[ActionScript 3.0] AS3 访问舞台上元件的方法

文档类:

package  {
    import flash.display.MovieClip;
    
    public class Main extends MovieClip {

        public function Main() {
            this.addChild(new Test());
        }

    }
    
}

子类:

package  {
    import flash.events.Event;
    import flash.display.Sprite;
    
    public class Test extends Sprite {

        public function Test() {
            this.addEventListener(Event.ADDED_TO_STAGE,init);
        }
        private function init(e:Event):void
        {
            //方法一
            this.parent["mc"].y = 120;
            //方法二
            //Main(parent).mc.y = 120;
            
            //方法三
            //Object(root).mc.y = 120;
        }
    }
    
}


mc为flash舞台上的一个影片剪辑。

 

posted on 2016-01-13 17:20  晏过留痕  阅读(854)  评论(0编辑  收藏  举报