Hi

need you help pl

i wrote this code


      package

    {

     

        import flash.display.MovieClip;

        import flash.display.DisplayObject;

        import com.greensock.TweenMax;

     

     

     

    public class Main extends MovieClip

        {

            public static var instance:Main;

            public var totalInventoryItems:Number;

            public var collected:Number;

            public var remaining:Number;

            public var inventory:Array;

     

            public function Main()

            {

                // constructor code

                Main.instance = this;

                collected = 0;

                txt.text = " ";

                stop();

            }

     

            public function prepareStage()

            {

                inventory = new Array();

                totalInventoryItems = 0;

     

                for (var i:int = 0; i < this.numChildren; i++)

                {

                    if (this.getChildAt(i) is InventoryItem)

                    {

                        totalInventoryItems++;

                    }

                }

                trace("totalInventoryItems", totalInventoryItems);

            }

     

            public function insertToInventory(object:DisplayObject)

            {

                var xx:Number = (68 - object.width)/2;

     

                if (inventory.length > 0)

                {

                    TweenMax.to(object, 1, {x:xx, y:inventory[inventory.length - 1].y + inventory[inventory.length - 1].height + 10});

                }

                else

                {

                    TweenMax.to(object, 1, {x:xx, y:10});

                }

                inventory.push(object);

     

                if (inventory.length == totalInventoryItems)

                {

                    this.nextFrame();

                    prepareStage();

                }

                collected++;

                remaining = totalInventoryItems - collected;

    trace(remaining,this.currentFrame);  // if you see anything less than 1 and then 4, you are assigning txt.txt to be "" when on  frame 4.

                txt.text = "you still have " + String(remaining) + " objects to collect.";

                if(remaining <= 1)

                {

                    txt.text = "You still have " + String(remaining) + " object to collect.";

                }

                if(remaining <= 0)

                {

                    txt.text = "";

                }

     

            }

        }

     }

on trace i got this: totalInventoryItems 11
10 2
9 2
8 2
7 2
6 2
5 2
4 2
3 2
2 2
1 2
totalInventoryItems 0
-11 3
totalInventoryItems 10
-2 4
-3 4
-4 4
-5 4
-6 4
-7 4
how can i fix it?

Thank you