PDA

View Full Version : Quick function/param question



dAEL
February 24th, 2005, 11:13 PM
Alright basically I want to make it so when i duplicate a movie clip, it sends its instance name to a function thats on the main timeline and executes the actions from there, for example...

I duplicate a movie clip of a block, and in its onClipEvent(load), it contains, _root.fallingBlock(instance name).

Then on the main timeline there is a method, called fallingBlock obviously, that takes the instance name as a parameter and runs through the given code, such as...

function fallingBlock(instanceName) {
_root.instanceName._y += 5;
}

Thnx in advance :D

E-Slayer
February 24th, 2005, 11:17 PM
You'd want the function to be something like:

function fallingBlock(instanceName){
_root[instanceName]._y += 5;
}

And to call it from the clip:

_root.fallingBlock(this._name);

dAEL
February 24th, 2005, 11:27 PM
ahhhh, _name!

thnx a ton bud ! :D :D :D

E-Slayer
February 24th, 2005, 11:28 PM
Not a problem. That one took me a while to get, it was all those stupid square brackets' fault.

dAEL
February 24th, 2005, 11:43 PM
Ok one last dumb question thats kinda off topic :P

When duplicating a movie clip, does the original movie clip need to be on the main timeline somewhere, or can i duplicate straight from the library?

E-Slayer
February 25th, 2005, 12:12 AM
Oh, I know that there's some way to pull clips from the library, but I'm not sure on the specifics or limitations.

Marz
February 25th, 2005, 01:11 AM
You can only use duplicateMovieClip the function if the clip is on the main timeline...

however... you can use the function attachMovie if it's in the library. ;)