I have built a flash file with a number of buttons in it and I want to be able to press one of these buttons, and on the release, play a movie. eventually the other buttons will be doing the same thing(just playing different movies)
to see an example of what I am talking about, you can check out www.puccaclub.com/eng
...and go to the amusement section where the flash movies are.
I bet this is real simple to do and I've guessed some script but I keep getting errors.
Thanks very much in advance. Anyone who could help will be much appreciated.
Thank you very much, however, I tried using that script and giving instance name to my movie and it's still a no go. By the way, I am using Flash MX Professional 2004...don't know if that makes a difference...
I think a flash file that I could look at with how to do it would be very helpful...if that's not possible though, could you or anyone else offer some more step by step explanation? Thanks so much~~
you have your main file (where all the buttons are), have a layer in your main, call it "buttons", put your buttons here. add a new layer, call it "AS (fyi: actionscript)" this will be where we store our actionscript.
add an instance name to each button (ex. btn1, btn2, btn3, etc. IN respective order).
have your movie (other swf files) in the same directory as this main swf file. remember their names.
now say our other swf files are the following
-page1.swf
-page2.swf
-page3.swf
and our buttons are the following (these are their instance names)
-btn1
-btn2
-btn3
WARP UP:
BTN: 1, 2, and 3 are all in the layer "buttons". and the swf files: page1, page2, and page3 are all in the same directory as the main swf file.
Now add the actionscript in the "AS" layer of the main file.
Now create a target for the loading swf files, give it the instance name "myTargetMC"
IT MUST BE THE SAME SIZE AS THE LOADING SWF FILES. Put myTargetMC on the main file "Stage 1".
Alco, my questions now are...what do you mean by the buttons and page1.swf, etc. have to be in the same directory? and how do I create a target? where does it go in my main file?
not sure what buttons in the directory mean....but if you want to load external.swf's into yoru MAIN.swf (and have them play on top or in certain sections) these .swf's need to be in the same directory as the MAIN.swf (for his code) but you can change the path to anywhere....
a "target" is just a movieClip INSTANCE name...
say I create new symbol.. (movieClip) I call it _blank.. I hit "OK"..
in my library...I have a movieClip called "_blank" drag one of these movieClips to the stage...and place it anywhere... select it...and give it the INSTANCE NAME of "containerClip".
containerClip is now your TARGET..so you cna now load things into ..
Thank you very much for your brief response whispers...
it worked. I didn't even bother deleting that actionscript alco told me about with the target mc and it still works with your code from the last post on the button.
(before that, I eventually did get alco's method to work as well when you explained the directory stuff to me.)
Now I have one more question...is there any way for me to get the movie ("page1.swf") to load on a specific position on the stage. right now it's just loading near the bottom of the stage, out of place, and I don't want it there.
I want all the movies to eventually be loading in the same position, like they have them in that link I posted in my first post. puccaclub.com/eng
Thanks-
it will load where you place your TARGET clip....you can also create a movieClip (to be a container for this situation) on the fly...and position it.. (meaning you dont have the place the containerClip on the stage before hand)
okay but...if I position the page1.swf onstage beforehand let's say, people wills e it playing automatically won;t they??? I am so confused now.
and what does that new piece of code mean? what do I replace the "this" and "createEMptymovieclip" with? sorry, but i should probably still be considered somewhat of a newbie because i need this stuff explained in steps. thanks for your patience~!
you dont repleace createEmptyClip with anything..thats the actual command.
this is like saying the "current" timeline..so you can use it anywhere (inside other clips even)
peaople will see the .swf you load playing regardless... if you do NOT want them to see anything..put a stop(); action in the first frame of the EXTERNAL.swf
So I just put that code on all of my buttons, just changing the external movie clip name of course, and it will continue to work? and so for example, if i press the button to play "page1.swf" and I watch it...and then I press the button to play "page2.swf", will "page1.swf" disappear so that you only see "page2.swf"? I might pm you in the future when those movies are actually completed...you don't have to answer now. Thanks again~~
Okay... I've created a "demo" fla file with the swf files. In the folder attached is the: main.swf, main.fla, page1.swf, page1.fla, page2.swf, page2.fla. I have MX2004 so it may not work. But if it does take alook at what I did. I basically just created a MC (called it myTargetMC) made it the same dimensions as my pages that I want to load, and stuck it where i wanted my pages to load. I didn't want the myTargetMC to be visible so I added the code:
myTargetMC._visible = false;
And that closes the case on using: createEmptyMovieClip();
That's all you have to do.
And, mayy I suggest not to use buttons, use MC. And put all your code in one layer called Actions or AS, better organization. Just my thoughts, but do whatever you want. Take care.
Alex
Last edited by alco19357; 04-20-2006 at 10:40 PM.
Reason: Forgot to add the zipped files.