This is a 2 parter:
I’m dynamically listing menus from an xml file which pulls out an swf file and loads it in. If there’s a text in the XML I want to overlay the text over the menu that’s being loaded. The reason I’m might have text and might not is because there’s a lot of dynamic content, menus, blah, blah, blah, so one button rather than making 1000.
Anyhoo, I can load the button, I can load the text over it, but immediately the button is no longer seelctable:
- Secondly, the swf are being loaded externally and have event listeners for mouse over and mouse out. When they’re loaded, I have a heck of a time declaring a mouse click event. I get errors all over the place. Here’s the main section code:
// Create a new movie clip and load the image
var load_file:URLRequest = new URLRequest( data_directory + menus[j].attribute("image") );
var load_menu:Loader = new Loader();
load_menu.x = int(menus[j].attribute("x"));
load_menu.y = int(menus[j].attribute("y"));
load_menu.name = int(j);
load_menu.load(load_file);
addChild( load_menu );
//---------------------------------------------//
//
// Add an onLoad handler to resize the text
//
//---------------------------------------------//
load_menu.contentLoaderInfo.addEventListener(Event.COMPLETE,
function(event:Event):void {
// Get the name so we know where to go
var menu:Loader = Loader(event.target.loader);
j = menu.name;
//---------------------------------------------//
//
// Add text to the button if necessary
//
//---------------------------------------------//
if( menus[j].text().length() > 0 ){
// Convert the margin top into an offset for placement of text
if( menus[j].attribute("margin_top") != "" ){
offset = menus[j].attribute("margin_top");
} else {
offset = 0;
}
trace( event.target.content.width + " " + event.target.content.height );
// Create the text field
menu_text_item = new TextField();
menu_text_item.name = menus[j].name() + "_text";
menu_text_item.x = int(menus[j].attribute("x"));
menu_text_item.y = (int(int(menus[j].attribute("y"))) + int(offset));
menu_text_item.width = event.target.content.height - int(offset);
menu_text_item.height = event.target.content.width;
menu_text_item.width = event.target.content.width;
menu_text_item.height = event.target.content.height;
menu_text_item.multiline = false;
menu_text_item.wordWrap = true;
menu_text_item.selectable = false;
menu_text_item.background = false;
menu_text_item.border = Boolean( int(menus[j].attribute("border")) );
menu_text_item.borderColor = "0x" + menus[j].attribute("borderColor");
menu_text_item.text = menus[j].text();
// Format the styling of text field
menu_text_format = new TextFormat();
menu_text_format.align = menus[j].attribute("align");
menu_text_format.font = menus[j].attribute("font");
menu_text_format.size = int(menus[j].attribute("size"));
menu_text_format.color = "0x" + menus[j].attribute("color");
menu_text_format.bold = Boolean(int(menus[j].attribute("bold")));
menu_text_format.italic = Boolean(int(menus[j].attribute("italic")));
menu_text_format.leftMargin = menus[j].attribute("margin_left");
//Apply the formatting
menu_text_item.setTextFormat(menu_text_format);
// Add the text field
addChild(menu_text_item);
//if
}
//---------------------------------------------//
}
);
//---------------------------------------------//
//---------------------------------------------//
//
// Add an onClick handler to goto the submenu
//
//---------------------------------------------//
load_menu.addEventListener(MouseEvent.CLICK,
function(event:MouseEvent):void {
// Get the name so we know where to go
var menu:Loader = Loader( event.target.parent );
trace( menu );
/*
// Load the Sub Menu
//Build_Menu( menus[j].name() );
*/
}
);
Here’s the external code.
addEventListener(MouseEvent.ROLL_OVER,
function(event:MouseEvent):void {
textTab_mc.gotoAndPlay(2);
}
);
addEventListener(MouseEvent.ROLL_OUT,
function(event:MouseEvent):void {
textTab_mc.gotoAndPlay(8);
}
);
Sooooo, any thoughts?