#!/usr/pkg/bin/ruby33
# Flash 8 bevel - move the mouse
# code by gazb : gazb dot ming at NOSPAM gmail dot com
# March 2007
# http://www16.brinkster.com/gazb/ming/
# Ruby code by Pawel Karwowski pkarwow at fastmail dot fm

require 'ming/ming'
include Ming

set_scale(20.0)
use_SWF_version(8)

@movie = SWFMovie.new
@movie.set_rate(31)
@movie.set_dimension(550,400)
@movie.set_background(0x00,0x00,0x00)

# create a box
@boxwidth=200
@boxheight=200

@box = SWFShape.new 
@box.set_right_fill(@box.add_fill(255,0,0))
@box.draw_line(@boxwidth,0)
@box.draw_line(0,@boxheight)
@box.draw_line(-@boxwidth,0) 
@box.draw_line(0,-@boxheight) 
@sp = SWFMovieClip.new
@sp.add(@box)
@sp.next_frame
@f1=@movie.add(@sp)
@f1.set_name("box")

# create an actionscript string
@strAction="

// create references to classes

box._x=Stage.width/2-box._width/2;
box._y=Stage.height/2-box._height/2;

box.cacheAsBitmap = true;

var listener = new Object();
listener.box = box;
listener.onMouseMove = function() {
    var xPercent = (Stage.width/2)-_xmouse;
    var yPercent = (Stage.height/2)-_ymouse;
	var ffbv=flash.filters.BevelFilter;
	var filter = new ffbv(yPercent, 45, 0xFFFF00, 0.8, 0x0000FF, 0.8, xPercent, yPercent, 1, 3, 'inner', false);

    var filterArray =[];
    filterArray.push(filter);
    this.box.filters = filterArray;
};

Mouse.addListener(listener);
listener.onMouseMove();

"

# write actionscript string to root frame #1
@movie.add(SWFAction.new(@strAction))

@movie.save("bevelfilter.swf",9)
