Air menu du haut (menubar)



Pour afficher un menu en haut de l'application, il suffit d'ajouter un objet MenuBar, le chargement de ce menu peut se faire en xml ou avec un tableau.

Exemple:

Le fichier mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()" >
<mx:Script source="dean.as"/>
</mx:WindowedApplication>


Le fichier src/dean.as

import mx.controls.MenuBar;
import mx.events.MenuEvent;

public var listeMenuHaut:Array = [
{label: "Menu1", children: [
{label: "Choix 1"},
{label: "Choix 2"}
]},
{label: "Menu2", children: [
{label: "Choix 1"},
{label: "Choix 2"}
]}
];

private var menuHaut:MenuBar = new MenuBar();
private   function init():void{
menuHaut.dataProvider=listeMenuHaut;
menuHaut.tabEnabled=false;//alignement droit
addChild(menuHaut);
}