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

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

New Here ,
Apr 16, 2017 Apr 16, 2017

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?

294
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

correct answers 1 Correct answer

Community Expert , Apr 16, 2017 Apr 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

...
Translate
Community Expert ,
Apr 16, 2017 Apr 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.

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
New Here ,
Apr 16, 2017 Apr 16, 2017

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

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 ,
Apr 16, 2017 Apr 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.

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
New Here ,
Apr 16, 2017 Apr 16, 2017

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);

       

}

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 ,
Apr 16, 2017 Apr 16, 2017

what's b15?

that looks like a potential problem if that frame is replayed.

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
New Here ,
Apr 16, 2017 Apr 16, 2017

It is a shape which need match/hit by the answer.

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 ,
Apr 16, 2017 Apr 16, 2017

is it ever removed from the timeline?

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
New Here ,
Apr 16, 2017 Apr 16, 2017

how to see whether it is removed from timeline or not?

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 ,
Apr 16, 2017 Apr 16, 2017

everytime you return to that frame is b15 defined?  (eg, not null?)

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
New Here ,
Apr 16, 2017 Apr 16, 2017

yes,

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
New Here ,
Apr 16, 2017 Apr 16, 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.

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 ,
Apr 17, 2017 Apr 17, 2017
LATEST

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

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