The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 4 of 4

Thread: How to make sure XML loads?

  1. #1

    How to make sure XML loads?

    I have a number of pics(around 30) and of large size(~5kb). Now i have made a simple xml file to load this images into the game and display them all at once.....but the pics are not being loaded. I mean, in the editor itself, it loads most of them, except 4-5 heavy ones. but on my server only 4 pics of 2 kb are being loaded and rest are skipped. In the frame before this frame, i have a button, to come to this frame, and on coming to this frame, the user is supposed to see all the pictures in a grid. How can i make sure all the pics are loaded, and then show this page?
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  2. #2
    12
    posts
    Registered User
    If your'e using AS2, search for "MovieClipLoader" in the help files. I would use a variable for a counter and increment it every time the onLoadInit(an event dispatched when MovieClipLoader finishes loading an image) is fired and check if the counter value is == xml nodes length. If it is, then you could proceed.

    If you're using AS3, look for Loader() and URLRequest.
    The approach is similiar. add and event listener, say like addEventListener(Event.COMPLETE, imageLoaded) and in the function imageLoaded increment the counter.

    My 2 cents. Probably a better way exists.
    Last edited by bLaf; May 11th, 2008 at 09:58 AM.

  3. #3
    bLaf, all the nodes information is already being read in, but for some particular reason, the heavy images are not being loaded
    MY BLOG

    I need a SPRITER who can do pixel arts for an arcade fighter project. If you can help out, please pm me.
    I also need someone who can write simple xml files.


  4. #4
    12
    posts
    Registered User
    Well, that's why you better use MovieClipLoader(if you don't already) and define a function for when onLoadInit is dispatched. That guarantees the image is loaded(i.e. this event is dispatched when the image is fully loaded and ready to be displayed).

    a short improvisation:

    Code:
    var XMLIndex:Number = 0;
    var ArrayOfMCs:Array = new Array(mc1, mc2, mc3, mc4, another_mc);
    var listener_object:Object = new Object();
    var MovieClipLoaderInstance:MovieClipLoader = new MovieClipLoader();
    
    MovieClipLoaderInstance.addListener(listener_object);
    
    listener_object.onLoadInit = function(target_mc) {
    
     trace("the image is fully loaded in movie clip " + target_mc);
     trace("proceeding to next image: ");
    
     XMLIndex++;
     MovieClipLoaderInstance.loadClip(XMLFile.firstChild.childNodes[XMLIndex].attributes["path_to_image"],     ArrayOfMCs[XMLIndex]);
    
    
    }
    
    MovieClipLoaderInstance.loadClip(XMLFile.firstChild.childNodes[XMLIndex].attributes["path_to_image"],  ArrayOfMCs[XMLIndex]);
    And yes in case we're talking about different things you could post/attach your code/fla and I'll try to help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012