topical media & game development
hush-draw.mx
hush-draw.mx
[swf]
[flash]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
paddingLeft="0" paddingTop="0" paddingBottom="0" paddingRight="0"
width="100%" height="100%"
horizontalAlign="center" verticalAlign="middle"
creationComplete="init()"
>
<mx:Script>
<![CDATA[
import flash.events.MouseEvent;
import mx.core.UIComponent;
[Bindable] public var config:String = "@mx-hush-draw.xml";
private var xml:XML;
private var urlLoader:URLLoader = new URLLoader();
[Bindable] public var hello:String = "hello (default) world";
[Bindable] public var message:String = "(default) world";
[Bindable] public var button:String = "(default) click me!";
[Bindable] public var source:String = "../assets/clips/tube/balloon.flv";
[Bindable] public var volume:Number = 0.75;
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);
}
private function handler ( event:MouseEvent ):void
{
//field.text = hello;
}
mouse down
private function onMouseDown(event:MouseEvent):void
{
drawing = true;
hold = null;
beginX = event.localX; beginY = event.localY;
if (mode == 0) {
item = new Sprite();
var c:UIComponent = new UIComponent();
c.addChild(item);
item.graphics.lineStyle(3, 0xFFCC00);
item.graphics.moveTo(event.localX, event.localY);
video.addChild(c);
}
}
mouse up
private function onMouseUp(event:MouseEvent):void
{
drawing = false;
trace("stop:" + event.localX + "/" + event.localY);
}
mouse move
private function onMouseMove(event:MouseEvent):void
{
if (drawing){
if (mode == 0) item.graphics.lineTo(event.localX, event.localY);
}
trace("move:" // + mouseX + "/" + mouseY + " :"
+ event.localX + "/" + event.localY );
}
]]>
</mx:Script>
<!--
<mx:Panel
title="{message}" horizontalAlign="center"
paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"
>
<mx:Label id="field" width="180" fontWeight="bold" fontSize="24"/>
<mx:Button label="{button}" click="handler(event);" />
</mx:Panel>
-->
<mx:VideoDisplay id="video" height="100%" width="100%" maintainAspectRatio="false" autoPlay="false"/>
<!--
<mx:Label id="note" width="400" fontWeight="bold" fontSize="24"/>
-->
</mx:Application>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.