0

Hey Guys so I am using TweenLite to act as a timer for Performance with Mobile usage. I ran into a little problem here that I can't seem to figure out. So In my ENTER_FRAME Listener I have this function difficultyController Where I add my TweenLite control like so:

    private function difficultyController():void 
    {
        if (nScore >= 10)
        {
            TweenLite.delayedCall(nChainsaw, addChainsaw);
            trace("DIFFICULTY_UPDATE");
        }
    }

In my addChainsaw Function I have the Movie Clip Objects added to the stage like so:

    private function addChainsaw():void 
    {
        TweenLite.delayedCall(nChainsaw, addChainsaw);
        var newChainsaw = new mcChainsaw();
        //Add Child
        addChild(newChainsaw);
        //Push Move CLips into array
        aChainsawArray.push(newChainsaw);
        trace(aChainsawArray.length + "chainsaw");
    }

Now I want the chainsaw Movie clip in the array to be added to the stage every 2 seconds which is what the value of nChainsaw is. Ill kill it off when the nScore reaches a higher number. But as of right now when I test the Game like so It adds Multiple Movie clips over and over again then freezes the game. I know it has to do with the ENTER_FRAME Listener But I don't know what else to do. SHould I just remove the TweenLite and add A Actual Timer and in the diffucultyController(); just add timer.start??

If anyone has anyother Ideas I would really Appreciate it thanks!

Nathan
  • 536
  • 4
  • 21
  • Most likely: infinite loop issues. Hard to say without seeing the `ENTER_FRAME` listener. –  Jul 28 '15 at 07:51
  • the only thing inside the ENTER_FRAME Listener is the function diffucultyController(); – Nathan Jul 28 '15 at 07:57
  • It might just be something specific with Tweenlite though. Might have to use a timer instead even thought that slows down performance greatly – Nathan Jul 28 '15 at 08:00
  • 1
    if you are really looking to call a certain function every certain number of seconds, then avoid both `ENTER_FRAME` as well as `TweenLite` and simply use `setInterval` attached to an `intervalID` or even better, a `Timer` object and control that. Once your certain condition reaches, you could get rid of the `setInterval` or the `Timer` object. – Tahir Ahmed Jul 28 '15 at 08:52
  • If you are concerned about the performance , it's good to avoid enter frame and use timer events as @TahirAhmed said. – harilalkm Jul 28 '15 at 11:31

0 Answers0