attachMovie .... specify properties not working properly


onEnterFrame = function () {
attachMovie ("ball", "ball", 1,[_x=_xmouse, _y=_ymouse]);
}

I’ve been having problems with a more complex version of this but just for testing I simplified it and I’m still having the same problem.

the symbol that is attached (ball) jumps between + and - 10 of whatever the value of _xmouse and _ymouse are. so basically it moves back and forth diagonally.

does anyone know why?

just copy and paste this code onto a frame and have a symbol exported for actionscript with the name “ball”

any help is appreciated

thanks

you need to pass an object, not an array :wink:

if you are doing it all in one line, directly within the attachMovie call, then you use colons ( : ) as the equals ( = ) ie:


onEnterFrame = function () {
       attachMovie ("ball", "ball", 1, {_x:_xmouse, _y:_ymouse});
}

wow … why do you do that?

that seems confusing

thanks =)

another question … since i have the attachMovie command inside the onenterframe function … does the movie get attached and deleted every frame. what’s the most efficient way to write that code … especially if i’m going to use a ‘for’ loop to make multiple instances of “ball”

yes it does attach and replace itself every frame

the best way to do it is have it in a function and run that function only once when you need it to be. This most likely wouldnt be in the enterFrame event, more likely in onClipEvent(load) or maybe some mouseDown or called from another action (button?) completely