TwelvestoneFlash

AS3 won't load my XML


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
DontBogartMe
 
2008-11-11

this is driving me batty, hopefully I've just overlooked something simple, but I can't see it.

package test_website {

import flash.display.*; 
import flash.events.*;
import flash.net.*;

public class TestWebsite extends MovieClip {

    private var ldrWorldMapXML:Loader = new Loader();

    public function TestWebsite() {

        trace("LOAD THE DAMN XML");

        ldrWorldMapXML.addEventListener(Event.COMPLETE, processWorldMapXML);            
        ldrWorldMapXML.load(new URLRequest("map.xml"));

        trace("ARE YOU LOADING YET?");
    }

    private function processWorldMapXML(e:Event):void {

        trace("DONE IT OH YES DONE IT!");

    }
}   

}

this was part of more complex code that I've stripped right down to just trying to load the XML to try to trace it, but the Event.COMPLETE is just not happening.

The XML is valid, it opens up fine in browsers.

All it traces out is this:

LOAD THE DAMN XML ARE YOU LOADING YET?

it nevers gets to DONE IT OH YES DONE IT!

Can someone shine a light on this please?

DontBogartMe
 
2008-11-11

it never fails, waste ages looking, post on 12S in fury, then fix it 5 mins later.

Don't use Loader - use URLLoader dumass.

Storm
 
2008-11-11

You need to declare an XML Object as well, I think otherwise it's a String. That was part of my understanding in our other thread.

dataXML = XML(ldrWorldMapXML.data);

package as3 {

import flash.display.MovieClip;
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.xml.XMLDocument;

public class Portal extends MovieClip
{

    var dataXML:XML;
    var xmlURL:String;
    var dataXMLURL:URLRequest;
    var xmlLoader:URLLoader;

    public function Portal() 
    {

        alignCentre();
        loadXML();

    }

    public function alignCentre()
    {

        stage.scaleMode = StageScaleMode.EXACT_FIT;
        stage.align = StageAlign.TOP;

    }

    public function loadXML()
    {

        dataXML = new XML();
        xmlURL = "xml/portal.xml";
        dataXMLURL = new URLRequest(xmlURL);
        xmlLoader = new URLLoader(dataXMLURL);
        dataXML = XML(xmlLoader.data);
        xmlLoader.addEventListener(Event.COMPLETE, displayXML);

    }

    public function displayXML(event:Event)
    {

        trace(event.target.data);
        trace(dataXML);

    }


}

}

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

AS3 won't load my XML