1 Reply Latest reply on Feb 22, 2010 10:30 PM by kglad

    key will not move array without clicking a button

    VicTropic

      so Im stuck on a peice of code that logically when I read it, it would work the way I want it to: I am trying to place a movieclip on the stage with a movieclip acting as a button, and that movie clip(placed on the stage) is attached to an array in the onPress function. I used a variable(i) to increase the level on the array every time the buttonMovieClip is clicked to attach a new movieclip to the array. Then I used a for loop to make a variable that would acnolage all the levels in the array up to variable(i) so that I could control all of the movieclips in the array. But for some reason, you cant control the array with the keyboard without pressing the buttonMovieClip:

       

       

       

      alldemons = new Array();

       

      summonsound = new Sound;

      attachMovie("toolframe","toolframe",_root.getNextHighestDepth(),{_x:0, _y:287});

      attachMovie("sbtn","sbtn",_root.getNextHighestDepth(),{_x:10, _y:337});

      attachMovie("actdis","actdis",_root.getNextHighestDepth(),{_x:425, _y:337});

      i=0

      s=5

      uptoi=0;

      _root.onEnterFrame = function(){

      sbtn.onPress = function(){

      sbtn.gotoAndPlay("sbtndwn");

      if(s>0){

      alldemons[i] = attachMovie("r_dmn","r_dmn"+i,_root.getNextHighestDepth(),{_x:250, _y:200-i});

      actdis.actdisp.text=uptoi

      i++

      s--

      }

       

      sbtn.onRelease = function(){

      sbtn.gotoAndPlay("sbtnup");

      }

      for(uptoi=0;uptoi<=i;uptoi++){

      alldemons[uptoi]._x = 400

      if(Key.isDown(Key.UP)){

      alldemons[uptoi]._x=200

      }

      }

      if(Key.isDown(Key.UP)){

      alldemons[1]._x=200

      }

      }

      }