...these be from google reader...


Archive for the ‘Flash’ Category

Multi-Mania 2007

Wednesday, May 30th, 2007

I gave a session at multimania last friday (25th may 07) on the fine topic of “Exploring Text Effects in AS3 and Flex2″ (with the marketing name of “Dazzling Text Effects”). There was much rejoicement. My friend Pieter was kind enough to stay awake and take a picture!

speaking at multimania

As you can see, I pretty much rented an empty cinema to pose as a speaker!

Also worthy of note, I forgot my clipper at my inlaws a few centuries ago when I last cut my hair, so, I actually resemble my pirate smiley in the photo… YAARRRRRRR etc. :buttrock:

Apparently I wasn’t all bad, here’s what the guys at thesedays had to say about it :ooh:

I promised I would swiftly provide source code to the files I presented… erm… I will, one at a time, at my own pace, I’ll actually have something to blog about… Like I said, I hacked most of it together only a few nights before the show, so, naturally I would be too embarassed to share such dribble…

Thanks again to Serge, Koen and the other organizers for smoking enough crack to invite me :D

PSP style menu with flex

Friday, March 2nd, 2007

Back in December I saw Tink speak at Flash On the Beach… He showed an application of his where the screens were lined up horizontally, and smoothly “slid” from one to another when navigating. For shits and giggles I decided to reproduce it in a cms project that I’m currently working on.

As I was tinkering (har har) I remembered a project I worked on for PlayStation Portable… I came in late to the project, Serge Jespers had written a menu that mimics the PSP one… I remember that being a few hundred lines of code… It occurred to me that with Flex I could write the same thing with far less…

well, here it is:



PSP Style Menu with Flex

I know I know, it’s not EXACTLY the same, but the concept is there (this is a test, not a paid project ;) ) The First two yellow items don’t actually contain “sub menus”, the red ones do, so be sure to click up and down (or use the arrow keys)…

Rather than creating a “Playstation Menu Component” I modeified a Slider component from an older project. The “HorizontalSlider” and “VerticalSlider” extend a baseclass called “Abstract slider” (see the source, psp_menu_clasees.components package).

The Abstract Slider is a “Template Component”, meaning the class allows users to either add “menu items” by placing Tags in mxml, or, through actionscript by using the addSlideItem() method. Search the documentation for “Template Component” for futher details.
The Subclasses (or concrete implementations) are very simple… each places a Box component and direction specific “sliding” instructions.

…sooo, to conclude, the actual code for the menu is around a 100 lines or so… It could have been made with less, but for the sake of cleanliness and functinality it’s what it is…

Right Click “View Source” or click here to see the code…

Using EventDispatcher in AS2, the AS3 way

Tuesday, February 20th, 2007

After a long run of AS3 goodness, I was outsourced to do some dinosaur development at these-days… An AS2 project, which unfortunately got cancelled after just 4 days :(.

It wasn’t a total waste of time though… Coming back from ActionScript3 to 2 brought along a number of “better” programming practices :)

The best example that popped up is event handling… Sure, event bubbling etc. is out of the question, but some basics can be imitated with relatively nice results.

In AS3, you extend mx.events.EventDispatcher (or implement flash.events.IEventDispatcher) to (surprise surprise) dispatch events… The “old way” of achieving this in AS2 was to “shove in” some clunky EventDispatching code… So, simply shove that clunkiness into a class:


[as]
import mx.events.EventDispatcher;
class AS2EventDispatcher{

public function AS2EventDispatcher(){
EventDispatcher.initialize(this);
}

public function dispatchEvent(){}
public function addEventListener(){}
public function removeEventListener(){}

}
[/as]

then, (instead of typing that in each of your wanna-be dispatching classes), just like AS3, you extend it:

[as]
import AS2EventDispatcher;

class DataModel extends AS2EventDispatcher{

public function DataModel(){
super();//only drawback... in AS2 the constructor must be created and super must be invoked
}

private function dispatchSomethingSweet():Void{
dispatchEvent(new Event("something_sweet"));
}
}
[/as]

as the discerning reader would have noticed (kl3ver boy), new Event(”some_event”) is not standard AS2… so, this event class must also be created, in order to be extended:

[as]
class events.Event{

private var _type:String;
public function set type(t:String):Void{}
public function get type():String{return _type;}

private var _target:Object;
public function set target(t:Object):Void{_target=t;}
public function get target():Object{return _target;}

public function Event(t:String,targ:Object){
_type=t;
target=targ;
}

public function toString():String{
return "Event{_type:"+_type+"_target:"+_target+"}";
}

public function clone():Event{
return new Event(_type,_target);
}
}[/as]

why one might want to clone() events in as2 is beyond my willingness to think about the subject though…

anyhow, good times, good times…