Comic Talk, Tips and Tricks

What is your favourite ActionScript?
Will at 6:57AM, June 25, 2007
(online)
posts: 383
joined: 2-10-2007
Now this may be a little bit of an obscure topic, as AS is one of the lesser known programming languages. However, i think every aspect of flash is useful in webcomicking. our dd games were all made with ActionScript.

So, for you people with flash and a vague understanding of the script we all know and love: what is your favourite thing you can do with it?

Mine would have to be the elasticity script (ill explian it thoroughly so anyone can give it a go)

open flash
create a circle
select the circle, press f8
click the button that says “movie clip”
name it “ball”

Now, select the new movie clip (MC) and go to the “actions bar”, it should be down the bottom of the flash workspace, click on it.
put in the following code:

—————————

onClipEvent(load){
vx=1;
ax=.1;
vy=1;
ay=.1;
//these are the variables which are needed as the base for all of the code. in
//my experience, messing with them doesnt really change much, so i'd just copy em :P

//the code in the conclipevent load are variables, these are numbers which
//remain constant throughout the game
}
onClipEvent(enterFrame){
vx+=ax;
vy+=ay;
_x+=vx;
_y+=vy;
// the script in the onclipevent enterframe contains numbers that change
//for every consecutive frame the script is present.
//simply, these numbers increase and decrease in relation to time and
//what you happen to be doing
}
onClipEvent(load){
k=.03;//this is the speed variable, the higher it is, the faster the MC
//will be elastic… if that makes any sense… meh, try it out :P
damp=.9; //this is the inertia variable; the higher it is, the
//bouncier and more elastic the script will be. .1 is not very
//elastic at all, .9 is jumping around all over the place!
//keep in mind though, if the value is one or higher, the MC will simply drift off

}
onClipEvent(enterFrame){
ax=(_root._xmouse -_x)*k;
ay=(_root._ymouse -_y)*k;
vx+=ax;
vy+=ay;
vx*=damp;
vy*=damp;
_x+=vx;
_y+=vy;
//just code, try to understand it if you are learning Actionscript
//theres no shame in copypasting some script but at least try to understand
//what it is :D
//i would explain it, but it's late. if you have some specific questions PQ meh :P
}

—————————-

Don't forget to put your framerate up to about 24 and center the shape in the movieclip!
there, now if i'm not a totally incompitant teacher, you should now have your very own little ball on a rubber band to control with your mouse. i plan to make a game revolving around this script… eventually…

So, does anyone on the good ol' DD have a favourite command? i hope at least volte responds :P
Will
putting your own quote into your sig is the post pretentious and pathetic thing anyone could ever do.
last edited on July 14, 2011 4:49PM

Forgot Password
©2011 WOWIO, Inc. All Rights Reserved