Copy link to clipboard
Copied
I'm trying to create a button within a movie clip for an ipad app. (a next button for a slideshow, the slideshow page is a movie clip.
This is the code I tried. Button=nextbutton, movie clip= artworkmovie. I just want the button to advance the movie clip one frame.
nextbutton.addEventListener(MouseEvent.CLICK, nextClickHandler);
function nextClickHandler(event:MouseEvent):void
{
artworkmovie.nextFrame();
}
This works fine from the stage, but if I have the button "next" within the movie "artworkmovie" I get the error "Line19 1120 Access of undefined property nextbutton". (Line19 is "nextbutton.addEventListener(MouseEvent.CLICK, nextClickHandler);") How can I create a path to the button? I tried artworkmovie.nextbutton and that didn't work.
Sorry for such a basic question and thanks for your help.
artworkmovie.nextbutton should work. Make sure you have the button name assigned in every keyframe within the movieclip.
Copy link to clipboard
Copied
artworkmovie.nextbutton should work. Make sure you have the button name assigned in every keyframe within the movieclip.
Copy link to clipboard
Copied
I should add that you need to be sure the button exists when that code executes. If it is in some other frame, it does not yet exist as far as the code sees it.
Copy link to clipboard
Copied
Thanks for the reply. So how is it usually handled if a button is not used all the time? take it's Alpha down to 0? Do IOS apps usually just use different frames on the main stage or do they typically use movie clips? (out of old habit I usually have only one frame on the main timeline and use movie clips for all other content)
Thanks a lot for you time.
Copy link to clipboard
Copied
You're welcome. If you don't want a button to be interactable/visible, but it needs to be present, then taking its alpha down to 0 won't help because it can still be interacted with. What is usually done is that the button's visible property is set to false/true as needed or the button is kept offstage until it is needed.
Copy link to clipboard
Copied
Thanks! I feel like you just gave me the keys to the kingdom.