Archive for October 2008
Flash Camp: San Francisco – Flash CS4

We’re in day 2 of Flash Camp located at the historic Adobe building in San Francisco.
Adobe kindly gave every attendee a pre-release of Flash CS4, and I have admit, after a quick overview, they have added really cool features!
The first thing you’d notice is the tools locations have changed, the tools are fixed in place (with option to move around), some liked it and prefered it to the loosely moveable tool sets. Another feature that certainly stands out is the ‘Bone’ tool. Briefly, it’s an arm where you can hook two objects and use one of them as rotational center with the radius length of the bone. You can add several objects connected by bones.
You also will be greeted by the 3D feature, from the look of it being denies it looks extreemly easy to use! I feel any neophyte will be able to do 3D stuff pretty quickly (having Flex as the backbone of most of my applications I don’t see much use for it out of the designing world).
Oh, and get this, Adobe has Free Massage for any attendee; They sure do know how to pamper their developers!
Flex – Dispatching your very own custom event
Many friends of mine are noticing the emerging new Programming Language that’s sweeping the RIA world. ActionScript 3. Like many other OO languages, you can easily customize your own Event. Here’s a quick and simple way of understanding it.
The Problem: You want to create a timer, and after each elapsed time, you would like to dispatch an event and a variable that keeps updating (without using global variables, and ensuring decoupling).
CountdownTimer.as : A timer which elapses ever second and displays a countdown of a time remaining with fixed endTime.
CountDownTimer.as:
// in the constructor
ticker = new Timer(1000);
ticker.addEventListener(TimerEvent.TIMER, onTick);
ticker.start();
private function onTick(evt:TimerEvent):void {
var myEvent:MyTimerEvent = new MyTimerEvent(“secElapse”);
myEvent.timeLeft = getCountDown(countDownTime – (new Date()).getTime());
dispatchEvent(myEvent);
}
——
MyTimerEvent.as: Our very own customized timer
public class MyTimerEvent extends Event {
private var theTime:String;
public function MyTimerEvent( type:String ) {
super(type);
}
public function set timeLeft ( time:String ):void {
theTime = time;
}
public function get timeLeft ():String {
return theTime;
}
}
——-
Our MXML where all the action converges on CreationComplete=”onCC()” :
private function onCC():void {
// listner to secElapse dispatcher
countDown = new CountdownTimer();
countDown.addEventListener("secElapse", updateTime);
}
// Update the display timer
private function updateTime (e:MyTimerEvent):void {
countDown.endTime = m_endTime;
m_updatedTimeRemaining = e.timeLeft;
}