Archive for March, 2008

How to add and remove Mediators in a actionscript-3 puremvc app

So since PureMVC has updated twice and also I never talked about garbage collection of the app, I have refactored PurelyKuler to work with PureMVC 2.3. Thate are quite a few changes, some being:

  1. the framework is being ported to many languages like PHP, Ruby, Python, Coldfusion, C# and many others.
    [as]import org.puremvc.as3.interfaces.IFacade;
    import org.puremvc.as3.patterns.facade.Facade;[/as]
    as oppose to
    [as]import org.puremvc.interfaces.IFacade;
    import org.puremvc.patterns.facade.Facade;[/as]
  2. there is a new way to notify observers:
    [as]facade.sendNotification(PurelyKulerConstants.STARTUP, app);[/as]
    as oppose to
    [as]facade.notifyObserver(new Notification(PurelyKulerConstants.STARTUP, app))[/as]
  3. also the Mediators are can be named from outside the class, so you can have many instances of the class and remove specific instances and not all.public function PurelyKulerMediator(mediatorName:String = null, viewComponent:Object=null){
    _tf = new TextField();

    super(NAME, viewComponent);// the colorContainer
    }
    Those are just a few.

Alright back to PurelyKuler.

So if you look at the last example I did, it was just about getting data from a Proxy to a Mediator.

This time I’m adding garbage collection and using the new, to ver2.3, onRemove method in IMediator to delete all the ui and variables. Like this.
[as]override public function onRemove():void
{
vo.removeEventListener(MouseEvent.CLICK, changeColor);
vo.graphics.clear();
vo.parent.removeChild(_tf);

_tf = null;
_ka = null;
cc = undefined;
trace(”_tf: ” + _tf);
}[/as]
Alright enough typing, here it is. Click on a mediator name.

Source | PurelyKuler2

3 comments March 30th, 2008

Mrs. Spitzer’s thoughts during her husbands sex scandal press conference

Mrs. Spitzer has a lot to think about. – Link

Add comment March 12th, 2008

Hilary Clinton’s Advice to NY Governor’s wife – Bitstrips is awesome

She’s good! -Link

Add comment March 12th, 2008

I smell a lawsuit

I was doing a search for Adobe AIR books coming out and found this. Who’d a thunk it!

adobeair.jpg

Add comment March 2nd, 2008

How to use the FileSystem in AIR to find the users directory folders

I was messing around last night with AIR and I stumbled apon this:

  1. start an AIR app in flash cs3
  2. add a list component
    1. name it dir_list
  3. drop the code below in the actions panel
  4. And Viola!
  5. PS – PC people, I put a test to see if My Documents in in that Directory.

filestream.jpg

[as]

import flash.filesystem.*;

var userDirFiles:Array = File.userDirectory.getDirectoryListing();
for (var i:uint = 0; i < userDirFiles.length; i++) {
if (userDirFiles[i].isDirectory) {
//this.display_txt.text = String(userDirFiles[i].nativePath);
dir_list.addItem({label:userDirFiles[i].nativePath })
var tmpString:String = userDirFiles[i].nativePath;
if(tmpString.search(/My Documents/) != -1)
{

dir_list.addItem({label:”working”});
break;
}
}
} [/as]

Add comment March 1st, 2008


    Blog Calendar

    March 2008
    M T W T F S S
    « Feb   Apr »
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  

    Posts by Month

    Posts by Category