Monday 8 October 2007

Goodbye onEnterFrame

Right so firstly I discover onEnterFrame() is gone. Bugger! What have they done with it?

I used to use onEnterFrame() all the time. Probably too much. It was down to a lack of knowledge I'm sure, but there were few problems that I couldn't manage to onEnterFrame() my way around. A generous dollop of checking here and a few instructions there. Sometimes my onEnterFrame() function could become a long list of if's waiting and waiting like Vladimir and Estragon.

At first glance it's simply been replaced (as with a number of other things) with the general addEventListener() function. This allows you to attach a bit of code to an "event" and then set it off when that event happens. That could be a mouse-click or a rollover, it could be a bitmap or some XML loading.

For onEnterFrame() the event you're looking for is ENTER_FRAME and so before you know it you're back where you were only with a nice sloppy AS3 smile on your face!

addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void
{
trace("and another frame gone!");
}
... but wait!

If I just insert that into my old code I've missed a trick. You see my old onEnterFrame() function with it's long list of if statements was doing me no good. All those if's returning false most of the time, long and unwieldy and hard to decipher the day after tomorrow.

What this new addEventListener() is actually encouraging me to do is use it for just that purpose. Instead of checking and checking and checking again, I need to attach my nugget of code to the event I'm waiting for. Then once it happens my code will get run. Not only that but I'm left with nice, clean, well organised actionscript which I can come back to in over a week and still understand.

The thing which I'm still confused about right now is that apparently the addEventListener() method can be called on any object that is part of the event flow, but what is the event flow? And what objects are part of it?

I must look into that.

Thursday 4 October 2007

About me

OK a little background. I'm a designer working for a UK telco. In web design generally but it's pretty general. I started with HTML in 2000. Got a job which quickly taught me CSS and JavaScript and then did a bit of Perl before a huge amount of PHP. That pretty much became what I did (+ MYSQL naturally) before I decided that actually I wanted not to program but to design. So I jumped.

Since then I've been getting to grips with all Adobe's software (not to mention Visio!) and particularly Flash has become something which most interests me. Not surprisingly perhaps as it seems to satisfy my visual/creative urges while involving that kind of programming/problem solving I still enjoy.

I choose Flash over Flex (for now) as I want to keep the visual emphasis in the mix and not move completely into application design (although I see the overlap and I'm willing to be convinced).

So previously I've used Flash Proffessional 8, ActionScript 2 and I've looked at Flash Lite (1 is limited, 2 seems good but handset coverage was frustratingly low when I last checked).

I've recently upgraded to Adobe CS3 and thought, considering the introduction of AS3 that this is the time I should really crack Flash - which basically to me means ActionScript.

That's me and this is the subsequent blog.

Wednesday 3 October 2007

AS Tart

Someone once said that blogging was a good way to learn about something. Well he's to blame for what follows, not me!

Enjoy!