TypeError: Error#1090: XML parser failure: element is malformed.

New Here ,
Feb 09, 2011 Feb 09, 2011

Copy link to clipboard

Copied

So I'm trying to make a Vertical 3D Carousel using Flash CS3, ActionScript 3, a program called TweenMax, and some XML. The site I got a tutorial from is a dead site, so no help there.

Here's the error I'm getting:

TypeError: Error #1090: XML parser failure: element is malformed.
    at outrageouslycooltitlescreennoerrors_fla::MainTimeline/xmlLoaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

And here's the actionscript I have:

//Import TweenMax
import gs.*;

//Path to the XML file
var xmlPath:String = "http://download139.mediafire.com/ugg079ku9srg/7h8ki2fbhti272b/cookies.xml";

//Storing XML file in a variable
var xml:XML;

//Create a loader and load the XML; when finished, call the function xmlLoaded
var loader = new URLLoader();
loader.load(new URLRequest(xmlPath));
loader.addEventListener(Event.COMPLETE, xmlLoaded);

//Call the function
function xmlLoaded(e:Event):void {
   
    //Make sure the variable is not null
    if ((e.target as URLLoader) != null ) {
       
        //Create a new XML object with loaded XML data
        xml = new XML(loader.data);
       
        //Call the function that creates the menu
        createMenu();
       
    }
   
}

//Need to know how many items are on the stage
var numberOfItems:uint = 0;

//Array that contains all menu items
var menuItems:Array = new Array();

//Set the focal length
var focalLength:Number = 350;

//Set the vanishing point
var vanishingPointX:Number = stage.stageWidth / 2;
var vanishingPointY:Number = stage.stageHeight / 2;

//Calculate the angleSpeed in the ENTER_FRAME listener
var angleSpeed:Number = 0;

//Radius of the circle
var radius:Number = 128;

//This function creates the menu
function createMenu():void {
   
    //Get the number of menu items we will have
    numberOfItems = xml.items.item.length();
   
    //Calculate the angle difference between the menu items in radians
    var angleDifference:Number = Math.PI * (360 / numberOfItems) / 180;
   
    //Use a counter to see how many menu items have been created
    var count:uint = 0;
   
    //Loop through all the <button></button> nodes in the XML
    for each (var item:XML in xml.items.item) {
       
        //Create a new menu item
        var menuItem:MenuItem = new MenuItem();
       
        //Calculate the starting angle for the menu item
        var startingAngle:Number = angleDifference * count;
       
        //Set a "currentAngle" attribute for the menu item
        menuItem.currentAngle = startingAngle;
       
        //Position the menu item
        menuItem.xpos3D = 0;
        menuItem.ypos3D = radius * Math.sin(startingAngle);
        menuItem.zpos3D = radius * Math.cos(startingAngle);
       
        //Calculate the scale ratio for the menu item; the further the item, the smaller the scale ratio
        var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
       
        //Scale the menu item according to the scale ratio
        menuItem.scaleX = menuItem.scaleY = scaleRatio;
       
        //Position the menu item to the stage (from 3D coordinates to 2D coordinates)
        menuItem.x = vanishingPointX + menuItem.xpos3D * scaleRatio;
        menuItem.y = vanishingPointY + menuItem.ypos3D * scaleRatio;
       
        //Add text to the menu item
        menuItem.menuText.text = item.label;
       
        //Add a "linkTo" variable for the URL
        menuItem.linkTo = item.linkTo;
       
        //Tell the text field to not catch mouse events
        menuItem.mouseChildren = false;
       
        //Assign MOUSE_OVER, MOUSE_OUT, and CLICK event listeners for the menu item
        menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
        menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
        menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
       
        //Add the menu item to the menu items array
        menuItems.push(menuItem);
       
        //Add the menu item to the stage
        addChild(menuItem);
       
        //Assign an initial alpha
        menuItem.alpha = 0.3;
       
        //Add some blur to the item
        TweenMax.to(menuItem,0, {blurFilter:{blurX:1, blurY:1}});
       
        //Update the count
        count++;
       
    }
   
}

//This function is called when a mouse is over an item
function mouseOverItem(e:Event):void {
   
    //Tween the item's properties
    TweenMax.to(e.target, 0.1, {alpha: 1, glowFilter: {color:0xffffff, alpha:1, blurX:60, blurY:60}, blurFilter: {blurX:0, blurY:0}});
   
}
   
//This function is called when a mouse is out of an item
function mouseOutItem(e:Event):void {
   
    //Tween the item's properties
    TweenMax.to(e.target, 1, {alpha: 0.3, glowFilter:{color:0xffffff, alpha:1, blurX:0, blurY:0},blurFilter:{blurX:1, blurY:1}});
   
}

//This function is called when an item is clicked
function itemClicked(e:Event):void {
   
    //Navigate to the URL that's assigned to the menu item
    var urlRequest:URLRequest=new URLRequest(e.target.linkTo);
    navigateToURL(urlRequest);
   
}

//Add an EVENT_FRAME listener for the animation
addEventListener(Event.ENTER_FRAME, moveCarousel);

//This function is called in each frame
function moveCarousel(e:Event):void {
   
    //Calculate the angle speed according to mouseY position
    angleSpeed = (mouseY - stage.stageHeight / 2) * 0.0002;
   
    //Loop through the menu items
    for (var i:uint = 0; i < menuItems.length; i++) {
       
        //Store the menu item to a local variable
        var menuItem:MenuItem = menuItems as MenuItem;
       
        //Update the current angle of the item
        menuItem.currentAngle += angleSpeed;
       
        //Calculate a scale ratio
        var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
       
        //Scale the item according to the scale ratio
        menuItem.scaleX=menuItem.scaleY=scaleRatio;
       
        //Set new 3D coordinates
        menuItem.xpos3D=0;
        menuItem.ypos3D=radius*Math.sin(menuItem.currentAngle);
        menuItem.zpos3D=radius*Math.cos(menuItem.currentAngle);
       
        //Update the item's coordinates
        menuItem.x=vanishingPointX + menuItem.xpos3D*scaleRatio;
        menuItem.y=vanishingPointY + menuItem.ypos3D*scaleRatio;
       
    }
   
    //Call the function that sorts the items so they overlap each other correctly
    sortZ();
   
}

//This function sorts the items so they overlap each other correctly
function sortZ():void {
   
    //Sort the array so that the item which has the highest
    //z position (= furthest away) is first in the array
    menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
   
    //Set new child indexes for the item
    for (var i:uint = 0; i < menuItems.length; i++) {
        setChildIndex(menuItems, i);
       
    }
   
}

TOPICS
ActionScript

Views

7.9K

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Feb 09, 2011 Feb 09, 2011
the problem is in your xml file.

Likes

translate

Translate

Translate
Adobe Community Professional ,
Feb 09, 2011 Feb 09, 2011

Copy link to clipboard

Copied

the problem is in your xml file.


Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 14, 2011 Feb 14, 2011

Copy link to clipboard

Copied

Okay, so I fixed a syntax error or two in my XML file, but now when I play the flash animation, it's just a blank black stage. Is something wrong with the actionscript that places the menu items on the stage?

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 14, 2011 Feb 14, 2011

Copy link to clipboard

Copied

use the trace() function to make sure your items are being added to the display list.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines