欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

分离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();    
        }
}

 

相关标签: Flash Adobe