Thursday, April 17, 2008

mx:ColorPicker set color, convert uint to string of selectedColor

If you are working with <mx:ColorPicker /> in flex and assuming the following are your requirements:

a) You want to set the colorpicker to some color

b) working with selectedIndex, selectedColor

c) you want to store the selectedColor of the color picker as a String in your database and convert the stored String value to set it back to colorpicker so you can set the color to the color picker (<mx:colorpicker>), here you go:

Assuming you have two color pickers and you want to set the color picker value of 'cp' to 'newcp'

   <mx:ColorPicker id='cp'/>
   <mx:ColorPicker id='newcp' />

if you do {cp.selectedIndex} in your action script code, it will return you an int value which is equal to the index number of the palette. Every color has a index number, the default value=0.

    var cpSelectedIndexStr:String = cp.selectedIndex.toString();
    newcp.selectedIndex = int(cpSelectedIndexStr);

if you do {cp.selectedColor} in your action script code, it will return you a uint value. The following code will NOT work -

   var cpSelectedColorStr:String = cp.selectedColor.toString();
   newcp.selectedColor = uint(cpSelectedColorStr);

The following code will work -

   var cpSelectedColorStr:String = cp.selectedColor.valueOf().toString();
   newcp.selectedColor = uint(cpSelectedColorStr);

This is a very basic conversion funda.. hope you get it...

Monday, March 31, 2008

AIR & LCDS - How do they work together?

,,,

Its easy to get started with Flex App and LCDS (i assume you know how to).. Use Flex Builder and create a J2EE Project with Remoting enabled. Use the LCDS setup install path for the context root in your dialog and set up the project.

Typically if you make a Flex Application you would ensure that your output directory of the generated SWF lies in the folder location inside the /flex directory or /samples/ directory of your flex application. Relevant config files have to be picked up ... I will describe the configuration files here in brief about LCDS:

-> service-config.xml - Main xml file that includes the below xml files and references them
-> remoting-config.xml - Used for writing destinations of Java/AS mappings using mx:RemotObject
->proxy-config.xml - Used for writing destinations for mx:HTTPServlet/mx:WebService
-> messaging-config.xml - Used to write destinations for mx:MessageProducer, mx:MessageConsumer
->data-management-config.xml - for DataService, fill operations

All these files reside in : C:\lcds\jrun4\servers\default\flex\WEB-INF\flex (On Windows) and /home/username/lcds/jrun4/servers/default/flex/WEB-INF (On Linux) (All this if you are running LCDS 2.5.1)

Using Flex Builder, You can Create an AIR Project with J2EE, LCDS Enabled for the project. So what happens? Your subscription to destinations may not work!! The same stuff on Flex Project works fine. So how do you rectify it?

AIR Projects need some extra settings in-order to work with LCDS -

A) Copy the services-config.xml from the above locatoin on the server to your project 'src' directory.
B) Raneme the copied file as 'custom-services-config.xml'
C) Open the menu in flex builder, Project->Properties
D) Go to the Compiler settings and you will find that the 'services-config.xml' need to be modified to include this one in the new path. i.e., set it as 'custom-services-config.xml'
E) Open the custom-services-config.xml file and look at your default channel (protocol). If you are using 'my-polling-amf' or 'my-rtmp', ensure that you remove the dummy 'http://{server-name}:port' and change it to 'http://localhost:portnumber or http://ip-address:portnumber' (similarly rtmp://{server-name}:port' to rtmp://localhost:portnumber or rtmp://ipaddress:portnumber)
F) Ensure that you have set your Default Channel accordingly as you altered.
G) Also, along with the custom-services-config.xml you would need remoting-config.xml, messaging-config.xml, data-management-config.xml. Copy them all to your local project src directory.
H) Ensure that you write all your destinations two times. One in the local copied files (related config file), and the remotely available config files.

Most problems related to changing of Protocol in LCDS occur due to "NOT CLEANING the Project and re-compiling it". As you change the compiler properties to include custom-services.config.xml, you would have already enabled auto-compile option. So this change will not recompile it unless you make changes to your app. So Ensure that you clean your project and recompile it.

Tuesday, March 25, 2008

Compiling and Running an AIR application on Linux (using sdk)

"Compiling and Running an AIR application on Linux (using sdk) is same as how you do it on Windows". If you have Flex Builder, you dont have to worry about this. BTW, this post is only for beginners on AIR. If you want to compile and run the app using the sdk (terminal on linux, cmd on windows), Here is how you do that.

