variable(s)
private var item:Sprite;
[Bindable] private var drawing:Boolean = false;
[Bindable] private var mode:uint = 0;
private var beginX:Number = 0;
private var beginY:Number = 0;
private var hold:UIComponent = null;
private function init():void {
if (Application.application.parameters.config) {
config = Application.application.parameters.config;
}
urlLoader.addEventListener(Event.COMPLETE,loaded);
urlLoader.load(new URLRequest(config));
}
private function loaded(e:Event):void{
xml = new XML(e.target.data);
button = xml..button.@text;
message = xml..button.@panel;
hello = xml..button;
if (xml..video.@source) { video.source = xml..video.@source; }
if (xml..video.@volume) { video.volume = xml..video.@volume; }
//if (xml..video.@width) { video.width = xml..video.@width; }
//if (xml..video.@height) { video.height = video.height * xml..video.@height; }
//video.volume = xml..video.@volume;
//source = xml..video.@source;
//note.text = video.source + " " + video.volume + " " + video.height;
//video.source = source;
video.play();
//trace(xml);
video.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
video.addEventListener(MouseEvent.MOUSE_UP, onMouseUp)
video.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
//ExternalInterface.call( "jsfun", "init" );
//ExternalInterface.addCallback( "function1", callback1 );
//ExternalInterface.addCallback( "function3", callback3 );
ExternalInterface.addCallback( "drawf", cdraw );
// callback1();
// callback1();
}
private var count:Number = 0;
private function callback1() : void
{
// note.text = "test function1: " + count++;
}
private function callback3(parameter : *) : String
{
//note.text = parameter.toString();
return "received from mx: " + parameter.toString();
}
private function handler ( event:MouseEvent ):void
{
//field.text = hello;
}
private function cdraw(parameter : *) : String
{
//note.text = parameter.toString();
//return "received from mx: " + parameter.toString();
var dir:String = parameter.toString();
var fx:Number = 10;
var dx:Number = 0;
var dy:Number = 0;
if (dir == "left") dx = -1;
if (dir == "right") dx = 1;
if (dir == "up") dy = -1;
if (dir == "down") dy = 1;
dx *= fx; dy *= fx;
item = new Sprite();
var c:UIComponent = new UIComponent();
c.addChild(item);
item.graphics.lineStyle(3, 0x0000FF);
item.graphics.moveTo(beginX, beginY);
video.addChild(c);
beginX += dx; beginY += dy;
item.graphics.lineTo(beginX, beginY);
// note.text = parameter.toString() + " " + dx + " " + dy;
return "OK";
}