Friday, April 10, 2009

Custrom Item renderer

This is a customitemrenderer and a live value mapping...



Thursday, April 9, 2009

endpoint issue is not end of the road

errors like..

RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: http://localhost:8080/WebContent/messagebroker/amf'" 

can be resolved in a single step..

First ensure you don't modify anything in the service config file.. Leave the poor guy alone.
Then right click on your project ---> go to properties -> flex server ==> servercontextrooot --> 

Give it the same name as your project

if your project is Fantastico

your server root will be 

/Fantastico..

Now you are good to go on any server any place blazeDs or LCDS no issue

Thursday, April 2, 2009

Flex print screen

This is a simple method to do a print screen from flex

private function doPrint(){

var printJob:FlexPrintJob = new FlexPrintJob();
   if (printJob.start() != true) return; 

Application.application.minHeight = Capabilities.screenResolutionY;
Application.application.minWidth = Capabilities.screenResolutionX;

printJob.addObject(UIComponent(Application.application),  FlexPrintJobScaleType.MATCH_WIDTH);
printJob.send();

 application.invalidateDisplayList();
application.invalidateSize();
application.invalidateProperties();
application.initialize();

}


Last and not the least call this function from your button or image or any thing..

Saturday, March 28, 2009

A simple timer event

So many times one searches for a simple timer event. Say I want to do some thing after few seconds then one requires a timer so here it goes..

public var t:Timer;

public function init():void{
//This can be any function...

t = new Timer(3000); //3000 is the timer interval which corresponds to 3 secs
t.start();
t.addEventListener(TimerEvent.TIMER,targets);//So after 3 secs it goes to the targets function
}

public function targets(event:Event):void{
t.stop();//Stop the timer
Alert.show("Ta da I am here after 3 secs");
}

Wednesday, December 10, 2008

Caringorm Drawback a solution..

This blog is thanks to Derrick's views which I concur with and the inspiration for this sample code from joe's Blog ..
What led to this code..

1. The cairngorm draw back of a failure to communicate from the command to the view.
2. The non ability to track an event after dispatch which is very essential.

A extremely detailed analysis is available courtesy Jess.

A small review of the code... (details available at joe's Blog)...

From the command one can send results or intimate the view that a particular event has completed or faultered.
 
So we dispatch an cairngorm event from the command. This is controlled by viewcontroller a sort of frontcontroller and another || sort of command which handles the event.

Now in the view we are listening to this event so as soon as this event occurs the functions are performed. 

This introduces a lot of flexibility in the view and the command is reusable and it gets into the true code reuse formula...

Cairngorm Phew!!!

Cairngorm was always a slippery eel. You hold one class the other slips through your hands. But thanks to David Tucker & other bloggers it enabled me to put together an example which one may relish. Probably it may be just another example but you know what my exp. says the more examples you browse:

1. You get better in reading code.
2. You get a different perspective.
3. Nobody can say you ripped in out from this blog..just joking..

Lets start with few basics. I know this ya da da da is there every where but its important you know.. My post must be long you see... So here goes my version..

First thing none of these bifurcations are strict you could implement every thing in one page or break it into tiny pieces.. Why? since the whole community is reading it like that nah it makes sense on a long run.

You must have  a Main.mxml which is going to house all other elements of this jig saw puzzle. 

modelLocator will hold the variables which area going to be common across modules and which has to be accessed in the command section. we'll see that later.

view: this will hold the view section or the so called front end of the flex application

vo(value object): some thing like a bean we use in java while send data to the event to the command. I am coming to that ..

Front controller: the supervisor.. He says which event is linked to which command. 

Event: when you want to perform an operation we could trigger an event.. We could pass data into the event too..

Command: At last we are here.. This would perform all the dirty operations talking to database updating the model variables  handling results and all that.. They say the model variables can be touched only by the command ..


service: it holds the declaration of the remoteObject ,Httpservice and all that Just the declaration thats all..

Delegate: Now the command is really over stressed so lets delegate some part of the work. The delegate will talk to the service and handle the remote calls..

Who should bear the results.

The responder is responsible to handle faults and results..

So the command now modifies the model variables and ta da thats cairngorm...

It sounds wierd right.. 

Visit davidtucker.net for some fantastic video tutorials.

The other sites..

cairngormdocs.org
the adobe labs site for cairngorm..

By the way there is a sample application that I promised and here it is