分离MXML和AS
程序员文章站
2022-04-30 10:21:58
...
package oreilly.cookbook
{
import mx.containers.Canvas;
import flash.events.Event;
public class CodeBehindComponent extends Canvas
{
public function CodeBehindComponent()
{
super();
addEventListener(Event.ADDED_TO_STAGE, addedToStageListener);
}
protected function addedToStageListener(event:Event):void
{
trace(" Added to Stage from Code Behind ");
}
protected function clickHandler(event:Event):void
{
trace(" Click handled from component "+event.target);
}
}
}
<cookbook:CodeBehindComponent xmlns:mx="http://www.adobe.com/2006/mxml" width="200"
height="400" xmlns:cookbook="oreilly.cookbook.*">
<mx:Button click="clickHandler(event)"/>
</cookbook:CodeBehindComponent>
public class Billiard1 extends UIComponent
{
private var app:Application;
public function Billiard1(app:Application)
{
this.app = app;
init();
}
}
上一篇: 老中医养胃秘方