Solved

Using gotoAndStop(); on movie clip?

Posted on 2004-04-14
4
1,167 Views
Last Modified: 2006-11-17
I would like to make a button with a regular movie clip. I dont want to use a button.
When I use the code nothing happens. Is it possible to use a movie clip and not a button?

on (release) {
    gotoAndStop(20);
}
0
Comment
Question by:Tobbe070599
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Author Comment

by:Tobbe070599
ID: 10826577
Is this the case in FlashMX too?:

---------------------------------------------------------------------------

In your work on Assignment 3, some of you have made the unhappy discovery that the goto and gotoAndPlay statements do not work when they are used in scripts attached to Movie Clips.

The problem arises from a serious flaw in ActionScript--which I hope will be corrected in the next version of Flash. Here's the trouble in a nutshell: As James L. Mohler notes in Flash 5: Graphics, Animation, and Interactivity, "the Go To action is limited to jumping to frames and scenes in the current movie." Or, he might have added, the current Movie Clip. Because a Movie Clip has its own timeline, the statement

gotoAndPlay("Scene 2", 1)
refers not to Scene 2 of the main movie but to Scene 2 of the Movie Clip's own timeline. If the movie clip in question does not have a second scene (and very few do), then the statement simply does nothing. You won't even see an error message, which is quite annoying.

Now here's the worst part. Since Flash wants to be an object-oriented scripting environment, you might expect to be able to direct a goto action to an appropriate target in the object hierarchy, such as the main movie. But this is impossible, because the goto action cannot refer outside the object that contains it. In short: bad software engineering.


Two Solutions
If you can substitute a button for your Movie Clip, then do so. The goto action works properly in button scripts, for some rather arbitrary reason.

In some cases you will not be able to use a button to control a transition from one movie timeline to another. For example, you may want the symbol in question to be made visible or invisible when an action is performed on another symbol. Interactions of this sort require the symbol that is being operated upon to have an instance name. Only Movie Clips can be named; buttons cannot.

Luckily, the loadMovie action lets you achieve virtually the same effect as the goto action, though in a somewhat different fashion--and loadMovie works with Movie Clips.

Unlike goto, loadMovie requires you to create a second Shockwave movie file (.swf) to hold the content you would have placed in a second scene within the main movie if you were going to rely only on buttons and goto. Setting up a second movie is a simple matter. Just copy all the frames in your second scene, select File>New, and paste those frames into the new movie. Export the .swf of your new movie under some recognizable name (e.g., "yourLastName.assn3.part2.swf"). Return to the first movie and insert the following script on the instance of your Movie Clip:

  onClipEvent("mouseUp"){
    loadMovie("yourLastName.assn3.part2.swf", 0);
  }

Your Movie Clip should now control a transition to the second part of your content--though note you are in a separate movie, so any transitions back to your main movie must also use loadMovie.

To see this technique in action, see this simple demo. The source and object files for this demo are available on Crow in multimediaShare/goToAndMovieClips/.

Observation
Macromedia is pushing out Flash versions far too quickly. In this case, they've allowed a serious inconsistency within ActionScript: you do one thing for buttons and another for Movie Clips (which were not scriptable in Flash 4). Brace yourselves, folks--messy design like this makes learning the scripting language a lot harder than it needs to be.

-----------------------------------------


0
 
LVL 1

Accepted Solution

by:
andylaw78 earned 240 total points
ID: 10827192
the code should work if you write _parent.gotoAndStop(20);
your code at the moment tells the button movieclip to go to frame 20, _parent brings it back to the main stage. hope this works! good luck
0
 

Author Comment

by:Tobbe070599
ID: 10830688
Ok, it worked but I got the problem that I would like it to jump to a specific scene.
_parent.gotoAndStop("scene2",20) this does not work, is there a way to do this?

When I use _parent it jumps to the first scene in the movie.
0
 

Author Comment

by:Tobbe070599
ID: 10830844
Thank you for your help. I gave me more info so I could solve my problem...

I found the solution here.

http://iat.ubalt.edu/courses/old/pbds668.185_Sp02/gotoProblem.shtml

Thanks
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question