I have this XML menu and my main problem is that I have to place the text elements each one of them into a movieclip in order to make the handcursor work.
The XML menu is made by this function
function xmlLoaded(event:Event):void {
xml=XML(event.target.data);
xmlList=xml.children();
for (var i:int =0; i<xmlList.length(); i++) {
// for the first element there is no previous textfield inserted
if (i==0) {
createMainText(xmlList*.attribute("title"), xmlList*.attribute("link") , mainLinkLeftMargin , 8, 0 );
createSublinks(xmlList,i);
} else {
// Create the text field getting positioning setting form the previous textField inserted
createMainText(xmlList*.@title, xmlList*.attribute("link") , stage.getChildByName("mainLink"+(i-1).toString()).width +
stage.getChildByName("mainLink"+(i-1).toString()).x + subLinkPadding, 8 , i );
createSublinks(xmlList,i);
}
}
and then i have the function that formats the text
function createMainText(mainText:String, mainLink:String, xPosition:Number, yPosition:Number, indexNumber:Number):void {
var dynText:TextField = new TextField();
stage.addChild(dynText);
dynText.selectable=false;
dynText.name="mainLink"+indexNumber.toString();
dynText.embedFonts=true;
dynText.text=mainText;
// tried to use this code but it doesn't seem to work
var MC_text = new MovieClip();
MC_text.buttonMode=true;
MC_text.useHandCursor=true;
MC_text.mouseChildren = false;
stage.addChild(MC_text);
dynText.setTextFormat(textFormatMain);
MC_text.addChild(dynText);
// cause it seems it nests only the first text element of the XML file
dynText.addEventListener(MouseEvent.MOUSE_OVER, subLinksShow);
dynText.addEventListener(MouseEvent.MOUSE_OVER, buttonModeTrue);
dynText.addEventListener(MouseEvent.MOUSE_OUT, buttonModeFalse);
stage.getChildByName("mainLink"+indexNumber.toString()).
addEventListener(MouseEvent.CLICK, CallArg.create(gotoSub, mainLink));
My question is where i should put this
var MC_text = new MovieClip();
MC_text.buttonMode=true;
MC_text.useHandCursor=true;
MC_text.mouseChildren = false;
stage.addChild(MC_text);
dynText.setTextFormat(textFormatMain);
MC_text.addChild(dynText);
in order to place each textfield into an identical Movieclip and make it behave like a button?:puzzled: