Hi ,
1) In the below code i have created a static error box in MXML file . can u please help me to create the dynamic errorbox instead of the below static object.
Static Object Creation :
?%26lt;mx:Fade id=''ViewStack_EffectStart'' duration=''500'' alphaFrom=''0.0'' alphaTo=''1.0''/%26gt;
?%26lt;mx:Fade id=''ViewStack_EffectEnd'' duration=''500'' alphaFrom=''1.0'' alphaTo=''0.0''/%26gt;
%26lt;comp:ErrorBox id=''errorBox'' active=''{active}'' showEffect=''{ViewStack_EffectStart}'' hideEffect=''{ViewStack_EffectEnd}''/%26gt; .
2).?The above static objects is working fine, but the problem is that we have lot of similiar static object which creates a memory issue.If we create dynamic objects, will it avoid the issue.Is dynamic objects advisible?.
Thanks in advance.Please reply ASAP.
Thanks ,
San.
Dynamic Object Creation in MXML ClassYou need to create your errorbox as a component with some public properties for things like the error message as below
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Canvas xmlns:mx=''http://www.adobe.com/2006/mxml'' width=''318'' height=''158''?backgroundColor=''#EDDDDD''%26gt;
?%26lt;mx:Script%26gt;
?%26lt;![CDATA[
?[Bindable]
?private var _errorMessage:String;
?
?[Bindable]
?public function set errorMessage(value:String):void {
?_errorMessage = value;
?}
?
?public function get errorMessage():String {
?return _errorMessage;
?}
?]]%26gt;
?%26lt;/mx:Script%26gt;
?
?%26lt;mx:Text x=''20'' y=''24'' text=''{_errorMessage}'' width=''279'' height=''114''/%26gt;
%26lt;/mx:Canvas%26gt;
Then you can set the errror Message for diffferent errors as shown below in the main app
%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml'' layout=''absolute''?%26gt;
?%26lt;mx:Script%26gt;
?%26lt;![CDATA[
?import mx.managers.PopUpManager;
?private var errorBox:ErrorBox;
?
?private function showError():void {
?errorBox = new ErrorBox();
?errorBox.errorMessage = 'This is an error';
?PopUpManager.addPopUp(errorBox,this);
?PopUpManager.centerPopUp(errorBox);
?}
?
?private function removeError():void {
?PopUpManager.removePopUp(errorBox);
?}
?]]%26gt;
?%26lt;/mx:Script%26gt;
?%26lt;mx:Button x=''42'' y=''41'' label=''Show Error'' width=''106'' click=''showError()''/%26gt;
?%26lt;mx:Button x=''42'' y=''71'' label=''Remove Error'' width=''106'' click=''removeError()''/%26gt;
%26lt;/mx:Application%26gt;
To take if further and to fit your needs you'll probably want to add more public properties to set things like error icons or buttons to select and return a response, warning messages etx.
Hope that helps
Andrew
Dynamic Object Creation in MXML ClassHi ,
The below dynamic object creation is not working . can u please guide me to create dynamic object.
?with curly brace initilization ( active = ''{active}'' ).
Static Object Creation :
Eg:
?%26lt;mx:Fade id=''ViewStack_EffectStart'' duration=''500'' alphaFrom=''0.0'' alphaTo=''1.0''/%26gt;
?%26lt;mx:Fade id=''ViewStack_EffectEnd'' duration=''500'' alphaFrom=''1.0'' alphaTo=''0.0''/%26gt;
?%26lt;comp:ErrorBox id=''errorBox'' active=''{active}'' showEffect=''{ViewStack_EffectStart}'' hideEffect=''{ViewStack_EffectEnd}''/%26gt;
Dynamic Object Creation:
Eg:
?%26lt;mx:Fade id=''ViewStack_EffectStart'' duration=''500'' alphaFrom=''0.0'' alphaTo=''1.0''/%26gt;
?%26lt;mx:Fade id=''ViewStack_EffectEnd'' duration=''500'' alphaFrom=''1.0'' alphaTo=''0.0''/%26gt;
var errorBox:ErrorBox?= new ErrorBox ();
?errorBox.active=''{active}'';
?errorBox.showEffect=''{ViewStack_EffectStart}'';
?errorBox.hideEffect=''{ViewStack_EffectEnd}'';
Thanks,
Santhosh.
No comments:
Post a Comment