Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
joe dc #1
math.random.whats wrong with my code?!!
Why is it doing this??
What I want is for my mc to slide to a new random x position when it is less
than 5 pixels away from its target, it keeps doing this. the problem is for
some bloody &*?$(()** reason my random numbers only keep going up!! why is
this?? i want to produce random numbers between 1 and 770 - this is my code..
Please somebody help me please..
onClipEvent (enterFrame) {
_root.xdif = _root.targetx-this._x;
if (_root.xdif<5) {
_root.targetx = Math.floor(Math.random()*(770))+1;
}
if (_root.xdif<5) {
this._x = null;
} else {
this._x += (_root.xdif/50);
}
}
joe dc Guest
-
Using Math.random to go to random frames
Hello everyone. My cerebral density is preventing me from seeing the solution to this problem. I have the following code which causes the user to... -
Math::GMP tests and Crypt::Random fail on Compaq (Math::Pari related ??)
Hi, I've been compiling Math::GMP for different OS's in order to use Net::SFTP and I have successfully compiled and used it for Solaris,... -
whats wrong with my fullscreen code?
on(press) { if ("fullscreen" == true ) { fscommand("fullscreen", "false"); } else { fscommand("fullscreen", "true"); }} -
[PHP] Whats wrong with my code?
Stevie D Peele wrote: Yeah. You need a ; at the end of the line before that. Like: include ($include); -
Whats wrong with this code?
Ray, This is the wrong syntax for the CASE expression. There are two valid kinds of CASE expression: CASE <expression> WHEN <value 1> THEN... -
stwingy #2
Re: math.random.whats wrong with my code?!!
Because you have put "if (_root.xdif<5)", this will always be the case for
negative numbers ie/when targetX is less than _x.
try something like this
onClipEvent (enterFrame) {
_root.xdif = _root.targetx-this._x;
this._x += (_root.xdif/50);
if (Math.abs(_root.xdif)<5) {
this._x = _root.targetX;
_root.targetx = Math.floor(Math.random()*(770))+1;
}
}
stwingy Guest



Reply With Quote

