A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: preloader

  1. #1
    Senior Member green_eye's Avatar
    Join Date
    Apr 2004
    Location
    Sarasota, Florida
    Posts
    1,496

    preloader

    What I have is a flash header that pulls in xml data. When you view the site the flash file displays and works correctly but when a call is made to the xml file I receive an undefined error. When the file is reloaded on the server the xml works correct.I have a preloader for the entire swf. I just don't know why the page has to be requested 2x for the xml call to work correctly. Is the preloader just for the swf file or also for the xml file that is being called in. If I add a preloader for the xml file where do I place the code? I have code that pulls the data in the first frame and is not need until a button click calls it on the second frame. Plus the xml file is relatively small... So I am puzzled.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    You are right, that the preloader only loads the actual SWF file, but not the associated files, like the XML, for instance. I bet you're using XML object's onLoad function to display the data from the XML, right? Something like this:

    Actionscript Code:
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = function(){
        // load data here
    }
    xmlData.load("someFile.xml");

    This tells Flash to load the XML file when you reach the frame with this code, and you can notice this by seeing that the data is not pulled instantly, but takes at least some milliseconds to one second to display, and that's because it was being loaded! What you can do, is to use the XML object on the preloader screen, and execute it after the actual preloader has been fully loaded, and make another fake loader, a loader where it says "Wait a moment, XML file is being loaded", and then use onLoad function and make the Flash continue when the XML file has been loaded. In the onLoad function, simply store the whole XML in a variable to use it later, so this is an example:

    Actionscript Code:
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = function(){
        play(); // or make Flash continue
        xml = xmlData; // store the XML in the variable, xml
        // you can pull out information from this variable just like you would do it in here
    }
    xmlData.load("someFile.xml");

    Hope this helps
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Senior Member green_eye's Avatar
    Join Date
    Apr 2004
    Location
    Sarasota, Florida
    Posts
    1,496
    Ok that issue is solved...

    The xml file is formatted with basic html tags... If I view the page that contains the flash header in a browser the html formatting works but the href tag or link does not. If I right click on the link and choose new tab/window it works. I dont understand why I the link will not open the page?

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Maybe post the XML file and FLA?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Senior Member green_eye's Avatar
    Join Date
    Apr 2004
    Location
    Sarasota, Florida
    Posts
    1,496
    thank you for your help... that problem is fixed.

    A question about the XML pull, I do update the file each day. Meaning that the upcoming dates are not up to date before the day before the actual date. Does the browser cache the whole XML content? I have noticed that it does cache each viewed day. I think unless the button calls the xml data that content is not cached. Is this correct thinking...


    EDIT: I found out that the answer is yes the whole xml file is cached by the browser.


    How can I have one xml file but only onload the part of the xml file that will be needed?
    Last edited by green_eye; 12-07-2011 at 04:19 PM.

  6. #6
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    How can I have one xml file but only onload the part of the xml file that will be needed?
    What do you mean, like some of the nodes?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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