newb flash question

Out of context: Reply #5

  • Started
  • Last post
  • 5 Responses
  • armsbottomer0

    i'm not sure how you want the movement increments to work. if its a certain amount in addition to each movieclip's width, could just get the width of the clip and add a number to it:
    mc.width += 50;

    however, if yo need to specify particular coordinates, you could store them in an array and have a counter correspond to where you are in the array. the prev and next buttons would increment and decrement the counter accordingly. the following code may be a buggy, i haven't programmed with AS in a while (and i'm tired ;) ).

    counter:int = 0;
    targetX = new Array("193", "20", "-150", "322");
    next.addEventListener(MouseEvent... changeCount);
    prev.addEventListener(MouseEvent... changeCount);

    function changeCount(e:Event):void{
    if(e.target == next){
    if(counter == targetX.length){
    counter = 0;
    }
    else{
    counter++;
    }
    }
    if(e.target == prev){
    if(counter == 0){
    counter = 5;
    }
    else{
    counter--;
    }
    }
    slideTo();
    }

    function slideTo():void{
    if(counter == num[counter[){
    targetX[counter]= 193;
    }
    else if(counter == num[counter]){
    targetX[counter] = 20;
    }
    //etc....
    }

View thread