Archive for June, 2008

AS3 function Overloading

The below mxml code demonstrates function overloading in AS3 using …args
fnCreateOverLoaded function can be given with variable number of arguments and handled differently.

<?xml version=’1.0′ encoding=’utf-8′?>
<Application xmlns=’’&gt;
import flash.utils.Dictionary;
public var targetMap: Dictionary = new Dictionary();
public var targetEventMap: Dictionary;
private function addEvent(event:Event, listener:Function, …args ) : void
targetEventMap = targetMap[] == undefined ? new Dictionary : targetMap[];
targetEventMap[event.type] = { listener:listener, args:args };
targetMap[] = targetEventMap; event.type, onEvent,false,0,true);
private function onEvent ( e:Event ) : void
targetEventMap = targetMap[e.currentTarget];
if (targetEventMap[e.type].args[0] is Event) targetEventMap[e.type].args.shift();
targetEventMap[e.type].args.unshift( e );
targetEventMap[e.type].listener.apply( e.currentTarget, targetEventMap[e.type].args );
private function handlerFn(e:MouseEvent,…args) : void
var tempObject:Object = new Object();
var functionName:String = ‘fnc’ + (args.length).toString();
tempObject.functionName = new Function()[‘fnOverLoaded’].apply(this, args))
private function fnOverLoaded(…args):void { args.toString(),’arguments ‘+(args.length).toString())
private function fnCreateOverLoaded(…args):void {
var event:Event = args[0] as Event
if(targetMap[] == undefined ){
public function removeEvent( target:IEventDispatcher, type:String ) : void
var targetEventMap : Dictionary = targetMap[target];
delete targetEventMap[type];
target.removeEventListener( type, onEvent );
<Button id=’btn1′ label=’with2Args’ click=”fnCreateOverLoaded(event, handlerFn,’arg1′, ‘arg2′)” />
<Button label=’with4Args’ click=”fnCreateOverLoaded(event, handlerFn,’arg1′, ‘arg2′,’arg3’, ‘arg4’)” />


custom Event with isDefaultPrevented()

Step 1:
dispatchEvent(new Event(“customEvent”, false, true )) [Link]
Step 2:
addEventListener( “customEvent”, handler, false, EventPriority.DEFAULT_HANDLER, true );  [Link]
The EventPriority.DEFAULT_HANDLER enables prevent default

 By Implementing these steps – and plus your custom handling for event.isDefaultPrevented()  enables your custom event to be prevented from action. Example: [Link]

Flash Player 10 Release

Great news, now we can save file from flash. we have new data type vector, support for 3d, new text engine and lot more 🙂  To develop code using flex for Flash 10

Code to Save any file in using flash
var fr:FileReference;‘data to be saved in a file’,;

example : files

Adobe release notes