Copy link to clipboard
Copied
After drag and drop matching an object, the movie clip is not allowed to be used again when user click on "play again" button.
For example, after a user match a MC with an object, if successful will go to next scene and continue playing...
When user matching wrong pattern and back to the main scene and start to play again, the MC will became null property and not able to be used again, result will always return false.
How can i fix this problem? Any suggestion?
that's usually caused by changing frames and, at some point, that movieclip has been removed from the timeline. even though it's re-added, it's no longer the same object and therefore no longer continues to have the same reference.
the only way to ensure that's not occurring is to use code to add and remove your object from the display or to add it using the ide and never remove it for as long as you want to continue using the same reference. it doesn't need to be visible, but it needs to exist
...Copy link to clipboard
Copied
that's usually caused by changing frames and, at some point, that movieclip has been removed from the timeline. even though it's re-added, it's no longer the same object and therefore no longer continues to have the same reference.
the only way to ensure that's not occurring is to use code to add and remove your object from the display or to add it using the ide and never remove it for as long as you want to continue using the same reference. it doesn't need to be visible, but it needs to exist.
Copy link to clipboard
Copied
how do i add and remove my object? by using add child and remove child?
Copy link to clipboard
Copied
addChild() and removeChild() is one way to add an remove display objects. and because the objects continue to exist (even when removed and not displayed) that will probably eliminate your replay problem.
Copy link to clipboard
Copied
I am doing it this way, but not working also.
var answer:Circle = new Circle();
answer.x = 50;
answer.y=50;
addChild(answer);
answer.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_4);
function fl_ClickToDrag_4(event:MouseEvent):void
{
answer.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_4);
function fl_ReleaseToDrop_4(event:MouseEvent):void
{
if (answer.hitTestObject(b15)){
MovieClip(this.root).gotoAndPlay(1, "Scene 7");
}
else{
MovieClip(this.root).gotoAndPlay(1, "Scene 4");
}
removeChild(answer);
}
Copy link to clipboard
Copied
what's b15?
that looks like a potential problem if that frame is replayed.
Copy link to clipboard
Copied
It is a shape which need match/hit by the answer.
Copy link to clipboard
Copied
is it ever removed from the timeline?
Copy link to clipboard
Copied
how to see whether it is removed from timeline or not?
Copy link to clipboard
Copied
everytime you return to that frame is b15 defined? (eg, not null?)
Copy link to clipboard
Copied
yes,
Copy link to clipboard
Copied
Every movie cllip object need to use Add and Remove child method if want to replayable?
If that so, i think i know where the problem is.
Copy link to clipboard
Copied
not necessarily, but it does prevent a common problem with replays.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now