In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

表示オブジェクトの重なりの変更

Get Adobe Flash player
by kotaro_tan 26 Sep 2010
    Embed
/**
 * Copyright kotaro_tan ( http://wonderfl.net/user/kotaro_tan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/viZA
 */

package {
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.display.DisplayObject;
    
    public class Sample extends MovieClip {
        
        private var _ookisa:Number;
        private var _ball:Sprite = new Sprite();
        private var _ball2:Sprite = new Sprite();        

        
        public function Sample() {
            _ookisa = 0;
            _ball.graphics.beginFill(0x000000);
            _ball.graphics.drawCircle(0,0,100);
            _ball.x = stage.stageWidth/2;
            _ball.y = stage.stageHeight/2;
            _ball2.graphics.beginFill(0x121212);
            _ball2.graphics.drawCircle(0,0,100);
            _ball2.x = stage.stageWidth/2;
            _ball2.y = stage.stageHeight/2;                
            addChild(_ball);
            addChild(_ball2);        
            _ball.scaleX = _ball.scaleY = 0;
            _ball2.scaleX = _ball2.scaleY = 0;            
            _ball.addEventListener(Event.ENTER_FRAME, _onEnterFrameHandler);
        }
    
        private function _onEnterFrameHandler(event:Event):void {
            _ookisa += 0.05;
            if(_ookisa > 10) _ookisa = 0;
            _ball.scaleX = _ball.scaleY = _ookisa;    
            var lastIndex = _ball.parent.numChildren -1;
            _ball.parent.setChildIndex(_ball,lastIndex);    
            
            if (_ookisa > 5) {
                _ball2.addEventListener(Event.ENTER_FRAME, _onEnterFrameHandler2);
                _ball.removeEventListener(Event.ENTER_FRAME, _onEnterFrameHandler);
                _ookisa = 0;
            }
            
        }
        
        private function _onEnterFrameHandler2(eventObject:Event):void {
            _ookisa += 0.05;
            var lastIndex = _ball.parent.numChildren -1;
            _ball2.parent.setChildIndex(_ball2,lastIndex);
            if(_ookisa > 10) _ookisa = 0;
            _ball2.scaleX = _ball2.scaleY = _ookisa;
            if (_ookisa > 5) {
                _ookisa = 0;
                _ball.addEventListener(Event.ENTER_FRAME, _onEnterFrameHandler);
                _ball2.removeEventListener(Event.ENTER_FRAME, _onEnterFrameHandler2);                
            }
        }        
    }    
}