Object Comparison In Flex/AIR
To compare the objects whether they are same or not we can use following method of SerializeUtil Class
public class SerializeUtil
{
public static function ObjectToString(object: *): String
{
var ba: ByteArray = new ByteArray();
ba.writeObject(object);
return ba.toString();
}
public static function ObjectToByteArray(object: *): ByteArray
{
var ba: ByteArray = new ByteArray();
ba.writeObject(object);
ba.position = 0;
return ba;
}
}
To do the actual comparison just use these lines of code to compare the two objects.
if (SerializeUtil.ObjectToString(object1)==SerializeUtil.ObjectToString(object2))
{
// Objects are 'equal'
}
else
{
// Objects are not 'equal'
}
Thanks and Regards
Varun Rathore
Friday, June 6, 2008
Friday, May 16, 2008
Custom Event Creation and Data Passing
Passing Data With Custom Event
As being an event driven language Action Script provides the mechanism of sending any kind of object with
the event.The concept is more important when we are supposing to get value of any varialbe of mxml into
any another mxml which is far enough in the structure(Folder Structure)of our Application. It is very simple
to create any custom event for the occurence of any particular event.Within the same parent folder in which
your mxml containing the variable create a folder (let suppose with name ‘event’).In mxml let's suppose
variable of arrayCollecton ‘myCollection’ is defined and it is already assigned some data.
Now we will create a custom event ‘CustomEvent’ in the folder where your mxml(which is having that arrayCollection)is present.
Just create one action Script class file Copy and Paste the code below.
——————————————————————————————–
package myPro.events
{
import flash.events.Event;
public class CustomEvent extends Event
{
public var mybool:Boolean=true;
public var myCollection:ArrayCollection;
public function PropertyThumbEvent (type:String,myCollection,mybool:Boolean=true):void
{
super(type);
this.myArrayCollection = myArrayCollection;
this.b=b ;
}
override public function clone():Event
{
return new CustomEvent(type,myCollection,mybool);
}
}
}
——————————————————————————————–
Now at this mxml where ‘myCollection’ is present First add Metadata as below :-
——————————————————————————————–
[Event(name="myCustomEvent",type="myPro.events.myCustomEvent")]
——————————————————————————————–
Again from the same mxml just dispatch one event i.e. as:-
——————————————————————————————–
dispatchEvent(new CustomEvent(”myCustomEvent”,myCollection,true));
——————————————————————————————–
we can use it as follows:-
trace(event.myCollection)
As being an event driven language Action Script provides the mechanism of sending any kind of object with
the event.The concept is more important when we are supposing to get value of any varialbe of mxml into
any another mxml which is far enough in the structure(Folder Structure)of our Application. It is very simple
to create any custom event for the occurence of any particular event.Within the same parent folder in which
your mxml containing the variable create a folder (let suppose with name ‘event’).In mxml let's suppose
variable of arrayCollecton ‘myCollection’ is defined and it is already assigned some data.
Now we will create a custom event ‘CustomEvent’ in the folder where your mxml(which is having that arrayCollection)is present.
Just create one action Script class file Copy and Paste the code below.
——————————————————————————————–
package myPro.events
{
import flash.events.Event;
public class CustomEvent extends Event
{
public var mybool:Boolean=true;
public var myCollection:ArrayCollection;
public function PropertyThumbEvent (type:String,myCollection,mybool:Boolean=true):void
{
super(type);
this.myArrayCollection = myArrayCollection;
this.b=b ;
}
override public function clone():Event
{
return new CustomEvent(type,myCollection,mybool);
}
}
}
——————————————————————————————–
Now at this mxml where ‘myCollection’ is present First add Metadata as below :-
——————————————————————————————–
[Event(name="myCustomEvent",type="myPro.events.myCustomEvent")]
——————————————————————————————–
Again from the same mxml just dispatch one event i.e. as:-
——————————————————————————————–
dispatchEvent(new CustomEvent(”myCustomEvent”,myCollection,true));
——————————————————————————————–
we can use it as follows:-
trace(event.myCollection)
Creating FullScreen Flex/AIR/Flash Applications
Going Fullscreen in Actionscript
The main stage for the AIR application has a displayState property. The framework also contains a class, StageDisplayState, that defines three constants for the three different display states. By using these classes you can put your AIR application into any of the three display states .
PLAIN TEXTActionscript:
// Enter Fullscreen Interactive State
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
or
// Enter Standard Fullscreen State
stage.displayState = StageDisplayState.FULL_SCREEN;
or
// Enter Normal State
stage.displayState = StageDisplayState.NORMAL;
we can use these as follows :-
Going Fullscreen through JavaScript
The logic works exactly the same in JavaScript as it does in Actionscript, but the classpaths are different. You can see the examples below in Code Example 2.
PLAIN TEXTJavaScript:
// Enter Fullscreen Interactive State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
or
// Enter Standard Fullscreen State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN;
or
// Enter Normal State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.NORMAL;
Cheers
Varun Rathore
The main stage for the AIR application has a displayState property. The framework also contains a class, StageDisplayState, that defines three constants for the three different display states. By using these classes you can put your AIR application into any of the three display states .
PLAIN TEXTActionscript:
// Enter Fullscreen Interactive State
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
or
// Enter Standard Fullscreen State
stage.displayState = StageDisplayState.FULL_SCREEN;
or
// Enter Normal State
stage.displayState = StageDisplayState.NORMAL;
we can use these as follows :-
Going Fullscreen through JavaScript
The logic works exactly the same in JavaScript as it does in Actionscript, but the classpaths are different. You can see the examples below in Code Example 2.
PLAIN TEXTJavaScript:
// Enter Fullscreen Interactive State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
or
// Enter Standard Fullscreen State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.FULL_SCREEN;
or
// Enter Normal State
window.nativeWindow.stage.displayState = runtime.flash.display.StageDisplayState.NORMAL;
Cheers
Varun Rathore
Thursday, May 15, 2008
Flex 4 (Gumbo)
Flex 4, codenamed Gumbo, is now beginning active development. The product plan is not yet complete, but a few themes are under consideration:
Design in Mind: provide a framework meant for continuous collaboration between designer and developer. Probably involves an additional component model that integrates with the existing Halo components.
Accelerated Development: take application development from concept to reality quickly. Features could include application templates, architectural framework integration, binding improvements.
Horizontal Platform Improvements: features that benefit all application and user types. Features could include compiler performance, language enhancements, BiDi components, enhanced text.
Broadening Horizons: expand the range of applications and use-cases that can leverage Flex. Features could include finding a way to make the framework lighter, supporting more deployment runtimes, runtime MXML.
Download Flex 4 build
Cheers
Varun Rathore
Design in Mind: provide a framework meant for continuous collaboration between designer and developer. Probably involves an additional component model that integrates with the existing Halo components.
Accelerated Development: take application development from concept to reality quickly. Features could include application templates, architectural framework integration, binding improvements.
Horizontal Platform Improvements: features that benefit all application and user types. Features could include compiler performance, language enhancements, BiDi components, enhanced text.
Broadening Horizons: expand the range of applications and use-cases that can leverage Flex. Features could include finding a way to make the framework lighter, supporting more deployment runtimes, runtime MXML.
Download Flex 4 build
Cheers
Varun Rathore
Flex Development Frameworks
1. Puremvc Framework
PureMVC is a lightweight framework for creating applications based upon the classic Model-View-Controller design meta-pattern.
2. Cairngorm Framework
Cairngorm Framework is the most widely accepeted framework with Flex development.
3. Prana Framework
Prana Framework is runtime control framework and made on the basis of spring framework.
4. Foundry
Foundry ( sbasfoundry ) is an ActionScript 3 / Java framework designed for Flex 2 applications development.
5. Guasax Flex Framework
Guasax is an ease of use programming framework to provide ordered and scalable Flex applications.
Life cycle of guasax framework is based in the MVC pattern to take on our program actions .
PureMVC is a lightweight framework for creating applications based upon the classic Model-View-Controller design meta-pattern.
2. Cairngorm Framework
Cairngorm Framework is the most widely accepeted framework with Flex development.
3. Prana Framework
Prana Framework is runtime control framework and made on the basis of spring framework.
4. Foundry
Foundry ( sbasfoundry ) is an ActionScript 3 / Java framework designed for Flex 2 applications development.
5. Guasax Flex Framework
Guasax is an ease of use programming framework to provide ordered and scalable Flex applications.
Life cycle of guasax framework is based in the MVC pattern to take on our program actions .
Wednesday, May 14, 2008
AIR Aplication Work Offline With Sqllite
We can make the AIR application work offline and synch with the database.
We can use sqllite databse for the offline display of data.
sqllite is just like mysql but it would create a *.db file in ur application folder
from where we can access the data.
A sample code for creating and executing the sqllite queries.
on creation complete we create a database contacts.
private function creationComplete():void
{
connection = new SQLConnection();
connection.open(File.applicationDirectory.resolvePath('contacts.db'));
var statement = new SQLStatement();
statement.text="CREATE TABLE IF NOT EXISTS contacts (ID INTEGER PRIMARY KEY AUTOINCREMENT, action TEXT, inputXML TEXT, outputXML TEXT)" ;
statement.sqlConnection=connection;
statement.execute();
var statement = new SQLStatement();
statement.text="CREATE TABLE IF NOT EXISTS offlineRequest (ID INTEGER PRIMARY KEY AUTOINCREMENT, action TEXT, inputXML TEXT)" ;
statement.sqlConnection=connection;
statement.execute();
}
This is very fast and effective too.
Cheers
Varun Rathore
We can use sqllite databse for the offline display of data.
sqllite is just like mysql but it would create a *.db file in ur application folder
from where we can access the data.
A sample code for creating and executing the sqllite queries.
on creation complete we create a database contacts.
private function creationComplete():void
{
connection = new SQLConnection();
connection.open(File.applicationDirectory.resolvePath('contacts.db'));
var statement = new SQLStatement();
statement.text="CREATE TABLE IF NOT EXISTS contacts (ID INTEGER PRIMARY KEY AUTOINCREMENT, action TEXT, inputXML TEXT, outputXML TEXT)" ;
statement.sqlConnection=connection;
statement.execute();
var statement = new SQLStatement();
statement.text="CREATE TABLE IF NOT EXISTS offlineRequest (ID INTEGER PRIMARY KEY AUTOINCREMENT, action TEXT, inputXML TEXT)" ;
statement.sqlConnection=connection;
statement.execute();
}
This is very fast and effective too.
Cheers
Varun Rathore
Tuesday, February 26, 2008
Set "Loading" screen background color on Flex
Check out the compiler arguments line in the Flex properties and add
-default-background-color #PUTYOURCOLORHERE
Check the complete list compiler aurguments at :-
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=compilers_123_24.html
-default-background-color #PUTYOURCOLORHERE
Check the complete list compiler aurguments at :-
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=compilers_123_24.html
Labels:
background color,
Compiler Aurgument,
Loading Screen
Monday, February 25, 2008
Granite Data Services
Its free data service provided for the flex users which is alternative to
Life Cycle data service. I have tried remoting service and it runs with good
compatibility without much code change. It also support the data push by the flex.
we can download the binary from www.graniteds.org/ .
Cheers
Varun Rathore
Life Cycle data service. I have tried remoting service and it runs with good
compatibility without much code change. It also support the data push by the flex.
we can download the binary from www.graniteds.org/ .
Cheers
Varun Rathore
Tuesday, February 12, 2008
Localising And Resource Bundles in Flex 3.0
Handling resource bundles in flex 3.0 has improved a lot from the previous version.
you just need to add loacale{locale} folder in the source path of the application and have to keep the en_US or ja_JP (which ever language refrence you want to add)
then you will have to make sample.properties file in each of the language refrence folder
in properties file you will have to add
hello=Hello World
the properties which you need to access from the application(here i used hello property)
in the application we will use
we can make the mapping of the resource bundle dynamic with the following code.
add the code in the script of the application
[ResourceBundle("sample")]
[Bindable]
private var locales:Array = [ "en_US" , "fr_FR" ];
private function localeComboBox_initializeHandler(event:Event):void
{
localeComboBox.selectedIndex =
locales.indexOf(resourceManager.localeChain[0]);
}
private function localeComboBox_changeHandler(event:Event):void
{
// Set the localeChain to either the one-element Array
// [ "en_US" ] or the one-element Array [ "fr_FR" ].
resourceManager.localeChain = [ localeComboBox.selectedItem ];
}
initialize="localeComboBox_initializeHandler(event)"
change="localeComboBox_changeHandler(event)"/>
Change the -locale option to be
-locale=en_US,fr_FR
you just need to add loacale{locale} folder in the source path of the application and have to keep the en_US or ja_JP (which ever language refrence you want to add)
then you will have to make sample.properties file in each of the language refrence folder
in properties file you will have to add
hello=Hello World
the properties which you need to access from the application(here i used hello property)
in the application we will use
we can make the mapping of the resource bundle dynamic with the following code.
add the code in the script of the application
[ResourceBundle("sample")]
[Bindable]
private var locales:Array = [ "en_US" , "fr_FR" ];
private function localeComboBox_initializeHandler(event:Event):void
{
localeComboBox.selectedIndex =
locales.indexOf(resourceManager.localeChain[0]);
}
private function localeComboBox_changeHandler(event:Event):void
{
// Set the localeChain to either the one-element Array
// [ "en_US" ] or the one-element Array [ "fr_FR" ].
resourceManager.localeChain = [ localeComboBox.selectedItem ];
}
change="localeComboBox_changeHandler(event)"/>
Change the -locale option to be
-locale=en_US,fr_FR
Labels:
Flex 3.0,
Localising,
Resource Bundle,
Resourcr Manager
Thursday, February 7, 2008
Ant Scripting, Junit ,Flex
If you have any query regarding any of the flex data services , ant targets and Junit test cases
please feel free to contact me .
please feel free to contact me .
Subscribe to:
Posts (Atom)
About Me
- vrathore
- noida, dehli, India