TwelvestoneFlash

I'm a confused ASS3....data between functions in class


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 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 ...
Storm
 
2008-11-10

Pasting the entire class....need help.

I am simply trying to replace AS2's onLoad(success) action in AS3 and struggling to get the object passed to the new function.

The last two functions loadXML() and displayXML() are where my problem lies. How do I get the XML data into displayXML? If I use event.target.data it comes as a String and I can't parse it as XML. dataXML doesn't show up as anything in the new function. And if I parse it in the loadXML function it is not always available and I want the COMPLETE to happen first.

following the trace commands: event.target.data: shows the data in the Output window but it's a string because I've also tried dataXML = event.target.data; or dataXML = XML(e.t.d) and = new XML(e.t.d) etc......but I get errors because it is a String.

How do I pass the object in the COMPLETE listener? I'm a dumbass.

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);

    }


}

}

baron ruhstoff
 
2008-11-10

No need to examine the event - your loader is accessible as a property of the class. If you had declared it local to loadXML()... well, that'd be a different story. public function displayXML(event:Event) {

        // trace(event.target.data);
        **dataXML = XML(xmlLoader.data);**
        trace(dataXML);

    }
Storm
 
2008-11-10

tried that too before.....and got this error:

no matter what i try as far as accessing dataXML as an XML Object, this is the most common error.

TypeError: Error #1088: The markup in the document following the root element must be well-formed. at as3::Portal/displayXML() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()

baron ruhstoff
 
2008-11-10

Howzabout this: dataXML = xmlLoader.data as XML;

Storm
 
2008-11-10

OFFS

I'm a retard. Thanks br. It came as a string because I had not properly contained my tag IDing the app before my .

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

I'm a confused ASS3....data between functions in class