Hi,
I successfully create XML menu and adding MouseEvent in each item and associate it with its content. My problem is that, how to load the first content in the stage without having to click the button?
public function xmlLoaded(e:Event):void {
if ((e.target as URLLoader) != null ) {
//Insert the loaded data to our XML variable
_btnLabels = new XML(e.target.data);
_btnLabels.ignoreWhitespace = true;
init();
}
}
private function init():void {
var i:int = 0;
for each (var section_name:XML in _btnLabels.sections.section){
var b:MovieClip = new butt();
//trace(i);
b.id = i;
b.content =_btnLabels.sections.section.section_content*;
addChild(b);
_allButt.push();
b.buttonMode = true;
b.mouseChildren = false;
b.addEventListener(MouseEvent.MOUSE_OVER, RollOver);
b.addEventListener(MouseEvent.MOUSE_OUT,RollOut);
b.addEventListener(MouseEvent.CLICK,onClick);
i++;
}
}
private function onClick (e:MouseEvent):void {
//enable disable button
var btn = e.currentTarget;
btn.mouseEnabled = false;
btn.buttonMode = false;
btn.alpha = 0.70;
lastClicked.mouseEnabled = true;
lastClicked.buttonMode = true;
lastClicked.alpha = 1;
lastClicked = btn;
dispatchEvent(e);
}
public function set content(loadedContent:String):void {
for (var btn in _btns) {
_btns[btn].content = loadedContent;
}
}