PDA

View Full Version : Actionscripted Movement



JCampos021
July 15th, 2005, 09:58 PM
Ok, so i can get my box to move up, but now i want the box to expand its sides to cover the whole screen. I cant figure out the rest of the action script for it.. If someone could point me in the right direction. Thanks for the help

nathan99
July 15th, 2005, 10:03 PM
Make sure ur mc is centered, like the objects that make it;
here an eg code;


onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
//if RIGHT is down
this._xscale+=5;
//scale X up
this._yscale+=5;
//scale Y up
}else if(Key.isDown(Key.LEFT)){
//Other wise is LEFT is pressed
this._xscale-=5;
//scale X down
this._yscale-=5;
//scale Y down
}
}

JCampos021
July 15th, 2005, 10:07 PM
Thank you for your help, one more question about it, If i dont want to use buttons to make it bigger but let it go on its own how would i get that done, then make it stop at a certain spot... Thanks again for your help

nathan99
July 15th, 2005, 10:11 PM
just without the key presses, to make it stop it would be easiest to make a scale speed variable;

First set it onLoad so;


onClipEvent(load){
scalespeed = 5;
//the variable scale speed gets set to what ever amount you want, in this case 5
}


Now the scale Code;


onClipEvent(enterFrame){
this._xscale+=5;
//scale X up
this._yscale+=5;
//scale Y up
if(this._xscale>=90){
//if the X scale is greater than or equal to 90
scalespeed = 0;
//scalespeed is set to 0, to it wont grow anymore
}
}


So the whole code will be


onClipEvent(load){
scalespeed = 5;
//the variable scale speed gets set to what ever amount you want, in this case 5
}
onClipEvent(enterFrame){
this._xscale+=5;
//scale X up
this._yscale+=5;
//scale Y up
if(this._xscale>=90){
//if the X scale is greater than or equal to 90
scalespeed = 0;
//scalespeed is set to 0, to it wont grow anymore
}
}

JCampos021
July 16th, 2005, 12:01 AM
ok, so i placed that in my mc that i wanted to scale, and its working, except it wont stop for some reason now... But everything else is working.. Thanks again for you help

nathan99
July 16th, 2005, 12:22 AM
what have you got for this bit?


if(this._xscale>=90){
//if the X scale is greater than or equal to 90
scalespeed = 0;
//scalespeed is set to 0, to it wont grow anymore
}

JCampos021
July 16th, 2005, 12:26 AM
if(this._yscale>=10){
//if the X scale is greater than or equal to 90
scalespeed = 0;
//scalespeed is set to 0, to it wont grow anymore


I used this the first time, then i bumped it down to 50.

Does it matter what the size of the object is? cause its 16 x 5

nathan99
July 16th, 2005, 12:30 AM
no, mmm


if(this._yscale>10){
//if the X scale is greater than or equal to 90
scalespeed = 0;
//scalespeed is set to 0, to it wont grow anymore


strange ey? try that

JCampos021
July 16th, 2005, 12:42 AM
Yeah it is really strange... i hope im doing this right, here is the .fla that i made for this, maybe this might make it easier.. Thanks again

nathan99
July 16th, 2005, 12:52 AM
i see no fla

JCampos021
July 16th, 2005, 12:53 AM
Jeeze, ive lost it today... its to damn hot here.... Anyway, here ya go

nathan99
July 16th, 2005, 12:58 AM
lol im embarassed


onClipEvent(load){
scalespeed = 5;
//the variable scale speed gets set to what ever amount you want, in this case 5
}
onClipEvent(enterFrame){
this._xscale+=scalespeed;
//i forgot to change this
//scale X up
this._yscale+=scalespeed;
//i forgot to change this
//scale Y up
if(this._xscale>500){
//if the X scale is greater than or equal to 90
scalespeed = 0;
//scalespeed is set to 0, to it wont grow anymore
}
}

JCampos021
July 16th, 2005, 01:07 AM
heh, thanx man, it works perfectly now