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

ShootXBox (no360)

By Narongrit Kanhanoi (Heart) dinsor_ja@hotmail.com
Thailand
Get Adobe Flash player
by dinsor 11 Feb 2009
//
//  By Narongrit Kanhanoi (Heart) dinsor_ja@hotmail.com
//  Thailand
//   

package {
    import flash.display.Sprite;
    import flash.text.*;
    import flash.events.*;
    import flash.ui.Mouse;
    import flash.display.MovieClip;
    import flash.utils.Timer;

    public class ShootXBox extends Sprite {

        private var spaceShip:TextField;
        private var enyme:Array = new Array();
        private var startText:TextField;
        private var title:TextField;
        

        public function ShootXBox() {
            // write as3 code here..
            title = new TextField();
         title.text = "         GAME\n  -:Shoot X Box:-";
        title.scaleX = title.scaleY = 5;
            title.selectable = false;
        startText = new TextField();
        startText.text = "[Click To Start ] ";
         startText.scaleX =  startText.scaleY = 1.5;
            startText.selectable = false;
            startText.y = 250;
            startText.x = 160;
            addChild(startText);
               addChild(title);   
        this.addEventListener(MouseEvent.CLICK ,  startGame);
        }


        private function startGame(e:MouseEvent):void{
        this.removeEventListener(MouseEvent.CLICK ,  startGame);
        removeChild(title);
         removeChild(startText);
 

            spaceShip = new TextField();
            spaceShip.text = "==X==\n    =\n   = =";
            spaceShip.selectable = false;
            spaceShip.scaleX = 1.5;
            spaceShip.scaleY = 1.5;
            Mouse.hide();
            addChild(spaceShip);

            var n:Timer = new Timer(300);
	    n.addEventListener(TimerEvent.TIMER , makeO);
	    n.start();

            var fire:Timer = new Timer(250);
	    fire.addEventListener(TimerEvent.TIMER , shoot);
	    fire.start();
           this.addEventListener(Event.ENTER_FRAME , update );
        }
        private function update(e:Event):void{
            spaceShip.x = mouseX;
            spaceShip.y = mouseY;
        }
        private function makeO(e:TimerEvent):void{
            var O:MovieClip = new MovieClip();
            var f:TextField = new TextField();
         
            f.text = "[X]";
            f.autoSize = "left";
            f.selectable = false;
            O.y = 20;
            O.x = Math.random()*500;
            O.addChild(f);
            addChild(O);
            O.addEventListener(Event.ENTER_FRAME , move2);
            enyme.push(O);
        }
        private function shoot(e:TimerEvent):void{

            var bullet:MovieClip = new MovieClip();
            var f:TextField = new TextField();
            f.text = "||||";
            f.autoSize = "left";
            f.selectable = false;
            bullet.addChild(f);
            addChild(bullet);

            bullet.x = mouseX+25;
            bullet.y = mouseY;

            bullet.addEventListener(Event.ENTER_FRAME , move);
            
            addChild(bullet);

        }

        private function move(e:Event):void{
         try{
            var tg:MovieClip = e.target as MovieClip;
            tg.y -= 10;
            for(var i:Number =0; i<=enyme.length ; i++ ){
                if(tg.hitTestObject(enyme[i]) ){
                    var eny:MovieClip = enyme[i] as MovieClip;
                    removeChild(eny);
                    eny.removeEventListener(Event.ENTER_FRAME , move2);
                    enyme.splice(i,1);
                    
                    removeChild(tg);
                    tg.removeEventListener(Event.ENTER_FRAME , move2);
                }
            }
            if(tg.y < -100){
                removeChild(tg);
                tg.removeEventListener(Event.ENTER_FRAME , move);
             }
            }catch(e:Error){
                  trace(e);
            }
        }
        private function move2(e:Event):void{
             try{
             var tg:MovieClip = e.target as MovieClip;
            tg.y += 3;
             if(tg.y < -100){
               for(var i:Number =0; i<=enyme.length ; i++ ){
                    if(tg == enyme[i] ){
                        enyme.splice(i,1);
                    }
                }
                removeChild(tg);
                tg.removeEventListener(Event.ENTER_FRAME , move2);
             }
             }catch(e:Error){
                  trace(e);
            }
        }
    }

}