Actionscript Academy Session 1
Friday 25, AIM (aim:goim?screenname=theforeverkul&message=I+am+here+for+Actionscript+Academy) , or specify something else.
Today we will be working on mouse movement games such as fancy cursors and mouse avoider games. If you don't know anything about AS at all, skim this.
(http://www.clockcrew.cc/talk/showthread.php?t=46360)
I WILL BE CONSTANTLY UPDATING THIS POST, IM ME IF YOU NEED HELP!
You can post finished projects here.
First Step is simple, just to make it follow the mouse.
[flash]http://img182.imageshack.us/img182/97/session1azk0.swf width=200 height=200[/flash]
This black dot simply follows the mouse.
1. Draw something
2. Turn it into a movie clip, name does not matter.
3. Give it the Instance Name follow
4. Open the Actions panel and click on the frame (http://www.clockcrew.cc/talk/showthread.php?t=46360)
5. Make sure it says Frame on the panel title.onEnterFrame = function () {
follow._x = _xmouse;
follow._y = _ymouse;
};
Step 2: Lets make some walls!
[flash]http://img186.imageshack.us/img186/4686/session1bph8.swf width=200 height=200[/flash]
This black dot follows the mouse, but if you move over the red, it will appear back at the start. You can mouse over the dot to make it follow the mouse again.
1. Draw walls and make it into a SINGLE move clip, name doesn't matter.
2. Give it the Instance Name wall
3. Add the new codes [B]following = false;[/B]
onEnterFrame = function () {
[B]if (following == true) {[/B]
follow._x = _xmouse;
follow._y = _ymouse;
[B]}
if (following == false) {
follow._x = 100;
follow._y = 100;
}
if (wall.hitTest(_xmouse, _ymouse, true)) {
following = false;
} else if (follow.hitTest(_xmouse, _ymouse, true)) {
following = true;
}[/B]
};
Step 3: UR A WINNAR
[flash]http://img186.imageshack.us/img186/9599/session1cib9.swf width=200 height=200[/flash]
This counts how many times you lost and if you hit the blue circle you win!
1. Type "Tries" or something with regular STATIC TEXT in the top corner
2. Create a DYNAMIC TEXT BOX (located in the properties panel, its in a drag down box that might says Static)
3. Look in the bottom right corner of the properties panel, you'll see a box with the word Var: next to it, type par in that box
4. Make a blue circle and turn it into an MC, give it the Instance Name win
5. now make a new frame (frame 2) and make a win picture or something, turn it into a movie clip.
6. Go inside the movie clip and add about 30 to 60 frames, the last frame should be a keyframe
7. In that last keyframe, type _root.gotoAndStop(1);
8. Now head back to the first frame on the main time line to add this code: [B]stop();
par = 0;[/B]
following = false;
onEnterFrame = function () {
if (following == true) {
follow._x = _xmouse;
follow._y = _ymouse;
}
if (following == false) {
follow._x = 100;
follow._y = 100;
}
if (wall.hitTest(_xmouse, _ymouse, true)[B] && following == true[/B]) {
following = false;
[B]par++;[/B]
} else if (follow.hitTest(_xmouse, _ymouse, true)) {
following = true;
}
[B]if (win.hitTest(_xmouse, _ymouse, true) && following == true) {
nextFrame();
}[/B]
};
Quote who're you?
Vibrator
never heard of you
yes
:O
Oh well =\
but you've probably heard of me
i'm the leader/god of the clock crew
I thought that was Strawberry o_O
lmaao
Hmm... perhaps I've been horribly misguided!
obviously
I have, seen you 'round, Coal. Not really 'heard' though.
strawberry died a couple of years ago :\
I like your siggy -^_^-
f'real
No he didn't!
yes he did!!
Shark Farming accident
it was all over the bloody news!
Well..
shark farming
maybe "SBC" did, but certainly not the person!
no, the person
SBC lives on in our flashes only as a mascot
I thought he would've died to the mass of CC members retaling due to his, trying to forget the CC for that new flash place he's working with on, I believe, adult swim?
Pisha!
ill never look at shark farmers the same way again =(
that's just our cover up, the whole sbc story
we like to fool around with Newgrounders
*jaw drops* Flux Capacitor!
Why is there a "2" next to my name? o_O
you fucking clockfriend
Rawr.
-^_^-
meow =^.~=
mew? o.o
o_o;
o3o
AW!
Oh
I see why.
haha.
I feel stupid.
heh ^^;
I had another tabe open with the chat and I reopened another one, and since the name"Vibrator" was already being used, they stuck a 2 next to my name
HEY GUYS
*sets lighter fluid and flame to coal*
HEY ROMAN
Don't tell me I'm disloyal!
JUST GO TO THE TOPIC AND TALK THERE
JAVA CHAT IS SLOWING MY COMPUTER
*** Vibrator2 has quit (QUIT: User exited)
*** Vibrator2 has joined #clockcrew
vibrator do you wanna get the fuck banned
Not particularly.
don't talk to me like that ever again
i'm the almighty lord of the clock crew
You're the ony who was all "You're disloyal"
PFFFT!
Good Bye!
AW :(
i'll see you hung from the gallows
with that attitude
*** RomanClock has quit (QUIT: User exited)
Yay!
Hempman rope come aide me to the light!
i must take my leave
but take heed clockfriend
know who your superiors are...
bitch
Coal instructed me to post this he threatened harm would befall my dicks if I didn't
:3
I really want to be here for this, but my IP has been blacklisted. Will someone with chat powers please fix this glitch?
Done
[flash]http://i3.photobucket.com/albums/y84/genex89/x.swf[/flash]
Quote from: Trek Clock;829362Done
[flash]http://i3.photobucket.com/albums/y84/genex89/x.swf[flash]
Try a higher frame rate to make it smoother :)
I usually use 30 FPS
AS works better at higher frame rates without any extra effort for you. I suggest 30 because its good all around.
following = true;
onEnterFrame = function () {
if (following == true) {
follow._x = _xmouse;
follow._y = _ymouse;
}
if (following == false) {
follow._x = 100;
follow._y = 100;
}
if (wall.hitTest(_xmouse, _ymouse, true)) {
following = false;
} else if (follow.hitTest(_xmouse, _ymouse, true)) {
following = true;
}
};
[flash]http://i159.photobucket.com/albums/t152/XXXPaddyBoiiXXX/dick.swf width=200 height=200[/flash]
Seems to work okay with 120fps ;)
[flash]http://i3.photobucket.com/albums/y84/genex89/x-1.swf[/flash]
Got the walls working
postin dis for coal
http://img218.imageshack.us/my.php?image=bummz5.swf
[flash]http://denvish.net/ulf/250507/74134_ASA1.swf width=200 height=200[/flash]
I tried adding easing to the mouse's movement, and it's working out well.
[flash]http://img138.imageshack.us/img138/1048/mousegamelm2.swf width=400 height=200 wmode=transparent[/flash]
following = false;
Mouse.show();
onEnterFrame = function () {
if (following == true) {
xMove=(_xmouse-follow._x)/5
yMove=(_ymouse-follow._y)/5
follow._x+=xMove
follow._y+=yMove
Mouse.hide()
}
if (following == false) {
follow._x = 70;
follow._y = 66;
Mouse.show();
}
if (wall.hitTest(_xmouse, _ymouse, true)) {
following = false;
} else if (follow.hitTest(_xmouse, _ymouse, true)) {
following = true;
}
};
[FLASH]http://www.blackmagic.cc/lol.swf width=600 height=400[/FLASH]
Quote from: SockPuppetClock;829407I tried adding easing to the mouse's movement, and it's working out well.
[flash]http://img138.imageshack.us/img138/1048/mousegamelm2.swf width=400 height=200 wmode=transparent[/flash]
following = false;
Mouse.show();
onEnterFrame = function () {
if (following == true) {
xMove=(_xmouse-follow._x)/5
yMove=(_ymouse-follow._y)/5
follow._x+=xMove
follow._y+=yMove
Mouse.hide()
}
if (following == false) {
follow._x = 70;
follow._y = 66;
Mouse.show();
}
if (wall.hitTest(_xmouse, _ymouse, true)) {
following = false;
} else if (follow.hitTest(_xmouse, _ymouse, true)) {
following = true;
}
};
Where did you put the easing?
Also, i tried editing some stuff and i think i've gotten basic knowledge of this shit.
Quote from: SockPuppetClock;829407I tried adding easing to the mouse's movement, and it's working out well.
[flash]http://img138.imageshack.us/img138/1048/mousegamelm2.swf [flash]
Lol, show off :) Were not doing that yet
Quote from: Tyler Durden;829425Where did you put the easing?
Also, i tried editing some stuff and i think i've gotten basic knowledge of this shit.
following = false;
Mouse.show();
onEnterFrame = function () {
if (following == true) {
[B]xMove=(_xmouse-follow._x)/5
yMove=(_ymouse-follow._y)/5
follow._x+=xMove
follow._y+=yMove[/B]
Mouse.hide()
}
if (following == false) {
follow._x = 70;
follow._y = 66;
Mouse.show();
}
if (wall.hitTest(_xmouse, _ymouse, true)) {
following = false;
} else if (follow.hitTest(_xmouse, _ymouse, true)) {
following = true;
}
};Quote from: RomanClock;829426Lol, show off :)
:o
Quote from: SockPuppetClock;829427:o
Don't make me use my laser codes
[FLASH]http://img527.imageshack.us/img527/9593/actionscriptpracticescear4.swf width=650 height=400[/FLASH]
[FLASH]http://img245.imageshack.us/img245/8481/asacademyprogress1ev8.swf width=550 height=400[/FLASH]
Wow, this actually seems to be going pretty well so far. Too bad I'm too busy with stupid reports at work, or I might have joined in on the fun.
EDIT: FIXED
[flash]http://denvish.net/ulf/250507/76275_ASA1.swf width=200 height=220[/flash]
I made a slight edit to the code:
I changed the first following = true to following = false
Quote from: FBerry;829443somthings wrong with my script. wen my mouse hits the green it adds one. not wen the "follow" hits it.
[flash]http://denvish.net/ulf/250507/75535_ASA1.swf[flash]
You have an earlier version of my code, redo the codes.
EDIT: <3 Flux and SockPuppet
[flash]http://img83.imageshack.us/img83/3121/cursorthingag3.swf width=550 height=400[/flash]
[FLASH]http://img300.imageshack.us/img300/4752/asacademyprogress2nv4.swf width=550 height=400[/FLASH]
Just playin around.
Quote from: Dilbert;829473I need help with the name instance thing I think.
When you click on the movie-clip, in the properties there is a text-box under the slide-down menu of what it is, which is where the instance name is supposed to be.

