Skip to main content
Participant
June 22, 2006
Answered

parameter problem in functions

  • June 22, 2006
  • 1 reply
  • 250 views
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 has been closed for replies.
Correct answer kglad
you can only have, at most, one movieclip at each depth. so, change your depth:

1 reply

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.
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
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: