flex builder + air un exemple simple

Flash, c'est un langage d'animation, son développement se fait avec une bonne connaissance de l'interface de création.
Flex, c'est du flash "amélioré", on y ajoute une touche RIA, son développement se fait en mxml pour la partie graphique et actionscript pour le code.
AIR, c'est du flex version desktop et multi-plateforme avec des API permettant d'améliorer la communication avec le pc.

Flash=>animations
Flex=>animations web2
AIR=>Logiciel web2



Exemple simple d'application AIR sur flex builder 3



File => new Flex project => (Project name = testAir) (Application type= Desktop application)

Fichier src/testAir.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
creationComplete="init()"
title="Simple application de bureau">
<mx:Script source="dean.as"/>
</mx:WindowedApplication>


Ajouter un fichier src/dean.as
import flash.events.MouseEvent;

import mx.controls.Button;
private var btn:Button = new Button();
private function init():void{
btn.label='Cliquer ici';
btn.addEventListener(MouseEvent.CLICK,clic);
addChild(btn);
}
private function clic(e:MouseEvent):void{
btn.label='bravo';
}


Compilez (Ctrl F11)
Voilà c'est tout

Code source:
http://www.progs.fr/exemple/08102001/index.html

Essayez de remplacer le code de dean.as par le suivant

import flash.events.Event;
import flash.filesystem.File;

import mx.controls.FileSystemComboBox;
import mx.controls.TextInput;

private var arborescence:FileSystemComboBox = new FileSystemComboBox();
private var zoneTexte:TextInput = new TextInput();

private function init():void{
arborescence.directory=File.desktopDirectory;
arborescence.addEventListener(Event.CHANGE,afficherLien);
addChild(arborescence);
addChild(zoneTexte);
}
private function afficherLien(e:Event):void{
zoneTexte.text=arborescence.directory.nativePath;
arborescence.directory=File.desktopDirectory;
}


Cela affiche une arborescence...


Quelques liens :
http://www.adobe.com/devnet/air/flex/quickstart/
http://actionscriptcheatsheet.com
http://actionscriptcheatsheet.com/pdf/AIRcheatsheet.pdf
http://codemoiunmouton.wordpress.com/category/air/