Control MC with AS

I´m trying to find out the mysterium about action scripting!!
I’ve found a tut that tells u how to make objeckts move by using AS. Pretty easy! But what if I want to make it a little more advanced?

Lets say I have a line and I want it to scale to certain sice and I want the alpha to be 50, I can use this action:

onClipEvent(enterFrame) {
this._alpha=50;
if (this._xscale<250){
this._xscale+=50
}
}

But what if I want it to scale back or something, when it has executed the first code. How should I do that? I’ve tried to put in a similiar code after this one, but that doesn’t work. This is probably all very easy, and if someone could point me in the right direction would be great!

One more thing: when sould u use AS instead of tweens? what is the difference?

Thanks :slight_smile:

Use the code or php tag tsavo because I don’t know when the smily problem is going to be fixed. Also that code does nothing except set the alpha to 50 every time it enters a frame.

You could have done this in onClipEvent (load). And where you have

if (this._xscale<25) {
this._xscale += 50;

It won’t increase the xscale because it’s not less than 25 yet.

But it’s a good effort and the only way to learn. Did you come up with that yourself?

I found some beginner stuff at actionscrip.org

the number 25 should have been 250! **** smileys!!
My line increased until it reaced 250. That worked out okay, but if I want it to decrease afterwards, how should I do that? I tried to type in the code after the other one, but it seemed they worked against each other.

onClipEvent (load) {
	done = 0;
	this._alpha = 50;
}
onClipEvent (enterFrame) {
	if (this._xscale<250 && !done) {
		this._xscale += 50/2;
		if (this._xscale == 250) {
			done = 1;
		}
	}
	if (done) {
		this._xscale -= 50/2;
		if (this._xscale == 100) {
			done = 0;
		}
	}
}

Just makes it go bigger and smaller. Goes smaller when the variable done is true or 1. You can put this on a mouse event if you like.

allright! thx! I’ll try and play aorund with it!!:slight_smile:

Well Flex, read the article, because what I’m trying to explain there is that you don’t need that “done” variable anymore… :stuck_out_tongue:

What article?