Moving mc's randomly

actually it works schling :slight_smile:
i was like what the … !!? it should work! and tested it :wink:

by the way … i’ll fix my script later and i’m not stressed out about it :wink:

thanks kax

originally posted by david
thanks kax

ehmm … yeah. i don’t know why but you’re welcome =)

Well, I won’t even start to guess why it wouldn’t work on my script. Since most of the codes are the same on both. Exept that you don’t have any code on the mc, just an instance name.

But! Yours work, and I can use it. Just wish I could really understand why mine didn’t work. Guess I must take a good look at it.

Thanks Kax, and to all others that have tried to help me :slight_smile: I’ll post url for my page as soon as it’s done.

“I don’t know why but your’e welcome.”

because you saved me the trouble of thinking about the code of course. :slight_smile:

Exept that you don’t have any code on the mc, just an instance name.

at the end of the code

mc.onEnterFrame = move;

it’s the same than

onClipEvent (enterFrame) {
	this.move();
}

But! Yours work, and I can use it. Just wish I could really understand why mine didn’t work. Guess I must take a good look at it.

can you post the exact code you used? i might find what’s wrong with it :wink:

and again … no problem schling =)

because you saved me the trouble of thinking about the code of course :slight_smile:

oh i see … =)

i should get paid for this :stuck_out_tongue: [size=1]jk ;)[/size]

Here it is.

This is my modified code, with your input.
Don’t know why it won’t work, perhaps it even will at your computer.

mine …

MovieClip.prototype.move = function() {
	if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
		this.x += this.diffx;
		this.y += this.diffy;
		this._rotation = Math.atan2(this.diffy, this.diffx)*180/Math.PI;
	} else {
		this.x = this.targx;
		this.y = this.targy;
		if (!this.t) {
			this.t = getTimer();
		}
		if (getTimer()-this.t>1000) {
			this.reset();
			this.t = 0;
		}
	}
	this._x = this.x;
	this._y = this.y;
};

yours …

MovieClip.prototype.move = function() {
	if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
		this.x += this.diffx;
		this.y += this.diffy;
		this._rotation = Math.atan2(this.diffy, this.diffx)*180/Math.PI;
	} else {
		this.x = this.targx;
		this.y = this.targy;
		if (!this.t) {
			this.t = getTimer();
		}
		if (getTimer()-this.t>1000) {
			this.reset();
			this.t = 0;
		}
	}
	**this._rotation = Math.atan2(this.x, this.y)*360/Math.PI;**
	this._x = this.x;
	this._y = this.y;
};

Ops :slight_smile:

what the hell does that line there?
So, THAT is why mine didn’t work.

You see I had the same line you used before, just at the wrong place. That is what I find really annoying. But now my script is all messy…

you can have the line there if you want to … it shouldn’t be a problem :slight_smile:
just remove the other line :wink:

by the way … i just realize that your line is wrong :-\

this._rotation = Math.atan2(this.x, this.y)***360**/Math.PI;

shoul be 180 not 360 …

but i can fix that :wink:

this._rotation = Math.atan2(this.diffy, this.diffx)*360/(Math.PI*2);

=)

Yup, used 180 myself at first, but when it didn’t work I tried to use 360. Since I thought that it would go 360 degrees, while 180 it would only go half the way in the circel.

But as I said, my old script was filled with mess. Guess I scripted it do death :-\

But as I said, my old script was filled with mess. Guess I scripted it do death :-\

:stuck_out_tongue: … don’t worry, it happens to everyone :wink: