Copy link to clipboard
Copied
I did this many years ago and I tried searching for this but did not find what I was looking for. I basically have a group of buttons and I want the buttons to load movie clips into an empty mc and then have the movie clip close again when the user clicks somewhere else. Do I actually have to save the movie clips as swf files first and then load them in to the empty mc?
Thanks!
Copy link to clipboard
Copied
You can save them as swfs if you like, or you can have them as movieclips in your library and add them from there. To add them from the library you need to assign a class name for each one and then you can create a new instance using the class name. To assign a class name, right click the mc in the library and select Linkage. In the panel that appears select the option to export for actionscript and then assign a clas name for the object in the field labeled as such.
Then to add it to your empty movieclip you would use... (assume you gave it a class name of "NewMC", and your empty movieclip is named "emptyMC")...
var newmc:NewMC = new NewMC();
emptyMC.addChild(newmc);
"newmc" is just an arbirtrary name assigned to the instance being created
Copy link to clipboard
Copied
Do I add that code to the buttons or to an actions layer?
Copy link to clipboard
Copied
never add code to your objects. keep all code on an actions layer.
Copy link to clipboard
Copied
So I created an actions layer and pasted the code in. I replaced what I thought I needed to replace with the names I have given. I got an error when I tried previewing that said: 1046: Type was not found or was not a compile-time constant: empty_mc.
Here's my AS:
var newmc:bio_mc = new bio_mc();
empty_mc.addChild(bio_mc);
It's been a while since I've used Flash and done actionscripting so appolgies for my newb questions.
Copy link to clipboard
Copied
You probably haven't created your empty_mc movieclip, or at least you haven't named it that.(instance names are assigned in the properties panel.)
Until you get the empty_mc figured out you can create it dynamically using...
var empty_mc:MovieClip = new MovieClip(); // creates an empty movieclip
var newmc:bio_mc = new bio_mc(); // creates the mc you want to put in it
empty_mc.addChild(bio_mc); // puts the mc in the empty one
addChild(empty_mc); // puts the empty mc on the display list
Copy link to clipboard
Copied
I do have my empty_mc labled with the instance of empty_mc. This is the error I just got now:
Scene 1, Layer 'actions', Frame 1, Line 5 | 1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject. |
Copy link to clipboard
Copied
What does frame 1, line 5 look like?
Copy link to clipboard
Copied
It just has this:
empty_mc.addChild(bio_mc); // puts the mc in the empty one
Copy link to clipboard
Copied
I missed that error...
should be: empty_mc.addChild(newmc);
bio_mc is the class name. Class names as a standard start with capital letters (as in Bio_mc) to help avoid confusing them with variables and instance names.
Copy link to clipboard
Copied
So that fixed the error, but it's loading the mc right when I test the movie instead of when I click the bio button? I also need to know how to specifiy where to load the empty mc because right now half of the bio_mc is getting cut off halfway off the screen.
Copy link to clipboard
Copied
If you expect a button to process those commands, then you need to incorporate those commands into the button's event handler function.
It sounds like you have the registration mark centered if it is halfway off where you think it should be. You can always adjust the objects x and y properties to place it wherever you want it to be.
Copy link to clipboard
Copied
How would I add those commands into the button's event handler function?
Copy link to clipboard
Copied
You could copy and paste them, or you could type them.
Copy link to clipboard
Copied
Is there a tutorial that covers all this? I've searched and searched and haven't found anything? Everything I find shows how to load swf files into empty mc's which is not what I want to do.