AIR, Flex / Flash, FMS, PushButton, Game… Developer
Posts tagged Tip of the day
Tip of the Day – Using the libs directory in Flex Builder
Jan 11th
This tip I’m stealing from Amy over on the flexcoders list.
One not so well documented feature of Flex Builder is the use of the libs directory. By default, when you create a new Flex Project, a libs directory is created. So say for example, you want to create a project, and you are planning to use the Cairngorm framework.
All you need to do is copy Cairngorm.swc into your libs directory, and you’re good to go.

Tip of the Day – Mouse wheel scrolling on the mac
Jan 10th
A friend of mine asked me yesterday if I would take a look at a Flex application that he was writing. I said, “of course!”, and pulled up his app in my browser. To my surprise, I couldn’t for the life of me figure out how to navigate through his application.
So I called him back as asked him. He told me that his app uses the mouse wheel quite a bit to navigate around, he thought it would be very intuitive. I guess not everyone knows that mouse wheel scroll events don’t register on the mac.
So today I’m letting everyone within the sound of my blog know that…
Mouse wheel scrolling does not work on Macs… natively!
Luckily for us, Ali Rantakari has created a solution for this very problem. You can read up about the solution in this post.
Tip of the Day – Proxies… Make ‘em dynamic
Jan 9th
A couple of days ago, I was working on my DateTime proxy class.
DateTime.as (Trimmed version)
package net.natebeck.core { import com.flexoop.utilities.dateutils.DaylightSavingTimeUS; import flash.utils.Proxy; import flash.utils.flash_proxy; public class DateTime extends Proxy { // Instance Variables protected var _date:Date; protected var _timezone:Timezone; public function DateTime(... args) { super(); _date = new Date(args[0]); if(args[0] is String) setTimezone(parseTimezone(args[0])); } public function setTimezone(value:Timezone):void { trace("Setting Timezone: "+value); _timezone = value; } public function getTimezone():Timezone { trace("Getting Timezone: "+_timezone); return _timezone; } public function getTimezoneOffset():Number { return _timezone.offset; } override flash_proxy function callProperty(methodName:*, ... args):* { var res:*; switch (methodName.toString()) { case 'toString': res = "foobar"; break; default: res = _date[methodName].apply(_date, args); break; } return res; } override flash_proxy function getProperty(name:*):* { trace("getting property: "+name); return _date[name]; } override flash_proxy function setProperty(name:*, value:*):void { _date[name] = value; } } }
I wrote a simple test application to test my DateTime Proxy class while I’m developing.
TestDateTime.as
package { import flash.display.Sprite; import net.natebeck.core.DateTime; import net.natebeck.core.Timezone; public class TestDateTime extends Sprite { public function TestDateTime() { var create:Object = "Jun 17 12:00:00 GMT-0500 2009"; var oldDate:Date = new Date(create); var strDate:DateTime = new DateTime(create); trace("old: "+oldDate); trace("new: "+strDate); strDate.getTimezone(); strDate.setTimezone(Timezone.PST); strDate.getTimezone(); trace(strDate.toString()); } } }
When trying to compile using Flex Builder I ran into this error:
ERROR 1061: Call to a possibly undefined method toString through a reference with static type net.natebeck.core:DateTime.
I thought to myself, “Well that’s lame… the whole reason I’m using the Proxy class is so I don’t have to re-write every method within my class”.
As usual, the issue wasn’t with the compiler, it was me being dumb. Computers… they’re always right.
The answer was simple, and makes complete sense after someone mentioned it.
When creating your own Proxy class, make them dynamic!
public dynamic class DateTime extends Proxy
If you’re confused about when or why to use the flash.utils.Proxy class, I gave a presentation yesterday at the Seattle Flex User Group about the Proxy class. My presentation materials are posted here.
I’d also like to thank Dale and Josh McDonald for quickly responding to my question on flexcoders.
Tip of the Day – Flex Date Utils
Jan 8th
I’ve recently been working with Gareth over at flexoop.com. He has been creating a more feature rich Date utility class.
As he puts it, “FlexDateUtils expands the Flex date library to be more on par with the date libraries found in many other programming languages. Most of the methods were adopted from ColdFusion as those are very full featured.”
Gareth has done a great job putting this library together.
Check out the project on RIAForge.
There are also in depth explanations on how to use the library on flexoop.com.

