# $Id: mingtext.rb,v 1.1.1.1 2003/10/29 01:20:42 knok Exp $

require 'color'
require 'ming/ming'
include Ming

def centertext(text, size, font, color)
  t = SWFText.new
  t.set_font(font)
  t.set_color(color.red, color.green, color.blue)
  t.set_height(size)
  t.move_to(- t.get_width(text)/2, t.get_ascent/2)
  t.add_string(text)
  t
end

def lefttext(text, size, font, color)
  t = SWFText.new
  t.set_font(font)
  t.set_color(color.red, color.green, color.blue)
  t.set_height(size)
  t.move_to(0, t.get_ascent/2)
  t.add_string(text)
  t
end

def rightuptext(text, size, font, color)
  t = SWFText.new
  t.set_font(font)
  t.set_color(color.red, color.green, color.blue)
  t.set_height(size)
  t.move_to(- t.get_width(text), t.get_ascent*0)
  t.add_string(text)
  t
end

def multitext(movie, strs, size, font, color, offset)
  items = []
  x = offset[0]
  y = offset[1]
  strs.each do |str|
    if (str.class == String) 
      item = movie.add(lefttext(str, size, font, color))
      item.move_to(x, y)
      items.push(item)
      y = y + size * 1.5
    else
      movie.add(SWFAction.new('stop();'))
      movie.next_frame
    end
  end
  items
end

def msleep(movie, time)
  1.upto(time) do |t|
    movie.next_frame
  end
end