Did you name the mouse follow?
http://img222.imageshack.us/my.php?image=gamemb0.swf
Quote from: SockPuppetClock;829494When you click on the movie-clip, in the properties there is a text-box under the slide-down menu of what it is, which is where the instance name is supposed to be.

Did you name the mouse follow?
Ah I see. thx
Hey wait, this AS works in MX 2004 right?
Quote from: AnkhClock;829507Hey wait, this AS works in MX 2004 right?
Yeah, it should.
Quote from: FluxCapacitorClock;829509Yeah, it should.
Then I don't know what I'm doing wrong.
Quote**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on/onClipEvent handler
onEnterFrame = function () {
Total ActionScript Errors: 1 Reported Errors: 1
Quote from: AnkhClock;829507Hey wait, this AS works in MX 2004 right?
Yeh, AS 2.0 was made in an even earlier version.
Quote from: AnkhClock;829514Then I don't know what I'm doing wrong.
You're putting it on the movieclip lol.
Put it on the frame.
Question: I sthere a way to make the default arrow cursor invisible on the Flash?
Quote from: Dilbert;829524Question: I sthere a way to make the default arrow cursor invisible on the Flash?
Using Alpha, no?
Quote from: SockPuppetClock;829518You're putting it on the movieclip lol.
Put it on the frame.
gottdam fffffffffff
[FLASH]
http://img223.imageshack.us/img223/1143/astryug9.swf width=250 height=250[/FLASH]
Quote from: HOUSEMASTER;829530Using Alpha, no?
... I mean the white computer arrow cursor.
Quote from: Dilbert;829546... I mean the white computer arrow cursor.
Oh yeah, theres a code. Mouse.hide()
[FLASH]http://denvish.net/ulf/250507/80103_ASA1.swf width=200 height=220[/FLASH]
Quote from: HOUSEMASTER;829555Oh yeah, theres a code. Mouse.hide()
Woot <3
heh, sock
You know what. I think each session should have a main game type we focus on, then when all the kinks are worked out, I could compile them and submit it to NG as Actionscript Academy Session X. I think it would make a cool series, a bunch of different people making mini games compiled into one flash :D
Quote from: RomanClock;829570heh, sock
You know what. I think each session should have a main game type we focus on, then when all the kinks are worked out, I could compile them and submit it to NG as Actionscript Academy Session X. I think it would make a cool series, a bunch of different people making mini games compiled into one flash :D
Fucking brilliant idea.
:)
[FLASH]http://img186.imageshack.us/img186/8639/gameot7.swf width=550 height=400[/FLASH]
You should give us a code for baddies that walk randomly too.
Quote from: Dilbert;830166You should give us a code for baddies that walk randomly too.
You can just add animations inside the wall movieclip to have things move.
Quote from: RomanClock;830214You can just add animations inside the wall movieclip to have things move.
Uhhh sounds fair enough...
[FLASH]http://i5.photobucket.com/albums/y157/forkhead44/Untitled-1.swf width=550 height=620[/FLASH]
Hey, I kinda learned something worthwhile.
[FLASH]http://img100.imageshack.us/img100/8610/gamedo3.swf width=550 height=400[/FLASH]
Now with baddies and a more accurate goal. Wow it feels really cool :)
What is the code for leveling trough different levels?
Quote from: Dilbert;830396[FLASH]http://img100.imageshack.us/img100/8610/gamedo3.swf[FLASH]
Now with baddies and a more accurate goal. Wow it feels really cool :)
What is the code for leveling trough different levels?
In the win screen (yours says Success) instead of ending with _root.gotoAndStop(1); use _root.nextFrame(); this will mean you can have an animation then another level.
You can make new movieclips or keep the same ones, you just need to have the same instance name. As for codes, all you need to add is following = false; on that frame with the new level. You can repeat this as many times as you want. The cool thing about AS is that you can have different movie clips but the only thing that matters is the instance name.
Also, AA doesn't have to be JUST on Friday! I hope people who did not participate in the initial session should still follow the steps on the first post and post any questions they have! This way we could have more people participating.
These are cool!
Quote from: David Spade;830348[flattp://i5.photobucket.com/albums/y157/forkhead44/Untitled-1.swf width=550 height=620[/flash]
Hey, I kinda learned something worthwhile.
rofl
Quote from: LeekClock;831218These are cool!
Make something! :)
This is excellent. I'm in the mood for making something with a bee.
Fucking awesome. I'ma get in on this.
You guys know if there exists a font that looks like digital clocks?
Quote from: TequilaClock;833693You guys know if there exists a font that looks like digital clocks?
It does exist.
Quote from: RomanClock;833891It does exist.
Ok, is there a link you asure me I will find it there that isn't a web search?
I tried this on the newest flash with as3 and it doesnt work, but it works with 2.0, just filling you in if you didnt know.
Quote from: Pepper Clock;845881I tried this on the newest flash with as3 and it doesnt work, but it works with 2.0, just filling you in if you didnt know.
Yea, Ive already said we are using AS2 here are some reasons:
I don't know AS3
I don't have CS3 so I can't learn it well
AS2 is MUCH EASIER to learn wen you're a beginner
AS2 will still probably be the major Flash language for a while
ALSO IMPORTANT!! SEND FLA'S!!!
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
i love to suck cock
Step 2 dosen't work for me,i did put the Circle(Step 1 work) and the Walls in 2 different layers at the same frame,but when i try it,the walls do nothing(i don't get any error),i have tryed 3 times and it give me the same thing each time.
Could anyone help me with this?Else,i am gonna go to the next tutorial hoping it work :(
(https://clockcrew.net/talk/proxy.php?request=http%3A%2F%2Fimg253.imageshack.us%2Fimg253%2F1115%2Floljpegqb0.jpg&hash=0e59698499711a4f4b9c738f6962a0a56dba8f26)
See how there is an "a" on both frames? Each of the codes I give you is the whole thing that should be on only 1 frame.
[flash]http://www.swfup.com/uploads/swf-83345.swf (http://www.swfup.com/uploads/swf-83345.swf%22) width=420 height=200[/flash]
[flash]http://www.swfup.com/uploads/swf-83355.swf[/flash] (http://www.swfup.com/uploads/swf-83355.swf%22)
Wow it feels good to have my first thing up on the web.
Quote from: Δ;1136238i dont get why you bumped this
This was supposed to be moved to the academy section of the forum
I have a question. The object goes back to the desired position when the '+' (center) of the object hits the wall. How do I make it so that the object goes back to the desired position when the edges of the object hit the wall?
Yes, huge bump.
Great job just go ahead and bump a 6 month or so old thread
You could have PMed him