Ciao a tutti...
ho a disposizione un esempio...( un componente BUTTON istanziato FerrariButton e un componente MENU) quando faccio clik sul bottone mi si apre un MENU che legge da xml dei dati....
ecco il codice
codice:
xmlMenu = new XML();
xmlMenu.ignoreWhite = true;
xmlMenu.onLoad = function (success){
if (success){
tofillMenu();
}
else{
trace("The XML could not be loaded");
}
}
xmlMenu.load("Menu.xml");
function tofillMenu(){
//Atach to master component 'Menu'
attachMovie("Menu", "myMenu", 1);
//We filled the menu
myMenu.dataProvider = xmlMenu.firstChild;
// Events
myMenu.addEventListener("change", listenerObject);
FerrariButton.addEventListener("click", myListenerObject);
LamborghiniButton.addEventListener("click", myListenerObject);
}
// Listener for button click; show menu
myListenerObject = new Object();
myListenerObject.click = function(eventTo){
//If click Button for Label Visitar Blog
if (eventTo.target == FerrariButton){
FerrariActivated = true;
LamborghiniActivated = false;
myMenu.removeMenuItemAt(1);
myMenu.addMenuItemAt(1, { label:"ferrari", selected:false, enabled:true} );
myMenu.show(_root._xmouse, _root._ymouse);
}
//If click Button for Label Lamborghini
else if (eventTo.target == LamborghiniButton){
FerrariActivated = false;
LamborghiniActivated = true;
myMenu.removeMenuItemAt(1);
myMenu.addMenuItemAt(1, { label:"primo", selected:false, enabled:true} );
myMenu.show(_root._xmouse, _root._ymouse);
}
}
//Listener for when we selected an option from Menu
listenerObject = new Object();
listenerObject.change = function(eventTo){
//If we have pressed the Ferrari button
if (FerrariActivated == true){
if (eventTo.menuItem.attributes.label == "To visit Web"){
getURL("http://www.html.it/", "_blank");
}
else if (eventTo.menuItem.attributes.label == "ferrari"){
getURL("http://www.html.it/", "_blank");
}
}
}
codice Menu.xml
codice:
<menu>
<menuitem type='separator' />
</menu>
Il menu legge la scritta "PRIMO" inserito da actionscript...con il link che punta a www.html.it...adesso io vorrei aggiungere altre scritte da actionscript con altri link...come si puoi sistemare il codice?
Grazie spero di essere stata chiara...