Function problem

hi

why won’t my below script work?

the movie clip is called “blue”

and i want it to move useing a function in a function
is it posible in MX?

blue.onEnterFrame = function() {
movestop(this._x, 10, 500);

// movestop function

function movestop(thing, speed, dist) {
thing += speed;
}
};

if i go

blue.onEnterFrame = function() {
this._x+=10;
}

then it works

thanks

Andrew

try this:

blue.onEnterFrame = function() {
movestop(this._x, 10, 500);
};
// movestop function
function movestop(thing, speed, dist) {
thing += speed;
};

I simply put the movestop function outside the onEnterFrame function. see if that works.

<marquee width=22 behavior=alternate>:hat:</marquee>

Hi Manny

i tried what you said

but stiil it does not move

i uploaded the file

do you have any other ideas

thanks so much for the help

Andrew

Sorry, but I don’t have Flash here at work. What I can do though is give you advice. Instead of passing the function an object property, just pass the object itself, then modify its property within the function. like so:

blue.onEnterFrame = function() {
movestop(this, 10, 500);
};
// movestop function

function movestop(thing, speed, dist) {
thing._x += speed;
};

I’ve had problems in the past with passing objects as variables, especially pointers to other instances. And like said, I don’t have flash on me right now so I can’t test that code I just gave you.

<marquee width=21 behavior=alternate>:hat:</marquee>

blue.onEnterFrame = function() {
movestop(this._x, 10, 500);
};
// movestop function
function movestop(thing, speed, dist) {
thing += speed;
};

The problem with that script is that you trasmit the value of this._x to the function, not the property. So if for instance this._x = 5 you’ll in fact call

movestop(5,10,500);

and you’ll increment 5 by the speed, not this._x.

pom :slight_smile:

thanks

it works

you rule

Andrew