dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Need help!!! AS, XML, and HTML

  1. #1
    Member
    Join Date
    Jun 2007
    Location
    Cleveland, Ohio
    Posts
    56

    Need help!!! AS, XML, and HTML

    I am trying to load a quiz that was built in xml into a flash file. IT works fine from my computer, but once I load it onto the server, itno longer works on the webpage, for some reason, no matter what I do, the swf will not see the file. Here is the code that calls the XML file.


    Code:
    myData.ignoreWhite=true;
    myData.onLoad=onQuizData;
    myData.load("quiz.xml");
    stop();

    Now in the "myData.load("quiz.xml")" I tried placing the XML file in the same folder as the SWF on the server, and that doesn't work. So I added:
    myData.load("http://www.blahblahblah.com/swf/quiz.xml")

    And that doesn't work either. Is there a special bit of code that I need to call for this? I am on a time frame and freaking out here. Thanks!!!

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Probably has something to do with the XML not loading as fast on the internet as it does locally, this should fix it:
    PHP Code:
    stop();
    myData.ignoreWhite true;
    myData.onLoad = function(success:Boolean):Void {
        if(
    success){
            
    // put code here for when the XML is loaded
        
    }
    }
    myData.load("quiz.xml"); 

  3. #3
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    dont forget to declare the XML variable..

    PHP Code:
    var myData:XML = new XML();
    myData.ignoreWhite true;
    myData.onLoad = function(success:Boolean):Void {
        if(
    success){
            
    // put code here for when the XML is loaded
            
    trace("XML: "+myData);
        }
    }
    myData.load("quiz.xml"); 

  4. #4

  5. #5

  6. #6
    Senior Member
    Join Date
    Oct 2000
    Posts
    220
    How would I modify that code to use a variable to load the XML instead of the actual path?

    We have a client with a really whacky server environment, which of course we don't have access to.

    We never know ahead of time where our files are going to end up, so anything that loads into Flash from an external file has to be a variable.

  7. #7
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    PHP Code:
    someVar "http://www.somedomain.com/somefolder.someXML.xml";




    var 
    myData:XML = new XML();
    myData.ignoreWhite true;
    myData.onLoad = function(success:Boolean):Void {
        if(
    success){
            
    // put code here for when the XML is loaded
            
    trace("XML: "+myData);
        }
    }
    myData.load(someVar); 

  8. #8
    Senior Member
    Join Date
    Oct 2000
    Posts
    220
    I already tried that, it doesn't work. The variable has to be defined in the html file, not the swf.

    For example, in place of having the following code in the fla.
    PHP Code:
    someVar "http://www.somedomain.com/somefolder.someXML.xml"
    I would ad the following line to the javascript in my html file

    PHP Code:
    'FlashVars''news=news.xml'

  9. #9
    Senior Member
    Join Date
    Oct 2000
    Posts
    220
    Figured it out. All my code was in a movie clip.
    PHP Code:
    myData.load(_root.someVar); 
    fixed it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center