TweenMax Arrays

[LEFT]Problem as follows…

I’m creating a flash game that throws rotten fruit at a band. When the game starts you select what type of fruit you want. There are 10 different fruits. I created a empty movie clip called —var ammoCon:MovieClip = new MovieClip(); to hold whichever fruit the use selects by the addChild(tomato_mc); method.

Right now the problem I have is that when I “fire” the fruit at the band I cannot fire another shot till the first shot has hit it’s target and been removed from the display list. If I do try to fire another shot the one currently in flight is removed instantly.

What I need is to fire the fruit as fast as I want. I know I need to use an array. The problem is I can’t figure out how to store the TweenMax Tweens into an array. And I’m not sure that’s my only problem, I think there are a few other code mistakes. I know how to add the fruit to the empty movieClip, but not sure how to add this object to a tween array.

ps TweenMax is the only Tween lib I can use because it contains the besier curve method

Please help. If you need further description of the problem I will give it.
here is the code that has had me stumped for a few days…

//-------buildAmmo-------//
function buildAmmo(ammo:MovieClip):void{
    //trace(ammoCon.numChildren);
    if(ammoCon.numChildren == 1){
        ammoCon.removeChildAt(0);
    }
    //ammoCon.addChild(ammo);
    currentAmmo = ammo;
    trace(currentAmmo);
}

function fireFruit(e:MouseEvent):void{
        
        randomX = Math.random() * 649;
        //ammoCon.addChild(currentAmmo);
        //ammoCon.x = randomX;
        //ammoCon.y = stage.stageHeight;
        
        splatAreaX = mouseX;
        splatAreaY = mouseY;
        
        
        swoosh1Fx.play();
        
        ammoConArray[ammoConArrayCounter] = new AmmoConMC();
        ammoConArray[ammoConArrayCounter].addChild(ammoCon);
        ammoConArray[ammoConArrayCounter].x = randomX;
        ammoConArray[ammoConArrayCounter].y = stage.stageHeight;
        ammoConArray[ammoConArrayCounter].visible = true;
        ammoCon.visible = true;
        //-------the best tween Engine ever!!!!!!!!!!!!!!!!!
        TweenMax.to(ammoConArray[ammoConArrayCounter], ammoSpeed, {x:splatAreaX, y:splatAreaY, onComplete:checkHitArea, bezier:[{x:randomX ,y:stage.stageHeight - 100}], orientToBezier:true});
        //trace(ammoConArray.length);
        //trace(ammoConArray[ammoConArrayCounter].getChildAt(0));
        //trace(ammoConArray.length);
        ammoConArrayCounter++;
        if(ammoConArray.length >= 7){
            ammoConArray.pop();
            ammoConArrayCounter--;
        }

}

[/LEFT]

ok im sure how tween max works and how your depth is organized but thats what i can see because you cant have to items at the same depth so when you throw one tomato the reason it gets replaced is there is no different depth so try putting in a depth changer that makes it so that they dont all end up on the same layer or the item will just replaced. :smiley:

Thanks Guys I finally figured it out with a little help from both your post. TweenMax is a great Tween Engine. Thanks Green Stock. I need to study it a bit more to understand how it’s working. I believe it’s creating a new tween instance each time I call it. I need to figure out if the tweenMax instance gets destroyed when the tween is complete. And if not remove it accordingly. Just haven’t got to it yet. :angel:

Here is my working code.


//-------fireFruit-------//
function fireFruit(e:MouseEvent):void{
        
        randomX = Math.random() * stage.stageWidth;

        switch(currentAmmo){
            case "tomato":ammoCon = new TomatoAmmo();break;
            case "lettuce":ammoCon = new LettuceAmmo();break;
            case "eggs":ammoCon = new EggAmmo();break;
            case "rawSteak":ammoCon = new RawSteakAmmo();break;
            case "potato":ammoCon = new PotatoAmmo();break;
            case "tomatoCan":ammoCon = new TomatoCanAmmo();break;
            case "grandpasUnderwear":ammoCon = new GrandpasUnderwearAmmo();break;
            case "diaper":ammoCon = new DiaperAmmo();break;
            case "bottleRocket":ammoCon = new BottleRocketAmmo(); break;
        }
        
        
        ammoCon.x = randomX;
        ammoCon.y = stage.stageHeight;
        
        splatAreaX = mouseX;
        splatAreaY = mouseY;
        
        swoosh1Fx.play();
        
        addChildAt(ammoCon,1);
        
        ammoCon.visible = true;
        
        //-------the best tween Engine ever!!!!!!!!!!!!!!!!!
        TweenMax.to(ammoCon, ammoSpeed, {x:splatAreaX, y:splatAreaY, onComplete:checkHitArea, bezier:[{x:randomX ,y:stage.stageHeight - 100}], orientToBezier:true});
}