Forum Topic: AS: Frame Functions

(3,026 views • 12 replies)

This topic is 1 page long.

<< < > >>
None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/2/05 10:39 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

OMFG! AS: Main!
Ok, in this tutorial, you will learn how how to use onClipEvent handlers but on frames instead of MC's! So, before we begin, it would be useful if you check out Inglor's AS: Clip Events becuase this will almost be the same thing but instead, you will learn how to use them on frames. I would also like to note that I checked out AS: Functions but I didnt really find anything in it that will relate to this.
---------------------------
What will I learn?
In this tutorial, you will learn how to use clipEvents but on frames. If you do this, you wont have to use a whole bunch of "varialbe holders" that are MC's. I did this a lot in the past.
Why not just use MC's?
Well, becuase what if you are making an API game? In API games, everything is done with AS so that means no "variable holders" allowed. Also, you wont have such a mess and it will be a lot easier for you.
---------------------------
Since, load and enterFrame functions are most commonly used, Ill explain those in detail. But first, Ill just explain frame functions in general. First, open up your frames action panel. Type in:

onEnterFrame=function(){

That is a frame function in its most simplist form. But you noticed it didnt do anything. Thats becuase you have to give it actions. So here is a function with actions:

onLoad=function(){
_root.gotoAndPlay(2);
}

Thats just a simple function that will play frame 2 of the root timeline. There are many more functions. You can use all the ones you see in clipEvents but always make sure you have function(){. So, thats pretty much it and now Ill explain load and enterFrame in detail.
---------------------------
enterFrame
Ok, enterFrame is a way of executing an objects actions every FPS. It is useful if you use movement for example and you want something to move forever. It is most commonly used and by far probably the most easiest.
load
Load is a way to execute an objects actions once the object is loaded and appears on the time line. Always use this for variables and things. It is unnecessary to look for a variable every FPS and is also less buggy. One of my favorite uses of it is to make a reset button for dress-ups.
READ HERE IF YOU WANNA MAKE A RESET BUTTON!
Ok, here is a basic way of making a reset button. Give a piece of clothing these actions:

onClipEvent(load){
oldx=_x;
oldy=_y;
_name="clothing";
}
on(press){
startDrag("");
}
on(release){
stopDrag();
}

Then, make a button and give it this code:

on(release){
_root.clothing._x=_root.clothing.oldx;
_root.clothing._y=_root.clothing.oldy;
}

I will not explain how that works since this tutorial isn't about that, lol.
---------------------------
Well, thats my tutorial! If I missed something (which I probably did) post here!

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

arctichigh

Reply To Post Reply & Quote

Posted at: 9/2/05 10:42 PM

arctichigh EVIL LEVEL 05

Sign-Up: 08/27/05

Posts: 357

already knew all this but this'll be helpful for n00bs. nice tut.


None

ParadoxSaint

Reply To Post Reply & Quote

Posted at: 9/2/05 10:42 PM

ParadoxSaint NEUTRAL LEVEL 29

Sign-Up: 02/05/05

Posts: 12,410

how did you learn this stuff man? 0_0 amazing


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/2/05 10:42 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 9/2/05 10:42 PM, The_ParadoX wrote: how did you learn this stuff man? 0_0 amazing

Practice...

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

T-H

Reply To Post Reply & Quote

Posted at: 9/4/05 04:17 AM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

Isn't this already in AS:Functions?


None

T-H

Reply To Post Reply & Quote

Posted at: 9/4/05 04:21 AM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

Well its covered in both Functions and Clip Events. But I guess its nice to have it organised in one place.

I like coding this way, the last 2 things I have done I have coded everything from the frame instead of coding on each seperate mc/textfields. Keeps things really organised.


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/4/05 02:01 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 9/4/05 04:17 AM, T-H wrote: Isn't this already in AS:Functions?

I checked it and I didnt find anything about this. :-P

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

T-H

Reply To Post Reply & Quote

Posted at: 9/4/05 02:08 PM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

At 9/4/05 02:01 PM, SpamBurger wrote:
At 9/4/05 04:17 AM, T-H wrote: Isn't this already in AS:Functions?
I checked it and I didnt find anything about this. :-P

Denvish in Clip Events:

"You can add this to your main timeline, first frame, instead:

PIE.onEnterFrame= function(){
//do stuff;
}"

Inglor in Functions

" container such as _root or a movieclip (in it's frame actions more usefully) has handlers like onPress onEnterFrame and onLoad that trigger when they should thanks to flash's complex triggering system.........................et.c etc."


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/4/05 02:11 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

0_0 I didnt see that. Well, this tutorial did explain them very well though atleast.

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

Kipling

Reply To Post Reply & Quote

Posted at: 9/4/05 04:47 PM

Kipling NEUTRAL LEVEL 13

Sign-Up: 05/04/04

Posts: 2,641

At 9/4/05 02:11 PM, SpamBurger wrote: 0_0 I didnt see that. Well, this tutorial did explain them very well though atleast.

Spamburger= Best underage user ever.


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/4/05 05:29 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 9/4/05 04:47 PM, kipling wrote: Spamburger= Best underage user ever.

Thanks. Your a pretty good animator yourself.

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


None

Kipling

Reply To Post Reply & Quote

Posted at: 9/4/05 05:30 PM

Kipling NEUTRAL LEVEL 13

Sign-Up: 05/04/04

Posts: 2,641

At 9/4/05 05:29 PM, SpamBurger wrote:
At 9/4/05 04:47 PM, kipling wrote: Spamburger= Best underage user ever.
Thanks. Your a pretty good animator yourself.

Thanks. I want to spend most of my energy on learning Actionscript now.


None

SpamBurger

Reply To Post Reply & Quote

Posted at: 9/4/05 05:38 PM

SpamBurger NEUTRAL LEVEL 15

Sign-Up: 07/12/05

Posts: 4,747

At 9/4/05 05:30 PM, kipling wrote:
At 9/4/05 05:29 PM, SpamBurger wrote:
At 9/4/05 04:47 PM, kipling wrote: Spamburger= Best underage user ever.
Thanks. Your a pretty good animator yourself.
Thanks. I want to spend most of my energy on learning Actionscript now.

Thats a good choice. I thought I could animate but before I knew about NG's, I submitted a stick movie to some weird site and it got decllined. So, I chose programming.

"However, the game received only two orders, one of which Molyneux speculated was from his mother." -Peter Molyneux's first game The Entrepreneur


All times are Eastern Standard Time (GMT -5) | Current Time: 08:38 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!