Quick ActionScript Question for a Newbie

Greetings,

I have a movie clip I am moving from the left side of the stage to the right using AS, however I can’t seem to get the clip to scale larger or stop.

I was able to succesfully get the clip to move, so I am wonderging if anyone can help me stop the MC and gradually make the clip larger.

Here is the AS as it stands now -

onClipEvent (load) {
_x=24;
_y=111.7;
_xscale=_yscale=0;
_alpha = 10;
}
onClipEvent (enterFrame) {
_x=_x+3;
_xscale=_yscale=+100
_xscale=_yscale=+100;
_alpha = _alpha+2;
}
onClipEvent (data) {
stop();
}

All help is greatly appreciated.

Best,
CG

You can either do it this way:
onClipEvent (enterFrame) {
_x=_x+3;
_xscale=_xscale+100
_yscale=_yscale+100;
_alpha = _alpha+2;
}
or this way:
onClipEvent (enterFrame) {
_x=_x+3;
_xscale+=100;
_yscale+=100;
_alpha+=+2;
}

It’s two ways of writing code that does the same thing.

Thanks glkngs - I was able to get the movie clip to scale larger. Any ideas on how to stop the moving object at a given _x coordinate.

The script - _x=_x+3 moves my object, but it just keeps on going off the stage. How can I get it to stop somewhere?

Best,

ChaoticGood


onClipEvent (enterFrame) {
if (_x<240) {
_x += 2;
} else {
this.deleteOnEnterFrame;
}
}

that will move a clip across the stage until it’s x coordinate equals 240. when it does, it just deletes the actions in the onEnterFrame.

and, if you want to move the clip across the stage in a fluid motion (my preference), just incorporate the concept of easing:


onClipEvent (enterFrame) {
 limitX = 440;
 speed = 3;
 if (_x<limitX) {
  _x += (limitX-this._x)/speed;
 } else {
  this.deleteOnEnterFrame;
 }
}


Many thanks, maximum_flash. I was missing the conditionals on the script.

On a side note, I know this animation can be done with tweening, but I am curious about when tweening should be used and when ActionScript should be used…?

Best,
CG

me, i try and use actionScript for everything. then, there are motion tween people who would rather eat nails than script movement. i would say that the first option should be actionScript because it cuts down on file sizes and also gives you more options.

just my $.02

your welcome for the scripts.