a) Get the SDK downloaded to a locatoin (ex: /home/username/flexsdk/)
b) If you are installing Flex Builder Linux Alpha 3 (to be released in labs around 31 March), you have an inbuilt sdk in your install location (ex: $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0)
c) Use the "amxmlc" - AIR MXML compiler present in your sdK (ex: $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/amxmlc)
d) Assuming you have created an AIR MXML Application with its application properties file AIR XML file. (locatoin ex: /home/username/AIRApps/FirstAirApp/MyApp.mxml, MyApp-app.xml)
e) You will have to find AIR runtime directory (if you have installed Flex Builder on Linux alpha 3, Then runtime directory = $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/runtimes/air/Linux),
e) Open your Terminal (cmd prompt on windows)


To Compile your MXML File

f) $localhost@terminal>"$INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/bin/amxmlc" <space> /home/username/AIRApps/FirstAirApp/MyApp.mxml
g) It will generate a SWF file with the same name in your directory (from where you are compiling)

Configure your *-app.xml to point it to the generated SWF
h) Open the application descriptor file "/home/username/AIRApps/FirstAirApp/MyApp-app.xml" (either in vi editor or in text editor), Find the string "[This value will be overwritten by Flex Builder in the output app.xml]" with in the tags <content> nested inside <initialWindow>. Remove the string present in the <content>...</content> and replace it with the path to the SWF file generated after you have compiled it. (example: <content>/home/username/....../Myapp.swf</content>). Save the file.

Running your air app:
i) In Your terminal run the command :
localhost@username> $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/bin/adl_lin <space> -runtime <space> $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/runtimes/air/Linux <space> /home/username/AIRApps/FirstAirApp/MyApp-app.xml

There you go... Your AIR App is launched for you.

PS:Please note that AIR Runtime (packaging/installing air apps etc.) does not come with Flex Builder Linux installation. You can get AIR Runtime for Linux on labs once again.


Wednesday, March 19, 2008

Flex Builder Linux - Alpha3

The Alpha3 version of Flex Builder for Linux is gonna hit the public users on LABS.ADOBE.COM around March 31th 2008. So what would it comprise of?

As the version still stays at alpha, dont expect really much. No Design View as yet. But yet, something exciting to speak - Support for AIR in flex builder.. plus some bug fixes...

Hope you will like the addition of AIR and provide us your feedback as always...

Wednesday, December 19, 2007

FBLinux Alpha2 Installer on 64bit Linux OS

The installer of Flex Builder Linux Alpha2 is modified slightly to help people trying it out on 64Bit OS. We need to download 32Bit Eclipse, 32Bit Sun JRE and 32bit Firefox for the installation to go successful.

If you are starting the installer on a 64bit OS - (It shows this OS Check message)


If you launch the installer with 64bit Sun JRE - (it exits with this message)

If you choose 64Bit Eclipse while selecting the eclipse path then it throws the below error and exits.

Also note that you will need to install Flash Player debug player manually by copying the libflashplayer.so file into the downloaded version of 32bit Firefox on your 64bit machine.


Tuesday, December 18, 2007

How to Serialize your DataVisualization Trials (Charting, ADG, ODG, PADG etc.)

It is a commonly asked question on how do i serialize Datavisualization Trials that are available bundled with Flex Builder Linux Alpha 2.

You can get your Windows Flex Builder Beta 3 serial and plug-it into Flex Builder Linux to get it serialized. This may be a temporary thing for now but it might change as it goes ahead...

Open the file $HOME/.adobe/Flex/license.properties
Add a new line - flexbuilder3=XXXX-YYYY-ZZZZ-blabla...

Save the file and see your DMV Trial water mark is no more...

Flex Builder Linux Alpha 2 Available...

Flex Builder Linux alpha 2 is available in Labs... http://labs.adobe.com/technologies/flex/flexbuilder_linux/ You can look at the release notes here - http://labs.adobe.com/technologies/flex/flexbuilder_linux/releasenotes.html

This release is more of a Alpha 1 Refresh where in not major features were added to it. Work is still going on to support some of the really requested features. This release however has addition to some of the new features like, Flash player r115 debug player update, Installer enhancements for better messaging in 64bit OS (doesnt natively support 64bit apps though!)..JSEclipse plugin installation, Bug Fixes which were prolonging from long time, DataVisualization Trials embedded....

All set for your Flex works to keep going on and on... Hope you liked it...