Repeat your calls not your functions.

Posted by Jonathan Fricke on July 7th, 2006

When I’m writing any code I have this little internal rule: any block of code repeated more than two times becomes a function. Naturally, I end up with quite a few functions.

Needless to say , one of the first things that caught me off guard when I started rolling back into the Flash4 ActionScript .5 state of mind, was the inability to create user defined functions. UGH! So, to that end, if there is anyone else feeling my pain on this issue, I’ve slapped together a quick sample of how to overcome the lack of UDFs in Flash Lite. I hope it helps.

You can view the really simple example that’s also available for download. Let’s get to it.

My first move was to create a MovieClip on the main timeline and gave it an instance name of ‘f’. Within my MovieClip ‘f“, I inserted blank keyframes on frames 2 and 3. Each frame was given a frame label, ‘foo’ and ‘bar’, respectively. On frame 1 of the same clip, I added a stop action

Whenever I needed the code on a particular frame (either ‘foo’ or ‘bar’) to be executed I would add the following code to any given button.

on(someEvent)

{

tellTarget(’f‘)

  {

gotoAndStop(‘foo’);

}

}

While this code would work, it’s not the most elegant solution to me. Instead of using the tellTarget command we could simply things a bit by using the AS.5 keyword call

Now, the same code above would be:

on(someEvent)

{

call(’/f:foo’);

}

Booyuh! Much cleaner and easier to read.

See attached files for samples. Remember this is designed to work with a phone so you’ll need to push the 1 & 2 buttons.

Certifiable

Posted by Jonathan Fricke on July 6th, 2006

Thanks to the stellar preparation by James at Adobe, I aced my Flash Lite 1.1 Developer Exam today! That means we can start adding it to the Connect Learning Schedule. I can’t wait to start teaching the class to others and watching this stuff take off!

I’m going to try and have a tutorial about Flash Lite game development posted soon.

Speaking of tutorials, if you have any thoughts about a particular topic be it Flash, Flash Lite, ColdFusion, HTML, CSS, SQL or anything, I’d love to hear them. Just leave a comment and let me know. In addition to Flash Lite content, I’ll be posting a tutorial covering the Accordion Component in Flash as requested by Ray.

Out to the Mothership.

Posted by Jonathan Fricke on June 25th, 2006

I’m going to be heading out to Adobe for a little Flash Lite Training this week. I’m really excited about getting into Mobile Applications and I already have a few ideas for some applications. There are already some very cool apps that have been made, and I’m looking forward to contributing what I can to the community.


Copyright © 2007 Go Blog Go!. All rights reserved.