I'm using a modified version of the XML menu tutorial found on this site. Please see my code below:
function poulateFields():void {
txtHead.text = ourWork.Intro.head.text();
txtSub.text = ourWork.Intro.sub.text();
//This will be used to represent a menu item
var projectItem:ProjectItem;
//This will be used to represent all menu items in one MovieClip
var mcProjectList:Projects;
//Determine how many “Projects” there are….
var itemCount:int = ourWork.Projects.project.(“*”).length() – 1;
//…asign the value of the last “Project” to the childName variable.
var childName:String =
//Counter
var i:uint = 0;
//Current “y” position
var r:uint = 0;
var yy2:int = 0;
//Loop through the “projects” found in the XML file
for each (var project:XML in ourWork.Projects.project) {
projectItem = new ProjectItem();
//–
//Load a dynamic image from the XML file…
//Create a new Loader object
var imageLoader:Loader = new Loader();
//Call the Loader object's load() method, assigning the new URLRequest instance the url of the file.
imageLoader.load(new URLRequest(project.@image));
//Call the addChild() method on a display object container to add the Loader instance to the display list.
projectItem.mcWorkPic.addChild(imageLoader);
imageLoader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
function onInit(evt:Event) {
yy2 = evt.target.content.height;
//trace(yy2);
}
//–
projectItem.txtDesc.multiline = true;
projectItem.txtDesc.wordWrap = true;
//Assign the “link” value to the projectItem.launchURL variable
projectItem.link =
//Insert the “description” text (project.@description reads the link's “name” attribute)
projectItem.txtDesc.text =
//If the “description” is more than one line of text, the textfield will autosize down.
//We achieve this by setting a fixed width and left aligning the text field.
projectItem.txtDesc.autoSize = TextFieldAutoSize.LEFT;
projectItem.txtDesc.width = 290;
//Insert the Project Label onto the stage
projectItem.x = 5;
projectItem.y = r;
//Increment the “y” position of each subsequent project label based on the previous project label's text height (don't forget to add padding)
r+= projectItem.txtDesc.textHeight + 17;
//Display the dashed divider between each project based on the height of the previous project label's text OR image height (don't forget to add padding)
var yy1:int = projectItem.txtDesc.textHeight;
//var yy2:int = imageLoader.height;
//trace(yy1);
//trace(yy2);
projectItem.addEventListener(MouseEvent.CLICK, itemClick);
projectItem.mcWorkDivider.y = yy1 + 6;
//If the value of childName (esentially the last “Project”) matches the current ,
//it means it's the last displaying “Project”…
//therefore DON'T display the divider line “……………….” below it.
if (project.@description == childName) {
projectItem.mcWorkDivider.visible = false;
//trace(“I've found a match… ” + childName)
};
mcS.content.addChild (projectItem);
//Increment the menu button counter, so we know how many buttons there are
i++;
}
}
function itemClick(e:Event):void {
//Get the item that dispatched the event
var project:ProjectItem = e.target as ProjectItem;
//Navigate to the URL that is assigned to the menu item
var urlRequest:URLRequest = new URLRequest(project.link);
navigateToURL(urlRequest);
// var urlRequest:URLRequest = new URLRequest(e.target.link);
// navigateToURL(urlRequest);
// var item:ProjectItem = e.target as ProjectItem;
//
// var loader = new Loader();
// loader.load(new URLRequest(item.link));
// addChild(loader);
// var urlRequest:URLRequest = new URLRequest(item.t);
// navigateToURL(urlRequest);
//
// var targetURL:String = e.target.launchURL;
// var urlRequest:URLRequest = new URLRequest(targetURL);
// navigateToURL(urlRequest);
// var page:String =
// trace(targetURL);
}
I've tried various ways of the actioning the URLRequest (you can see them commented out in the function) all of which have failed and returned similar errors. Please help.