I can't get MovieClip(parent).play():void; to function correctly

452 Views Asked by At

I've been trying to make a parent of my movieclip to run, both via button and frame function. Neither were working. I'd got a warning everytime. This is a simple code I suppose. I never work with as3. But I need this to get done.

Here is what I did. As far as I read, it should be working, it just 1 child really. I use with and without 'this.' function. But nothing's working.

closeBtn.addEventListener(MouseEvent.CLICK, close);

function close(e:MouseEvent):void{
   MovieClip(this.parent).play():void;
}

I expect the parent timeline would play() or gotoandplay() as it should in as2. But I got warning of;

Symbol 'mcSetting_001_bubble', Layer 'ac_', Frame 1, Line 4, Column 33  1078: Label must be a simple identifier.

thank you so much for your help

2

There are 2 best solutions below

5
Not so Veteran On BEST ANSWER

You shouldn't include :void when calling a function, only when defining one.
Try changing the code to:

closeBtn.addEventListener(MouseEvent.CLICK, close);

function close(e:MouseEvent):void{
   MovieClip(this.parent).play();
}

(1) The compiler picked up the : and thought you were trying to create a label in the code, hence that particular error message.

(2) Don't use close as a function name since that's already a compiler keyword in AS3 language. Try renaming it to _close or something else. This way it wont clash with AS3's own built-in close.

0
K A M A L M A S R U N On

thanks for the help. i did remove :void. but i got warning instead, everytime. here's the warning.

Symbol 'mcSetting_001_bubble', Layer 'ac_', Frame 1, Line 3, Column 10  1023: Incompatible override.
Symbol 'mcSetting_001_bubble', Layer 'ac_', Frame 1, Line 3, Column 10  1021: Duplicate function definition.
C:\Program Files\Adobe\Adobe Animate CC 2019\Common\Configuration\Camera\Flash\privatePkg\___LayerProp___.as, Line 1, Column 1  5000: The class 'privatePkg.___LayerProp___' must subclass 'flash.display.MovieClip' since it is linked to a library symbol of that type.

i can't reply in the comment. it's too long, i'm sorry.

btw, column 10 is at function close name.