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

Creating a button within a movie clip for ipad

Community Beginner ,
Aug 11, 2012 Aug 11, 2012

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.

TOPICS
ActionScript

Views

840

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

correct answers 1 Correct answer

LEGEND , Aug 11, 2012 Aug 11, 2012

artworkmovie.nextbutton should work.  Make sure you have the button name assigned in every keyframe within the movieclip.

Votes

Translate

Translate
LEGEND ,
Aug 11, 2012 Aug 11, 2012

Copy link to clipboard

Copied

artworkmovie.nextbutton should work.  Make sure you have the button name assigned in every keyframe within the movieclip.

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
LEGEND ,
Aug 11, 2012 Aug 11, 2012

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.

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
Community Beginner ,
Aug 11, 2012 Aug 11, 2012

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.

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
LEGEND ,
Aug 12, 2012 Aug 12, 2012

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.

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
Community Beginner ,
Aug 12, 2012 Aug 12, 2012

Copy link to clipboard

Copied

LATEST

Thanks! I feel like you just gave me the keys to the kingdom.

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