dcsimg
A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: preloading an SWF that contains XML onLoad

  1. #1
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645

    preloading an SWF that contains XML onLoad

    Hello all..

    Heres my problem:
    I have created a movie, that when it loads it pulls data from an XML file that will be used to populate a scrolling movie clip with images.

    USER NAME: guest
    PASSWORD: openme

    Here is the working flash without a preloader
    http://www.3primates.com/currentDev/...802/main7.html

    Everything works fine if I do not try and preload the movie.
    If I try and preload the movie, the XML data does not get loaded and the movie fails.

    Here is the NON working flash with a preloader
    http://www.3primates.com/currentDev/...2/preload.html


    Or if I move the XML out of the first frame of my movie, the XML data will mot load and the movie fails.

    You can download mt source here to help me test it.1.7 MB
    http://www.3primates.com/currentDev/...2/3p_flash.zip

    Here is my scripting:

    PHP Code:
    stop();


    // alpha transparency of the thumbnail images
    // within _root/thumbs/scroller MC
    thumbAlpha 70;

    // ease out of _root/thumbs/scroller MC (thumb images)
    // greater number = more ease time
    ease_y 5;

    // amount of horizontal space between thumbnail images
    // and the amount of horizontal padding on top and bottom of thumbnail scroller
    // padding refers to the black movie clip called scroller_bg
    // located at _root.thumbs.scroller_bg
    offsetY 7;

    // amount of vertical padding on the left and right of thumbnail scroller
    offsetX 7;

    // Amount of thumbnail images there are visible in the scroller at one time.
    // changing the amount also changes how many are scrolled at one time,
    // and the size of the mask that covers the scroller clip.
    // If you increase the height of the movie or decrease the
    // size of the image, you should be able to use a number over 4
    // but I am not sure how well that works. That aspect was not fully tested
    thumbAmount 4;

    scrollerY Math.ceil(Math.round(_root.thumbs.scroller._y));

    var 
    movieWidth 600;
    var 
    numOfpicFrames;
    var 
    rightMostMenu;
    var 
    leftMostMenu 0;
    var 
    scrollRate = -5;
    var 
    picFrameWidth 150;
    var 
    menuLoaded false;
    var 
    scrollControl true;
    nextX 0;
    nextY 0;
    //
    // First thing: Load the XML
    _root.onLoad = function() {
        
    XMLobj = new XML();
        
    XMLobj.ignoreWhite true;
        
    XMLobj.onLoad loadXML;
        
    XMLobj.load("images/pics.xml");
    };
    //
    // turn XML document into menu items
    function loadXML(success) {
        var 
    inodeObjnewMovieimageSize;
        if (
    success) {
            
    debug "Loaded XML";
            
    //numOfpicFrames = this.firstChild.childNodes.length;
            
    numOfpicFrames this.firstChild.childNodes.length;
            
    //rightMostMenu = numOfpicFrames;
            
    for (i=0i<numOfpicFramesi++) {
                
    nodeObj this.firstChild.childNodes[i];
                
    _root.thumbs.scroller.attachMovie("picFrame""picFrame"+(i+1), i+1);
                
    newMovie _root.thumbs.scroller["picFrame"+(i+1)];
                
    newMovie._y nextY;

                
                
    nextY += parseInt(nodeObj.attributes.height)+offsetY;
                
                
    //newMovie._x = 0;
                
    newMovie.title nodeObj.attributes.title;
                
    newMovie.bigPic nodeObj.attributes.bigPic;
                
    newMovie.picHolder.loadMovie(nodeObj.attributes.thumbNail);
                
    newMovie.picURL nodeObj.attributes.image;
                
    newMovie._alpha thumbAlpha;
                
                
    // scroller, scroller mask and scroller BG
                // height and width conversions
                // Pretty nasty lookin
                
    thumb_series_height parseInt(nodeObj.attributes.height) + offsetY;
                
    mask_height thumb_series_height thumbAmount offsetY;
                
    thumb_width parseInt(nodeObj.attributes.width);
                
                
    _root.thumbs.scroller_mask._height mask_height;
                
    _root.thumbs.scroller_mask._y mask_height 2;
                
                
    _root.thumbs.scroller_bg._height mask_height offsetY;
                
    _root.thumbs.scroller_bg._y _root.thumbs.scroller_mask._y  offsetY offsetY /2;
                
                
    _root.thumbs.scroller_bg._width thumb_width offsetX;
                
    _root.thumbs.scroller_bg._x _root.thumbs.scroller_mask._x
                
    //
                
            
    }
            
    newHeight parseInt(nodeObj.attributes.height)* numOfpicFrames offsetY;
            
    menuLoaded true;
            
    debug "xml data loaded";
            
    _root.down._visible false;
        } else {
            
    debug "failed to load XML";
        }

    I am new to XML and would appreciate any insight into why I cannot get my preloader to function.

    Thank you for your help

    3PRIMATES

    I am also posting this in scripting and backend since XML forum does not get much traffic. I will delete one of them when I get a response..
    Thanks
    Last edited by 3PRIMATES; 02-08-2003 at 01:16 PM.

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