PDA

View Full Version : Loading the first image...(NOT a preload Q!!)



osc
June 30th, 2003, 12:04 PM
Hello,

Having got the bulk of my site to work - I seem unable to get the AS to work in loading the first image.
The main script runs after a button has been pressed, but how do I get the following script to execute after the XML file (called pictures) has been loaded. I have tried lots of different ways - onenterframe, frame loaded etcbut none seem to work


_root.picture.loadMovie(pictures.childNodes[0].childNodes[1].attributes["jpegURL"]);


Is there a simple answer to this? - I hope so:)

Osc

jingman
July 1st, 2003, 05:37 AM
yes, there is a very simple answer. This is how I load all my XML files.

my_XML = new XML();
my_XML.ignoreWhite = true;

// IMPORTANT PART FOR YOU ////////////

my_XML.onLoad = function(success) {
if (success) {
///WHAT YOU WANT TO DO///
};
};
my_XML.load("countries.xml");

///////////////////////////////////////

osc
July 1st, 2003, 10:20 AM
Thanks - it works! I have been able to load my first image...BUT I can not understand why the preloader I am using does not work(it works in the rest of the site when a button is pressed). If I have the following script as follows - the image loads - but the loadbar does not work:



pictures = new XML();
pictures.ignoreWhite = true;

pictures.onLoad = function(success) {
if (success) {
this.createEmptyMovieClip("preloader", 1000);
_root.picture.loadMovie(pictures.childNodes[0].childNodes[1].attributes["jpegURL"]);
picture._visible = 0;
preloader.onEnterFrame = function() {
var l = picture.getBytesLoaded();
var t = picture.getBytesTotal();
var getPercent = l/t;
loadBar._width = getPercent*100;
if (l>0 && l>=t) {
picture._visible = 0;

}}}};
pictures.load("pictures.xml");


Why does the preloader loop not work(and yes I know I said in my thread title that this was not a preloader question - as I thought I had a script that worked!)??