Pages: [1]
Author Topic: invisible targets  (Read 6795 times)
0 Members and 1 Guest are viewing this topic.

Brians: 0
Offline Offline

Posts: 1

« on: May 07, 2012, 12:38:17 AM »

for some reason the game runs fine and finds no errors but it wont run the targets to shoot at, i think theres some problem with adding them to stage but cant quite see it.

var TargetTime:int = 1;          
var TargetLimit:int = 40;

if(TargetTime < TargetLimit){
   TargetTime ++;
   else {
      var newTarget = new Target ();
      newTarget.y = -1 * newTarget.height;
      newTarget.x = int(Math.random()*stage.stageWidth - newTarget.width);
      TargetTime = 0;

and the seperate .as file:
   import flash.display.MovieClip;         
   public class Target extends MovieClip{
      private var _root:Object;
      private var speed:int = 10;     
      public function Target(){
addEventListener(Event.ADDED, beginClass);      
addEventListener(Event.ENTER_FRAME, eFrame);   
      private function beginClass(event:Event):void{
         _root = MovieClip(root);
      private function eFrame(event:Event):void{
         y += speed;
         if(this.y > stage.stageHeight){
            removeEventListener(Event.ENTER_FRAME, eFrame);

can anybody see whats wrong?
Pages: [1]
Jump to:  

Terms of service | Privacy policy

Paul Vickers is a participant in the Amazon Europe S..r.l. Associates Programme, an affiliate advertising programme designed to provide a means for sites to earn advertising fees by advertising and linking to

How to think like a programmer: problem solving for the bewildered pdf
How to think like a programmer: program design solutions for the bewildered pdf
Powered by EzPortal