Skip to main content
zsqrd34964785
Participating Frequently
April 16, 2017
Answered

Movie Clip became null after perform drag and drop matching an object game

  • April 16, 2017
  • 2 replies
  • 393 views

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?

    This topic has been closed for replies.
    Correct answer kglad

    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.

    2 replies

    zsqrd34964785
    Participating Frequently
    April 17, 2017

    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.

    kglad
    Community Expert
    Community Expert
    April 17, 2017

    not necessarily, but it does prevent a common problem with replays.

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    April 16, 2017

    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.

    zsqrd34964785
    Participating Frequently
    April 16, 2017

    how do i add and remove my object? by using add child and remove child?

    kglad
    Community Expert
    Community Expert
    April 16, 2017

    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.