Friday, 22 June 2012

Flex Mobile read XML files


1. Declare the variables


private var myXML:XML;
private var XML_URL:String ="https://sites.google.com/site/way2db1/oca/create.xml";
private var myXMLURL:URLRequest;
private var myLoader:URLLoader;



2. In the required function, implement this logic:

myXML = new XML();
myXMLURL = new URLRequest(XML_URL);
myLoader = new URLLoader(myXMLURL);
myLoader.addEventListener(Event.COMPLETE, xmlLoaded);

Note: Mostly done in init().

3. All the stuff which you wanted to do after loading the XML, place the code in xmlLoaded().


4. Parsing XML


Here is my XML
<root>
<base id="1">
  <empno></empno>
  <ename></ename>
</base>

<base  id="2">
  <empno></empno>
  <ename></ename>
</base>
</root>


a)  To find the no of main nodes in an XML, use
                myXML.base.length();


b) To find the empno from the XML, use
                myXML.base[0].empno;
                myXML.base[1].empno;


c) To work on base node 1, use
               var xmlList:XMLLIST = myXML.base.(@id="1");


Flex Mobile Generate APK

You have created your App, Next step is to Run it on your mobile.

1. Right Click on the Project , Select EXPORT.
2. Flash Builder > Release Build.
3. Enter a path in the "Export to Folder".
4. If you get any Warning Ignore them, they wont cause any problems.
5. You need a certificate, Click On DIGITAL SIGNATURE tab.
6. Click on Create Button
7. Enter your name and Password.
8. Click on Finish button.

How to Resize an Image using Paint.

You can resize an Image using Paint in Windows.

1. Open the Image in Paint.
2. Using Save AS, save the image with your target name.
3. You will have an Resize option in the TAB bar of the Paint. Click on it.
4. Enter your required size in the second tab of the Popup. Use scale than mertrices.
5. Save the Image.

How to Add image to my App

Every Flex Mobile Project has a file as <Project Name>-app.xml


1. Open the File.


2. Search for <icon> tag. This will be commented.
             <icon>
              <image16x16></image16x16>
              <image32x32></image32x32> 
                          - - - - -
              <image128x128></image128x128>
           </icon>


3. Get prepared with your logos.. Prepare 3 logos of sizes 16x16, 32x32, 128x128.
          If you are not aware of resizing the logo, click here. 2 steps process using Paint.


4. Copy the images/ logos to the Project Directory. Remote access is not possible since these logos are mandatory are they are going to be appeared as the Face of your app.


5. Save the file and Export.
     


Note:  If the logos are not of equal size, you will be getting an Error Message.