Skip to main content
Participant
June 22, 2006
Answered

parameter problem in functions

I have a problem: I want to create a function that add a movie clip instance on the scene.

function showItem(lx,ly,clip){
_root.attachMovie("doc1",clip,0);
clip._x = lx;
clip._y = ly;
}

the problem lies on the variable clip:
if the function is called, e.g. showItem(240,120,"clip"); then this won't work because the "clip" variable, which should be without the " " inside the function. How do you solve this small but annoying problem?
thanks for the help
This topic is closed to new replies. Start a new post to keep the conversation going.
kglad
kgladCorrect answer
Community Expert
June 22, 2006
you can only have, at most, one movieclip at each depth. so, change your depth:

3 replies

kglad
Community Expert
Community Expert
June 22, 2006
you're only passing what name you call the movieclip that's attached. you're not passing which movieclip to attach. do you really mean to pass the name of the linkage id to showItem?

if not, use _root[clip]._x etc.
Translate
Participant
June 22, 2006
Ok it works, but there's an other problem: I want to attach more instances of the same movie clip with the same function.
By doing:
showItem(200,200,"movieclip1");
showItem(100,100,"movieclip2");
only the last instance will appear, but not both. How do you do that?
thanks for the help
Translate
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
June 22, 2006
you can only have, at most, one movieclip at each depth. so, change your depth:

Translate