AS'd movement, and repeat

Okay, here’s the deal…

I worked on Kirupa’s tut on how to make the action scripted movement, and it working well, until I wanted it to reappear and repeat…

I’m working on a Stick Shooting game (the basic first draft can be seen at http://www.stickslaughter.com/stickshooter.html) and have been attempting to make a stick, walk from one side of the stage to the other, and repeat. I can do that easily, but then i run into a problem…

When you shoot the stick, it goes into an animation where it dies and fades to 0 alpha. So when the stick reappears, he’s invisible, therefore making it pointless for him to repeat. Here’s the script I have on the stick right now:


onClipEvent (enterFrame) {
	speed = 5;
	this._x += speed;
	if (this._x>=500) {
		this._x = 20;
		tellTarget (_root.target) {
		gotoAndPlay(1)
	}
}
}

So he moves until 500 on the stage, then repeats, and the tellTarget attempts to make the stick (instance name: target) go back to frame 1, where’s he walking visibly.

Any suggestions?
Thanks in advance…
KoRRupt

tellTarget is deprecated. And why are you targeting _root.target? Isn’t your animation in the same clip that the actions are on? If that is so, shouldn’t it be

onClipEvent (enterFrame) {
	speed = 5;
	this._x += speed;
	if (this._x>=500) {
		this._x = 20;
		this.gotoAndPlay(1);
	}
}

(this.gotoAndPlay or _root.yourClip.gotoAndPlay(), etc are replacements for the deprecated tellTarget)

Thanks man…

Also, thanks for getting me up to date, been living in the past with telltarget for too long, everything works now!

Thanks again,
KoRRupt

No problem man. I learned with MX so I never knew tellTargeting (for the first week or so of AS learning that is) so when I saw it on the forum I was like… Huh? What is that?!..lol.

Funny how things work :slight_smile:

Glad you got everything working now :beam: