2

Here i tried to move card around by using the x and y axis it shows the following error:

TypeError: Error #1010: A term is undefined and has no properties. at GamePlay/moveNext()[D:\TrainingAS3\GamePlay.as:71]

When I click the button for move cards it shows in this statement

Globe.self.realstage.TweenLite.to(anEntry['card'], .4, { 
 x:anEntry['x'], y:anEntry['y'], onComplete:moveNext } );


package 
{
    import flash.display.MovieClip;
    import flash.events.TimerEvent;
    import flash.events.MouseEvent;
    import com.greensock.*;
    import com.greensock.easing.*;
    import Globe;

    public class GamePlay 
    {
        var currentEntry:int = -1;

        var aList:Array =
            [
                {card:Globe.self.realstage.joker_mc, x:605.55, y:195.45},
                {card:Globe.self.realstage.king_mc,  x:323.80, y:298.45},
                {card:Globe.self.realstage.queen_mc, x:45.85, y:213.95},
                {card:Globe.self.realstage.a_mc,     x:605.55, y:195.45},
                {card:Globe.self.realstage.ten_mc,   x:323.80, y:298.45},
                {card:Globe.self.realstage.five_mc,  x:45.85, y:213.95},
                {card:Globe.self.realstage.two_mc,   x:605.55, y:195.45},
                {card:Globe.self.realstage.nine_mc,  x:323.80, y:298.45},
                {card:Globe.self.realstage.four_mc,  x:45.85, y:213.95},
            ];

        public  function onClick(e:MouseEvent):void
        {
            // Unsubscribe to avoid the mess with second click.

            Globe.self.realstage.click_mc.removeEventListener(MouseEvent.CLICK, onClick);


            // Start process.
            moveNext();
        }

        public  function moveNext():void
        {
            currentEntry++;

            // Stop the process if all the cards have been moved.
            if (currentEntry >= aList.length) return;


            // Get the entry.
            var anEntry:Object = aList[currentEntry];

            // Move the card.
            trace(card);

            Globe.self.realstage.TweenLite.to(anEntry['card'], .4, { 
     x:anEntry['x'], y:anEntry['y'], onComplete:moveNext } );


        }


}

Could you please someone Elaborate this one ...

2
  • And trace(card) before the error outputs...? Also, trace(currentIndex) would help. Commented May 24, 2017 at 10:29
  • 3
    "Globe.self.realstage.TweenLite" looks suspicious. Shouldn't it be just "TweenLite" ? Make sure that aList already exists when you execute moveNext. Also check (trace) if card, x and y is set in each anEntry Commented May 24, 2017 at 11:28

1 Answer 1

3

That error means that one of the following objects are null/undefined:

self.realstage.TweenLite or anEntry

Looking at those objects and seeing you are importing com.greensock.*, the issue is with TweenLite.

TweenLite is a class, which means it cannot be a property of realStage (which is how you are trying to access it).

To remedy the situation, just reference the TweenLite class directly since you've already imported it:

TweenLite.to(anEntry['card'], .4, {x:anEntry['x'], y:anEntry['y'], onComplete:moveNext } );

To further understand what's going on, you could research the difference between Static properties and methods and regular properties and methods.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.