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

Just a Button

逆転の発想的なかんじで
Get Adobe Flash player
by sakusan393 16 Sep 2010
/**
 * Copyright sakusan393 ( http://wonderfl.net/user/sakusan393 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/amUe
 */

package  
{
    import com.bit101.components.PushButton;
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.net.URLRequest;
    import flash.system.Security;
    import flash.ui.Mouse;
    import jp.progression.commands.lists.LoaderList;
    import jp.progression.commands.net.LoadSWF;
    
    /**
     * ...
     * @author 393
     */
    public class HandButton2 extends Sprite
    {
        
        public function HandButton2() 
        {
            stage.align = StageAlign.TOP_LEFT;
            Security.loadPolicyFile("http://assets.wonderfl.net/crossdomain.xml");
            loadHand();
        }
        
        
        
        
        private var _handArray:Array;
        private var _handCount:int;
        public function loadHand():void
        {
            
            var btn:PushButton = new PushButton(this, 0, 0, "Button",handBtnClickHandler);
            btn.scaleX = btn.scaleY = 4;
            btn.x = stage.stageWidth / 2 - 200;
            btn.y = stage.stageHeight / 2 - 50;
            btn.addEventListener(MouseEvent.ROLL_OVER, function(e:MouseEvent):void { btn.alpha = .8; } );
            btn.addEventListener(MouseEvent.ROLL_OUT, function(e:MouseEvent):void { btn.alpha = 1; } );
            
            var loader0:Loader = new Loader();
            var loader1:Loader = new Loader();
            
            loader0.load(new URLRequest("http://assets.wonderfl.net/images/related_images/f/fe/fe58/fe58561f3aa5c17f2f7c085624a011bd15aae90e"));
            loader1.load(new URLRequest("http://assets.wonderfl.net/images/related_images/c/cd/cd1d/cd1d53ec46913066792e290f0b53feba25168cf2"));
            loader0.contentLoaderInfo.addEventListener(Event.COMPLETE, handInit);
            loader1.contentLoaderInfo.addEventListener(Event.COMPLETE, handInit);
            loader1.visible = false;
            addChild(loader0).x = addChild(loader1).y = 1000;
            loader0.mouseEnabled = loader1.mouseEnabled = false;
            _handArray = [loader0,loader1];
        }
        
        private function handBtnClickHandler(e:MouseEvent):void
        {
            
        }
        private function handInit(e:* = null):void
        {
            _handCount++;
            if (_handCount < 2) return;
            Mouse.hide();
            this.addEventListener(Event.ENTER_FRAME, handEnterFrameHandler);
            stage.addEventListener(MouseEvent.MOUSE_DOWN, stageDownHandler);
            stage.addEventListener(MouseEvent.MOUSE_UP, stageUpHandler);
        }
        
        private function stageDownHandler(e:MouseEvent):void 
        {
            _handArray[0].visible = false;
            _handArray[1].visible = true;
        }
        private function stageUpHandler(e:MouseEvent):void 
        {
            _handArray[0].visible = true;
            _handArray[1].visible = false;
        }
        
        private function handEnterFrameHandler(e:Event):void 
        {
            for (var i:int = 0; i < 2; i++)
            {
            _handArray[i].x += (mouseX-_handArray[i].x -5)*.4;
            _handArray[i].y += (mouseY-_handArray[i].y -35)*.4;
            }
        }
        
    }

}