0
votes

I am facing a situation that I have problem understanding...

I am writing a little Drag and Drop game that comes with its own solution. Game starts on frame 1, solution of frame 150.

To show the solution, I chose to display all drag items in their original position and fade them out one by one while concurrently fading in another instance in the correct position.

In the "game" part, I made sure that all dragged items get added back to the stage to ensure that drags would not pass behind other drag-able objects. So at the end of my drag function, I added the line "this.parent.parent.addChild(this.parent)".

Where I get puzzled, is when I click the solution button, all dragged instances remain in place and no longer respond to Timeline actions. If I take out the "this.parent.parent.addChild(this.parent)" bit, all work fine (except for being able to drag behind other object)

Can someone explain this behavior to me?

TIA


Humm... I guess I spoke too soon!

My scenario is as follows: I placed 5 instances of a choice MC at the first level on my stage. The choice MC contains an instance of dragButton MC (mapped to its own class) and an instance of choiceText MC looking like:


[dragButton] choiceText


The intent is for the user to drag the dragButton MC on top of a specific instance of a choiceGroup MC.

To ensure that any dragged item passes over any other, I added

this.parent.parent.addChild(this.parent);

at the end of the dragButton's drag function. This has the effect of re-adding the choice MC containing the selected dragButton.

After further testing, I came to realize that the objects are getting added to the right "container" BUT cease to be "linked" to Timeline preferences.

This happens in the "correction" area where I fade out the choice and then fade in another instance in its intended location. However, the "fade" (Classic Tween) does not grab any MC that have been re-added to the stage.

Is there a workaround to this short of having to code my "fade-in/fade-out" rather than using timeline tweens?

TIA

1

1 Answers

1
votes

It sounds like you are adding your dragged instances to the wrong parent. In actionscript, you can take any object and re-assign it to any parent. So, you will need to look for which parent it really needs to be attached to.

If you add a child MC (MovieClip) to another parent MC that is visually below other parent clips, then it too will be below the other parent clips. By being an internal component of the new parent MC, it inherits the parent's z-index, no matter where that parent is located.

I would recommend checking out the "insert target path" command in the actions palette.

It allows you to navigate to the clip you want to re-attach from one parent to another and then see what path it is recommending.

You may be surprised at what the paths actually are from one MC (MovieClip) to another...

Also, by using a timeline of that length, you may actually be causing the correct parent to "disappear" from the stage because it is on a keyframe that does not contain the correctly labeled MC and may have caused any code attached to it to not be loaded.

I am not sure how you are doing things in your game, so these are all just guesses...