View Full Version : function problem
andrew1234
July 11th, 2003, 08:50 AM
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
thoriphes
July 11th, 2003, 09:03 AM
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>
andrew1234
July 11th, 2003, 09:10 AM
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
thoriphes
July 11th, 2003, 09:15 AM
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>
pom
July 11th, 2003, 09:25 AM
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 :)
andrew1234
July 11th, 2003, 09:26 AM
thanks
it works
you rule
Andrew
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.