Skip to main content
Inspiring
November 15, 2010
Question

_root to AS3 - EASY ONE!

  • November 15, 2010
  • 2 replies
  • 25813 views

I swear I've googled all over for this before I posted.  I've tried things I've read, but nothing's worked (or made sense to me, for that matter).

What I have is pretty basic.  Trying to do what WOULD have been this in AS2:

mute_btn.addEventListener(MouseEvent.CLICK, onMute);
function onMute(e:MouseEvent):void {

     _root.soundbars_mc.gotoAndStop(2);

}

Both mute_btn and soundbars_mc are on the main timeline.  I can't get this to work, and I know it's easy.  Any help???

Thanks!

This topic has been closed for replies.

2 replies

Participant
March 26, 2020

mute_btn.addEventListener(MouseEvent.CLICK, onMute);

// try to delete _root.
function onMute(e:MouseEvent):void {

     soundbars_mc.gotoAndStop(2);

}

Participating Frequently
November 15, 2010

Hi,

   In ActionScript 3 _root was changed to just root

Hope this helps,

Regards,

Peter Witham

www.uibuzz.com

Inspiring
November 15, 2010

That's what I thought.  But if I make that line:

root.soundbars_mc.gotoAndStop(2);

Then I get this error:

Scene 1, Layer 'Actions', Frame 1, Line 76    1119: Access of possibly undefined property soundbars_mc through a reference with static type flash.display:DisplayObject.

Ned Murphy
Legend
November 15, 2010

AS3 gets picky (aka stupid) at times, requiring you to tell it what it already knows anyways.  Try using...

MovieClip(root).soundbars_mc.gotoAndStop(2);