flash on 2010-5-9

by arumajirou
♥0 | Line 68 | Modified 2010-05-09 19:13:10 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.text.*;
    import flash.events.*;
    import mx.controls.Alert;
    

    public class FlashTest extends Sprite {
    		static public var to : TextField;
    		
        public function FlashTest() {
            // write as3 code here..
            to = new TextField();
            to.text = "test\n\n";
            var tf : TextFormat = new TextFormat();
            to.autoSize = TextFieldAutoSize.LEFT;
            to.defaultTextFormat = tf;
            addChild( to );
            
            var p : panel = new panel();
            addChild( p );
            p.width = parent.stage.stageWidth;
            p.height = parent.stage.stageHeight;
            
            var b : button = new button();
            p.addChild( b );
            
            addEventListener( MouseEvent.CLICK, click );
            p.addEventListener( MouseEvent.CLICK, p.click );
            b.addEventListener( MouseEvent.CLICK, b.click, true );
//            mouseChildren = false;
            b.mouseEnabled = true;
            Alert.show("test");
        }
        
        private function click( e : MouseEvent ) : void
        {
        		to.appendText( "parent.\n" );
        }
    }
}

import flash.display.*;
import flash.events.*;
class panel extends Sprite
{
	public function panel()
	{
		super();
		const g : Graphics = graphics;
		g.clear();
		g.beginFill( 0x0, 0 );
		g.drawRect( 0, 0, 465, 465 );
		g.endFill();
		mouseEnabled = false;
	}
	
	public function click( e : MouseEvent ) : void
	{
		FlashTest.to.appendText( "panel\n" );
	}
}

import flash.display.Sprite;
class button extends Sprite
{
	public function button()
	{
		super();
		const g : Graphics = graphics;
		g.clear();
		g.beginFill( 0xff0000 );
		g.drawRect( 0, 0, 150, 20 );
		g.endFill();
	}
	public function click( e : MouseEvent ) : void
	{
		FlashTest.to.appendText( "button\n" );
	}
}