Thursday, November 29, 2007

Remoting Object Flex

In mxml this code would be used








For every method defined in the remote object there should be fault and result function


//result function
private function getFullDetailsSuccessfull(evt:ResultEvent):void
{
PopUpManager.removePopUp(initial);
CursorManager.removeAllCursors();

jobMaster.removeAll();
jobMaster = ArrayCollection(evt.result);

}

// fault function
private function getFullDetailsFailed(evt:FaultEvent):void
{
this.enabled =true;
Alert.show("There was an error communicating to theserver:"+evt.fault.faultCode);
}


Corresponding to this there should be entry in remoting-config.xml
the destination should be same defined in the mxml file



com.apnatek.business.remoting.ListJobs
request

Thursday, November 1, 2007

Flex Custom Resizable and Min-Max Panel

Here a snipplet of code which would help you to make a resizable panel which can be minimised when its not in use.




creationComplete="initComp()" >



[DefaultProperty("subComponents")]

[Event("minimized")]
[Event("maximized")]
[Event("normalized")]




















// the title property
private var _title:String;
public function set title(t:String) : void
{
_title = t;
}
[Bindable]
public function get title() : String
{
return _title;
}

// the subComponents property (default)
private var _myChildren:Array;
public function set subComponents(a:Array) : void
{
_myChildren = a;
}
public function get subComponents() : Array
{
return _myChildren;
}

private function addSubComponents() : void
{
if( _myChildren == null ) return;
for(var i:int=0; i < _myChildren.length; i++) {
panel.addChild( _myChildren[i] );
}
}

// the controlComponents property
private var _myControlChildren:Array;
public function set controlComponents(a:Array) : void
{
_myControlChildren = a;
}
public function get controlComponents() : Array
{
return _myControlChildren;
}

private function addControls() : void
{
if( _myControlChildren == null ) return;
for(var i:int=0; i < _myControlChildren.length; i++) {
controlBar.addChild( _myControlChildren[i] );
}
}

// display minimize button property
[Bindable]
public var showMinimize:Boolean = true;

// display maximize button property
[Bindable]
public var showMaximize:Boolean = true;

private function initComp() : void
{
if( !showMinimize ) minButton.width=0;
if( !showMaximize ) maxButton.width=0;
}

// minimizes (or restores) this control
public function minimize(fireEvent:Boolean=true) : void
{
if( currentState == 'minimized' ) {
currentState = '';
if( fireEvent ) dispatchEvent( new Event("normalized") );
}
else {
currentState = 'minimized';
if( fireEvent ) dispatchEvent( new Event("minimized") );
}
}

// maximizes (or restores) this control
public function maximize(fireEvent:Boolean=true) : void
{
if( currentState == 'maximized' ) {
currentState = '';
if( fireEvent ) dispatchEvent( new Event("normalized") );
}
else {
currentState = 'maximized';
if( fireEvent ) dispatchEvent( new Event("minimized") );
}
}

public function normalize(fireEvent:Boolean=true) : void
{
currentState = '';
if( fireEvent ) dispatchEvent( new Event("normalized") );
}
]]>


layout="absolute"
left="0" top="0" bottom="0" right="0"
creationComplete="addSubComponents(); addControls()">








id="minButton"
icon="@Embed('minimize_icon.gif')"
visible="{showMinimize}"
click="minimize()"/>
id="maxButton"
icon="@Embed('maximize_icon.gif')"
visible="{showMaximize}"
click="maximize()"/>






you can accesss it any where in your application using tag

About Me