Solved

Loading Movies with Variables

Posted on 2002-07-06
15
203 Views
Last Modified: 2012-05-04
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?
0
Comment
Question by:palare98
  • 8
  • 7
15 Comments
 
LVL 23

Expert Comment

by:Zeffer
ID: 7134422
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

0
 

Author Comment

by:palare98
ID: 7134783
that might work if I was using external movies, but I am using internal movie clips.
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7136400
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
0
 

Author Comment

by:palare98
ID: 7136429
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.
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7136590
sorry but it is still not perfectly clear..are all the clips..in different frames..in the same movie?
 
0
 

Author Comment

by:palare98
ID: 7136673
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.
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7136866
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


0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:palare98
ID: 7136898
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.
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7136918
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
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7137108
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

0
 

Author Comment

by:palare98
ID: 7141737
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.
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7142444
Fair enough.I'm working on it.

Z
0
 

Author Comment

by:palare98
ID: 7142466
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.
0
 
LVL 23

Accepted Solution

by:
Zeffer earned 200 total points
ID: 7145126
You have made this incredibly hard to do by wanting to run the intro clip and then tacking on the selected movie...Now you did say you are prepared to be flexible about this..so...if you dropped a copy of the intro into the front of each clip (this is no increase in file size as they are all coming out of the same library)..then you can target the clips..using variables..which is very clearly explained in this excellent tutorial and work files for download by Bryan Gaffin on .."how to use variables to control movie clips".

http://www.flashkit.com/search.php?term=Bryan+Gaffin&cat=tutorials&version=--&per=10&field=Contact_Name&orderby=Rating&andor=or&page=1&submit=Submit

there are some small changes to the first couple of frames of the clips to enable the player to read the variable..but it is a good introduction to using variables.

and thanks for persevering..I've learned something too..:)

Z
0
 

Author Comment

by:palare98
ID: 7145200
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.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now