flash on 2012-5-10

by yarhalla1
♥0 | Line 33 | Modified 2012-05-10 12:25:07 | MIT License
play

ActionScript3 source code

/**
 * Copyright yarhalla1 ( http://wonderfl.net/user/yarhalla1 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pwXo
 */

<?xml version="1.0" encoding="utf-8"?>
<!--
 Sample source from Adobe devnet
 http://www.adobe.com/jp/devnet/actionscript/articles/event_handling_as3.html
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            applicationComplete="initApp()">
   <mx:Script>
      <![CDATA[
         public function boxDown(event:MouseEvent):void {
            trace2("box down");
            stage.addEventListener(MouseEvent.MOUSE_UP, boxUpOutside);
         }

         public function boxUpOutside(event:MouseEvent):void {
            if (event.target != box) {
                trace2("box up outside");
            }else{
               trace2("box up");
            }

            stage.removeEventListener(MouseEvent.MOUSE_UP, boxUpOutside);
         }

         public function initApp():void {
            box.addEventListener(MouseEvent.MOUSE_DOWN, boxDown);
         }
         
         public function trace2(str:String):void{
               trace.text = str + "\n" + trace.text;
         }

      ]]>
   </mx:Script>
   
   <mx:Canvas id="box" width="200" height="200" backgroundColor="#800000">
   </mx:Canvas>
   <mx:TextArea id="trace"></mx:TextArea>
   
</mx:Application>