Monday, June 6, 2011

Change Locale at the runtime


http://cookbooks.adobe.com/post_Change_Locale_at_the_runtime-11143.html

Problem

You want to change the language of your flex application

Solution

Use ResourceBundle class and resourceManager method to change text and images at the runtime

Detailed explanation

The Application:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    creationComplete="{init()}"
    xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
    viewSourceURL="srcview/index.html">
    <mx:Script>
        <![CDATA[
            import it.creativesource.ResourceLanguage;
            private function init():void{
               
                ResourceLanguage.setResources(resourceManager);
            }
            private function changeLocale(locale:String):void{
           
                resourceManager.localeChain=[locale];
            }
        ]]>
    </mx:Script>
    <mx:ApplicationControlBar width="400">
        <mx:Image source="{resourceManager.getString('myResources','ICON')}" width="16" height="11"/>
        <mx:Label text="{resourceManager.getString('myResources','TITLE')}"  width="100%"/>
        <mx:Button icon="@Embed('assets/us.png')" label="eng" click="changeLocale('en_US')" />
        <mx:Button icon="@Embed('assets/it.png')" label="ita" click="changeLocale('it_IT')" />
    </mx:ApplicationControlBar>
   
    <mx:Text text="{resourceManager.getString('myResources','CONTENT')}"  width="400" height="240"/>
</mx:Application>
 


The ResourceLanguage class:

package it.creativesource
{
 import mx.resources.IResourceManager;
 import mx.resources.ResourceBundle;
 
 public class ResourceLanguage
 {
  public function ResourceLanguage()
  {
  }
  
  public static function setResources(resourceManager:IResourceManager):void{
   
   
   var myResources:ResourceBundle=new ResourceBundle("en_US","myResources");
   myResources.content['TITLE']="Adobe Flex - English Version";
   myResources.content['CONTENT']="Adobe Flex is a collection of technologies released by Adobe Systems for the development and deployment of cross platform rich Internet applications based on the proprietary Adobe Flash platform. The initial release in March 2004 by Macromedia included a software development kit, an IDE, and a J2EE integration application known as Flex Data Services. Since Adobe acquired Macromedia in 2005, subsequent releases of Flex no longer require a license for Flex Data Services, which has become a separate product rebranded as LiveCycle Data Services.";
   myResources.content['ICON']="assets/us.png";
   resourceManager.addResourceBundle(myResources);
   
   
   myResources=new ResourceBundle("it_IT","myResources");
   myResources.content['TITLE']="Adobe Flex - Versione Italiana";
   myResources.content['CONTENT']="Adobe Flex è un insieme di tecnologie rilasciato da Adobe Systems per lo sviluppo e la diffusione del multi-piattaforma Rich Internet Applications basata sulla proprietà di Adobe Flash piattaforma. The initial release in March 2004 by Macromedia included a software development kit , an IDE , and a J2EE integration application known as Flex Data Services . La release iniziale nel marzo 2004 da Macromedia incluso un kit di sviluppo software, un IDE, e un J2EE integrazione domanda noto come Flex Data Services. Since Adobe acquired Macromedia in 2005, subsequent releases of Flex no longer require a license for Flex Data Services, which has become a separate product rebranded as LiveCycle Data Services. Dato che Adobe ha acquisito Macromedia nel 2005, le successive versioni di Flex non necessitano più di una licenza per Flex Data Services, che è diventato un prodotto separato come rebranded LiveCycle Data Services.";
   myResources.content['ICON']="assets/it.png";
   resourceManager.addResourceBundle(myResources);
     
   resourceManager.update();
   
  }
 }
}

Thursday, April 28, 2011

Differences between invalidateList and invalidateDisplayList


invalidateList -tells the component that the data has changed, and it needs to reload it and re-render it.
invalidateDisplayList - tells the component that it needs to redraw itself (but not necessarily reload its data).

Flex Blogs

Getting Started with Maven Flex


What is Maven?
Maven is java tool for project management and build automation based on concept of POM(Project Object Model).
  • Maven projects are configured using POM, stored in pom.xml.
  • Maven project needs some coordinates to allow it to be identified by other Maven projects. These are called the group ID, artifact ID, and version
What is groupId?
groupId is a unique identifier of the group that created project, typically it is fully qualified name of the organization.
What is artifactId?
artifactId is unique base name of the primary artifact being generated by this project. A typical artifact produced by Maven would have the form <artifactId>-<version>.<extension> (for example, myapp-1.0.jar).
What is Archetype?
Archetype is a maven set of template projects.
Creating a Maven Flex Project:
Executing the command mvn archetype:generate will generate a project and pom file from the predefined template project.
After Executing the command on command line following screen is shown to select the one of the template project, version, groupId, artifactId of the created project.
A project will be created with the following structure:
my-app
|-- pom.xml
`-- src
    |-- main
    |   `|-- flex
    |    |  `-- Main.mxml
    |    |-- resources
    `-- test
        `-- flex
            `-- com
                `-- mycompany
                    `-- TestApp.as

POM:
<project>
  <!-- model version is always 4.0.0 for Maven 2.x POMs -->
  <modelVersion>4.0.0</modelVersion>

  <!-- project coordinates, i.e. a group of values which uniquely identify this project -->

  <groupId>com.mycompany</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0</version>
  <packaging>swf</packaging>
  <!-- library dependencies -->

  <dependencies>
      <dependency>
            <!-- coordinates of the required library -->
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>flex-framework</artifactId>
            <version>3.2.0.3958</version>
            <type>pom</type>
       </dependency>
       <dependency>
            <!-- this dependency is only used for running and compiling tests -->
            <groupId>com.adobe.flexunit</groupId>
            <artifactId>flexunit</artifactId>
            <version>0.85</version>
            <type>swc</type>
            <scope>test</scope>
       </dependency>
  </dependencies>
  <build>
    <sourceDirectory>src/main/flex</sourceDirectory>
    <testSourceDirectory>src/test/flex</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.sonatype.flexmojos</groupId>
        <artifactId>flexmojos-maven-plugin</artifactId>
        <version>3.8</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
 <profiles>
    <profile>
      <id>m2e</id>
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <artifactId>maven-resources-plugin</artifactId>
              <version>2.4</version>
            </plugin>
          </plugins>
        </pluginManagement>
        <plugins>
          <plugin>
            <groupId>org.maven.ide.eclipse</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>0.9.9-SNAPSHOT</version>
            <configuration>
              <mappingId>customizable</mappingId>
              <configurators>
                <configurator id="org.maven.ide.eclipse.configuration.flex.configurator" />
              </configurators>
              <mojoExecutions>
                <mojoExecution>org.apache.maven.plugins:maven-resources-plugin::</mojoExecution>
              </mojoExecutions>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
 </project>
Ref:

Visit :http://subhash85.wordpress.com/ 

Wednesday, April 27, 2011

FlexLib project

FlexLib is a wonderful library . U can find the usage in many places while u code. Visit the link below and see the examples and experience it . Happy Flexing ...

http://code.google.com/p/flexlib/wiki/ComponentList

Saturday, April 9, 2011

I Love Flex

Adobe® Flex® is a highly productive, free, open source framework for building expressive web applications that deploy consistently across browsers, desktops, and operating systems by leveraging the Adobe Flash Player and Adobe AIR® runtimes.



Adobe has announced the following new technologies and initiatives, which are now available to explore, download and try on Adobe Labs: