Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 685
  • Last Modified:

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?
0
brucegust
Asked:
brucegust
  • 6
  • 4
  • 3
1 Solution
 
john_hollingsCommented:
you are using the gotoAndStop if you want it to play the promo sence then you need to use gotoAndPlay.
0
 
brucegustPHP DeveloperAuthor Commented:
I changed that, but the button still isn't working. Do I have the "_root" thing wrong?
0
 
john_hollingsCommented:
Are you using AS2 or AS3.  If AS3 try using parent or _level0.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
john_hollingsCommented:
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");
}
0
 
ccareyCommented:
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.
0
 
brucegustPHP DeveloperAuthor Commented:
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
0
 
ccareyCommented:
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
0
 
brucegustPHP DeveloperAuthor Commented:
I uploaded a new copy, It's the same URL. Check it out and I do appreciate your time.

Thanks!
0
 
ccareyCommented:
I modified your file and it works fine for me with labels in place.

button script looks like this (just one parameter - forget the ,1):

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

see the screen grab of the timeline for label placement (the view is of the "Promo" scene). I expanded the timeline to 20 frames so you can see the label.

Note that case sensitivity applies. If you target "Promo" with a capital P your label must match that. If you spell it "promo" (small p) it won't work. Doesn't matter what case you prefer as long as it's the same.



timeline.JPG
0
 
brucegustPHP DeveloperAuthor Commented:
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!
0
 
ccareyCommented:
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.
0
 
brucegustPHP DeveloperAuthor Commented:
Got it!

Thanks so much!
0
 
brucegustPHP DeveloperAuthor Commented:
Too, too cool!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now