The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 4 of 4

Thread: TweenMax Arrays

  1. #1

    TweenMax Arrays

    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..

    function buildAmmo(ammo:MovieClip):void{
        if(ammoCon.numChildren == 1){
        currentAmmo = ammo;
    function fireFruit(e:MouseEvent):void{
            randomX = Math.random() * 649;
            //ammoCon.x = randomX;
            //ammoCon.y = stage.stageHeight;
            splatAreaX = mouseX;
            splatAreaY = mouseY;
            ammoConArray[ammoConArrayCounter] = new AmmoConMC();
            ammoConArray[ammoConArrayCounter].x = randomX;
            ammoConArray[ammoConArrayCounter].y = stage.stageHeight;
            ammoConArray[ammoConArrayCounter].visible = true;
            ammoCon.visible = true;
            //-------the best tween Engine ever!!!!!!!!!!!!!!!!!
  [ammoConArrayCounter], ammoSpeed, {x:splatAreaX, y:splatAreaY, onComplete:checkHitArea, bezier:[{x:randomX ,y:stage.stageHeight - 100}], orientToBezier:true});
            if(ammoConArray.length >= 7){

  2. #2
    I'm on vacation at the moment, typing this from a hotel, so I didn't have time to comb through your code to troubleshoot, but I figured I'd chime in and mention that it's easy to keep track of TweenMax instances because whenever you call or TweenMax.from(), it returns a TweenMax instance. So you could populate an Array like:

    var myTweens = new Array();
    var t1 =, 1, {x:"200"});
    That code could be simplified, but I wanted it to be readable so you get the concept. If you need to kill a particular tween, just call TweenMax.removeTween(myInstance); which could look like TweenMax.removeTween(myTweens[0]). Or you can force it to completion using the complete() method, like myTweens[0].complete(true). See the documentation for more details at

    Hope that helps!

  3. #3
    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.

  4. #4


    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.

    Here is my working code.

    function fireFruit(e:MouseEvent):void{
            randomX = Math.random() * stage.stageWidth;
                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;
            ammoCon.visible = true;
            //-------the best tween Engine ever!!!!!!!!!!!!!!!!!
  , ammoSpeed, {x:splatAreaX, y:splatAreaY, onComplete:checkHitArea, bezier:[{x:randomX ,y:stage.stageHeight - 100}], orientToBezier:true});
    Last edited by zanemx; May 14th, 2008 at 05:43 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012