Link to home
Start Free TrialLog in
Avatar of palare98
palare98

asked on

Loading Movies with Variables

I am trying to call movies using telltarget but with a variable.  By that I mean...I have numerous buttons that all call a movie clip.  When the called movie clip reaches it's end, I want it to call another movie clip  loaded within the current movie clip.  I do not want to make 7 duplicate clips so I want to assign a variable that will determine which movie clip is called.  Problem 2...let's say that I can get the above to work.  When I click on another button, I want to remove the current current movie clip from the stage...how do I do that, too?
Avatar of Zeffer
Zeffer
Flag of New Zealand image

don't use tellTarget..it is deprecated from Flash5 on..
use..with..instead..tellTarget only targets the path or url of a movie..with.. targets the movie as an object.

and anyway for what you want to do you can use the loadMovie and unloadMovie actions..

but first put an empty movie clip on the as a 'container' or 'target' into which the movie clip will load....give this movie the instance name of ..say..container..

put this on your buttons..and use your movie names where I've got..firstmovie.swf...and..nextmovie.swf

on (release)}
  loadMovie("firstmovie.swf","container");
{

in the last frame of your movie clips..

stop()
loadMovie ("nextmovie.swf",container);
unloadMovienum (1);

Z

Avatar of palare98
palare98

ASKER

that might work if I was using external movies, but I am using internal movie clips.
where are the clips located?levels,frames?
also you mention not wanting to make 7 duplicate clips..is this to run the movies sequentially..no matter which button is clicked first?

Z
the movies are loaded in a frame.  No they are not to be run sequentially.  I ned to be able to use a variable (or something like) that is declared when the button is pushed and tells the movie which clip to run.  Then when another button is pushed, it removes the current clip from the stage and allows the next one to start.
sorry but it is still not perfectly clear..are all the clips..in different frames..in the same movie?
 
no.  They are all in the same frame in the same movie on the same layer.  The clips are set to begin at frame 2.  Their first frame has a Stop action in it. This is what I was using the Tell Target for. I would use the tell target to call the instance of the clip and tell it to play frame 2.  I'm not adverse to doing it another way.  I just need o know how.
give each clip an instance name..
select a clip..go..window/panels/instance and type in a name..say..one..(next..two..three etc)
go to the main timeline and select a button.
now open the actions panel.
in..actions(it is under method in MX)..go down and find..with.. and click it.

now click on the blue circle with a cross in it(bottom right on the panel)and you will see the instance named..one.(and the others)..the panel  should be set on dot syntax..by default.. with absolute also checked.
click on ..one..and then ok... and the actionsript will now read..

on (release){
  with(_root.one){
gotoAndPlay(2);
 }
}

repeat this for the others..


on(release){
with(_root.two){
  gotoAndStop(1);
 }
}
on(release){
with(_root.three){
  gotoAndStop(1);
 }
}

}
on(release){
with(_root.four){
  gotoAndStop(1);
 }
}

so when you click on this button..movie one plays and the player looks for and parks..two,three and four.

the next button would have..two..or whatever in the first on(release) and then the rest would park any movie that happened to be playing.(this is a similar logic to show/hide layers in DHTML)

The quick way to do all this scripting is to do the first button and  then click on the right pointing triangle on the actionscript panel (near the top right corner).
select..export as file.

on the next button..select..import from file (select that .as file that was exported) and you only have minor changes to make to the instance names.

Z


welll..that would work, except that you're forgetting the very beginning part.  You click on the button, it calls "testmovie" when "testmovie" gets to the end it calls the next movie clip which is in a frame within "testmovie".  All of the button movies are in "testmovie".  I need a variable named when the button is clicked, then when "testmovie" reaches the end it refers back to the variable to call the correct next clip.  I appreciate your helpfulness, but I think that you are thinking about this too basically.  Most of what you have told me, I already know.  What I need to know, is how to use the variable to call the correct movie clip, and then when the next button is used how to unload the previous movie clip before the next one starts.  I don't just want to cover it up.
you can only use unloadMovie when a movie has been loaded using loadMovie..

yours have all been loaded to the player on the initial load...so all you can do is 'cover them up'...by replacing one with another. The others will stay loaded in the player.(but hidden)

you only need an action at the end of each clip that calls the frame which holds the next movie..and if you want the 'correct' next movie to play they are obviously sequential (in content).
With respect..because of the way your movie is structured, I think you are thinking about this too complexly..which is why I have had trouble understanding the question.

Z
a thought..if testmovie is an intro to each clip..put it on the front of each clip using a shared library and call each one individually..if you use the last code I posted this would work fine.

Z

I can appreciate where what I am trying to can be confusing.  While, you have definitely answered the unloading or removing the movie clip from the stage (answer:  it can't be done).  I am still holding out for the variable answer.  I appreciate you trying to create a resolve for what I am trying to do, but it does not address how to use variables to solve my problem.  I could have easily found a workaround.  I WANT to know how to use variables to solve this issue.
Fair enough.I'm working on it.

Z
It's really starting to bother me. I've read all of the online docs and the flash help...I cannot get it to work.
ASKER CERTIFIED SOLUTION
Avatar of Zeffer
Zeffer
Flag of New Zealand 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
While that was not exactly what I was looking for, and you are still making me use the first clip over and over...that was pretty cool and I will be able to use it.  Thanks.