Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

Button within a movie clip

I've got a movie clip on my main timeline. The buttons in teh movie clip are scripted like this:

on (release) {
      _root.gotoAndStop("Promo",1);
}

I'm trying to go back to the main timeline, find the scene "Promo" and play it. Nothing complicated, but I can't get it to work.

What am I missing?
Avatar of john_hollings
john_hollings
Flag of United Kingdom of Great Britain and Northern Ireland image

you are using the gotoAndStop if you want it to play the promo sence then you need to use gotoAndPlay.
Avatar of Bruce Gust

ASKER

I changed that, but the button still isn't working. Do I have the "_root" thing wrong?
Are you using AS2 or AS3.  If AS3 try using parent or _level0.
Alternatively best practice is to have most your actionscript on your main timeline, on a actions layer.

To reference the button within the movieclip first ensure th mc has an instance name and the button within it has an instance name.  To add an instance select the object and look at the property panel.

//Code for AS2
mymovieClip_mc.myButton_btn.onRelease = function()
{
     _root.gotoAndPlay("promo", 1);
}

//Code for AS3, you need to reference the frame number first then the scene, but ensure you import the events class as shown.

import flash.events.*;
stop();

myMovieClip_mc.myButton_btn.addEventListener(MouseEvent.CLICK, myButton_CLICK);

function myButton_CLICK(e:MouseEvent)
{
      gotoAndPlay(1, "promo");
}
your easiest way through is to just place a label on frame 1 of scene Promo. Call the label "Promo"

Then your button script just uses the label like so:

on (release) {
      _root.gotoAndPlay("Promo");
}

Scenes have flaky support when it comes to navigation. Always use a label.
ccarrey, I tried your suggestion and named the first frame of every scene, it didn't make a difference.

john, I tried your script and it didn't work either.

I have zipped up my "stuff" and placed it at the following URL. Diet Cokes all around for the person who can tell me where I'm blowing it.

I didn't include the videos thinking that a person interested in solving my dilemma would be able to correct the code without having to see the video.

http://www.hihatwebdesign.com/VideoGallery.zip
Wasn't able to open that zip - looks like it's corrupted or not uploaded completely.  If you could try re-uploading I'm happy to take a look at the FLA
I uploaded a new copy, It's the same URL. Check it out and I do appreciate your time.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of ccarey
ccarey
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ccarey

I must be still missing something. If you go to http://www.hihatwebdesign.com/VideoGallery.zip again, I've uploaded the version that is incorporating your suggestions. I don't doubt that I SHOULD work, but I'm overlooking something and I don't know what.

Thanks for your time!
You haven't put a label on the Promo scene, only Intro and Contestants, but as far as I can see none of the buttons target these scenes anyway.

Expand the timeline like I've done above and you'll be able to clearly see your labels. Put a label on the Promo scene and you should be fine.
Got it!

Thanks so much!
Too, too cool!