Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

hi

Guest
Feb 13, 2013 Feb 13, 2013

i  have a problem

on the secound  frame i collect objects  all goes well, i do see the text how many item i have to collect more

on the fourth ihaea nother items, i can collcet them but the text is mising , dont tellme how many items i have to collect more

the objects are link to the invetoryitems on the base class

thisis my invetoryitem class

package

{

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    import flash.media.Sound;

   

   

    public class InventoryItem extends MovieClip

    {

        public function InventoryItem()

        {

            // constructor code

            this.buttonMode = true;

            this.addEventListener(MouseEvent.CLICK, mouseClickHandler);

        }

        private function mouseClickHandler(e:MouseEvent):void

        {

            this.removeEventListener(MouseEvent.CLICK, mouseClickHandler);

            this.buttonMode = false;

            Main.instance.insertToInventory(this);

            var s:Sound = new button4();

            s.play();

            //addBubbles(e.currentTarget);

        }

        /*private function addBubbles(e:Object):void

        {

           

            var xx:Number = e.x;

            var yy:Number = e.y;

            var bubble:ballg = new ballg();

            bubble.x = xx;

            bubble.y = yy;

            e.parent.addChild(bubble);

            bubble.gotoAndPlay(1);

        }*/

    }

}

do i need to add something on my invetoryclass?

Thank you

TOPICS
ActionScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 13, 2013 Feb 13, 2013

there's nothing in that class that displays text.  you must have that code elsewhere.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 14, 2013 Feb 14, 2013

Hi

ok this is my code

it's  working just to frame 1 but doesnt work at frame 4 , and yes i have keyframe at frame 4 as well

at frame 4 i can collect the items like at frame one BUT the text i cant see, i cant find  why is that

thank you for your help

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;

            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 = "";

            }

        }

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2013 Feb 14, 2013

put txt in a layer by itself in frame one.  extend that layer to frame 4 with no keyframes after frame 1.  test.

once you have that working you can add keyframes to the txt containing layer if needed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 14, 2013 Feb 14, 2013

i  have the txt layer till frame 4

doesnt working

what else can i do?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2013 Feb 14, 2013

attach a screenshot showing your timeline,properties panel and stage with txt selected on stage.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 14, 2013 Feb 14, 2013

hi

the screenshot , on this frame the txt is not showing

screenshot.PNG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2013 Feb 14, 2013

that looks good.  (but you should anti-alias that text for reading, not animation and make sure your font is embedded.)

now, add the following trace statements and test your app when you expect text to be added when you're on frame 4:

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 = "";

            }

        }

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 14, 2013 Feb 14, 2013

Hi

that's what i got at the trace

totalInventoryItems 10

-2 4

-3 4

-4 4

-5 4

-6 4

-7 4

-8 4

-9 4

what that means? still cant see  the message how many item more to collect

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 14, 2013 Feb 14, 2013

OK thank you so much

now i see the problem

i use Math.abs and i fix it

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 14, 2013 Feb 14, 2013
LATEST

Well i use the math.abs but now its show the text but i got this on the trace

totalInventoryItems 10

2 4

3 4

4 4

5 4

6 4

7 4

8 4

9 4

it's dont count right

what can i do to fix it?

Thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines