Flashing Again

As the flashplayer is moving into 10.1 number,I think Flash player 10 itself has a lot to give me as a developer.

What I found recently is there are some amazing magic methods and tools in AS3,FlashPlayer10 and in flashCS4 IDE.
I have attached a FLA having the source code on the first frame to keep things simple 🙂

1. The inverse Kinematics (IK) :
This is Flash IDE and I am amazed with the Bones tool and the IK of it.The thing is one can use the IK at

authortime and if required one can make all the IK interactions runtime with just a user selection. Once all the

bones are drawn,select the “Armature” layer which “Bones” tool creates by default.Now you can see an option in the

properties pannel to make the IK “runtime” or “authortime” and VOILA!!Thats short,sweet and simple.Yay.

Next we will jump into some actionscript.

2. EXIT_FRAME

We all flash developers are born with “enterframe” events with us. Anything,anytime not working,simply write an

enterframe event-handler and throw some debugging code there. Well,for developers from Macromedia Director or

Lingo scripting world coming to Flash almost always miss their weapon,” to know when” the framehead leaves the

current frame. The good news is now we have an event named “EXIT_FRAME” and this works the same way as

“ENTER_FRAME”.So there we go,if we want to controll the frame exactly the way we want,there are two events we can

check for and do the desired stuff in-between.
The attached FLA has got the “trace” statements for the enterframe and exitframe events just to make the test.

3. addFrameScript()

Next is the un-documented method of a movieclip.I think this one we all flash developers were looking for a

long time. What it does is, add a script to a frame in the movieclip and rightly called “addFrameScript()”. The

example FLA has got the authortime IK animation controlled,by pushing in actionscript into the frame of the

movieclip. The code looks like
this.barClip.addFrameScript(10,myFunc);

4. describeType

I am quite excited to share these. For me these are real new and useful stuff,which make me think again as to how

to write my next flash application. Now the time for debugging,if I am right the first thing one do in a flash

trace statement is
trace(this);
Wow,that gives me the current object on my output panel.What else,if I want to know any property of the object I

will go ahead and do the same trace with the properties in the trace.
trace(this.myProperty);
I really got excited,when I got to know about a nifty function on “flash.utils” package.The name of the function

is “describeType”.What it does is returns an XML object of the parameter object we pass in to the function.Thats

huge. I mean it gives all the deatils of that object,I mean all the details.

Now I am putting down here, the whole code there in the FLA just in case you want the code only.

import flash.events.*;
this.addEventListener(Event.ENTER_FRAME,onEntry,false,0,true);
this.addEventListener(Event.EXIT_FRAME,onExit,false,0,true);
//import flash.utils.describeType
trace(this.barClip);
this.barClip.addFrameScript(10,myFunc);
function myFunc():void
{
this.barClip.stop();
}
//
function onEntry(e:Event):void
{
trace(‘: Entry on frame : ‘,this.currentFrame);
}
function onExit(e:Event):void
{
trace(‘: Exit from frame : ‘,this.currentFrame);
if(this.currentFrame==100)
{
this.stop();
this.removeEventListener(Event.ENTER_FRAME,onEntry,false);
this.removeEventListener(Event.EXIT_FRAME,onExit,false);
trace(describeType(e));
this.barClip.addFrameScript(10,null);
this.barClip.play();
}
}

With that I am hoping these tips may open your door to new innovations in the way we script and do stuffs in

Flash.
Happy Flashing. 🙂

Advertisements

Author: saumya

designer / developer / maker / educator @saumya

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s