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

removeChild fails after convert layer into symbols

Community Beginner ,
Jun 03, 2024 Jun 03, 2024

Copy link to clipboard

Copied

Hi everyone,

 

Here I have a symbol(symbol1), it contains 3 layers

  • layer1, named 'as', it contains only one line on frame 100

 

removeChild(this)​

 

  • layer2, is a layer contains pic1
  • layer3, is a layer contains pic2

 

It goes all well. Until I changed layer2 and layer 3 into symbol2 and symbol3.

After layer2, layer3 are changed into symbols.

Symbol2 is put back on layer2, and Symbol3 is on layer3.

Everything keeps same, just all key frames are now contained in individual symbols.

 

And then,  code on layer1 raises error.  IT DOES NOT WORK NOW.

Error #1034: Type Coercion failed: flash.display::Stage@5e12d25d0d1  cannot convert to flash.display.MovieClip

 

I've also tried 

 

removeChild(this.symbol2)

 

to remove one layer directly. It still fails

ArgumentError: Error #2025: The provided DisplayObject must be a child of the caller.

 

Trace(symbol2.parent)

 

The result of the Trace statement above is: Parent of symbol2: [object symbol1]

So symbol2, is indeed a child of symbol1.

 

Any ideas? Again it works again if I put all key frames back on layer 2 and 3. But I just want to make them individual symbols so it'd be easier to reuse.

 

Thanks.

 

Views

59

Translate

Translate

Report

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 ,
Jun 04, 2024 Jun 04, 2024

Copy link to clipboard

Copied

LATEST

you should be using instance names.

 

whatever you want to remove use, trace(this) or trace(this.name), to confirm you have dealing with the correct object.  then you can use:

 

whatever.parent.removeChild(whatever)

Votes

Translate

Translate

Report

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