Skip to main content
Known Participant
May 21, 2013
Question

Access button inside of movieclip?

  • May 21, 2013
  • 1 reply
  • 1592 views

I'm sure this has been asked and answered plenty of times, but I've been searching off and on for days and haven't found a solution that works.

I have a movieclip that loads inside of a scrollpane when the flash document is published.  Inside of that movieclip are buttons that I want to control the main timeline.  Here is the code that I am using for this:

PipeStr_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopFromFrame);

function fl_ClickToGoToAndStopFromFrame(event:MouseEvent):void

{

    myContent(root).gotoAndStop("PiperStretcher");

}

However, when I go to test everything, I get this error:

"

Scene 1, Layer 'Actions', Frame 1, Line 171120: Access of undefined property PipeStr_btn.

So I'm not sure how to proceed.  I thought about adding the code to the movieclip itself in an actionscript layer, but that's what you would do in AS2.  I like how in AS3, you just have the one layer of actions that control everything.  However, if I need to add AS inside my movieclip, I will.  I'm just not sure what is going on here.  I've been trying different things for days and nothing is working.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 21, 2013

myContent(root) makes no sense.

if you're trying to direct the main timeline, use:

MovieClip(root).gotoAndStop(...

CuwenAuthor
Known Participant
May 21, 2013

Thank you.  And 'my Content' is my movieclip's instance name.  I'm sorry, I should have said that.  I had found a previous post you had made awhile ago and was trying that, but it wasn't working.  But I had just mistyped something when I was trying to type out your code.  So I just copied and pasted, filled in my button's names and movie clip name, and everything worked great.  I should just stick to copying and pasting new code.  Here's what worked:

myContent(scrollPane.content).RetClip_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_7);

function fl_ClickToGoToAndStopAtFrame_7(event:MouseEvent):void

{

     gotoAndStop(7);

}