Please help me understand this

I have a function that loads text and pictures into two seperate movie clips and sub movie clips, and then sets buttons and arrows for scolling. the script is below:


// Loaded Text
// declare the LoadVars object that 
// loads in the external text
myData = new LoadVars();
// load event 
myData.onLoad = function() {
    // allow text to use html 
    _root.headerHolder_mc.headerText_box.html = true;
    _root.headerHolder_mc.headerText_box.htmlText = this.headerVar;
    _root.bodyHolder_mc._y = 85;
    _root.bodyHolder_mc.bodyText_box.autoSize = true;
    _root.bodyHolder_mc.bodyText_box.multiline = true;
    _root.bodyHolder_mc.bodyText_box.wordWrap = true;
    _root.bodyHolder_mc.bodyText_box.html = true;
    _root.bodyHolder_mc.bodyText_var =  this.textVar;
    
    // load pictures
    attachMovie("mask_mc", "maskSmall_mc", _root.getNextHighestDepth(), {_width: 170, _height:400, _x: 610, _y:80});
    attachMovie("picturesHolder_mc", "picturesHolder_mc", _root.getNextHighestDepth(), {_x:620, _y:85});
    picturesHolder_mc.setMask(maskSmall_mc);
    attachMovie("upArrow_mc", "upArrowPics_mc", _root.getNextHighestDepth(), {_x:720, _y:490, _alpha:0});
    attachMovie("downArrow_mc", "downArrowPics_mc", _root.getNextHighestDepth(), {_x:745, _y:490, _alpha:0});

    noPicturesToLoad = this.noPictures;
    picturesLoaded = 1;
    pictureStartY = 0;
    while (picturesLoaded <= noPicturesToLoad) {
        picHolder_clipName = "picHolder_mc" + picturesLoaded;
        picturesHolder_mc.attachMovie("picHolder_mc", picHolder_clipName, picturesHolder_mc.getNextHighestDepth(), {_x:0, _y:pictureStartY});
        _root.picturesHolder_mc[picHolder_clipName].loadMovie("../images/"+_root.contentVariable+"/thumbs/"+picturesLoaded+".jpg");
        pictureStartY += _root.picturesHolder_mc[picHolder_clipName]._height;
        trace(_root.picturesHolder_mc._height);
        trace(pictureStartY);
        picturesLoaded += 1;
    }
                trace(_root.picturesHolder_mc[picHolder_clipName]._height);
    
    //showPics_tween = new Tween(picturesHolder_mc, "_alpha", Regular.easeInOut, 0, 100, 30, false);
    showPics_tween.onMotionFinished = function() {
        new Tween(upArrowPics_mc, "_alpha", Regular.easeInOut, 0, 100, 10, false);
        new Tween(downArrowPics_mc, "_alpha", Regular.easeInOut, 0, 100, 10, false);
    }
    // Set buttons for pictures
    _root.downArrowPics_mc.onPress = function() {
        _root.onEnterFrame = function(){
            endOfPics = 450 - _root.picturesHolder_mc._height - _root.picturesHolder_mc[picHolder_clipName]._height;
            if (_root.picturesHolder_mc._y > endOfPics) {
                _root.picturesHolder_mc._y -= 5;
            }
        }
    }
    
    _root.downArrowPics_mc.onRelease = function() {
        delete _root.onEnterFrame; 
    }
        
    _root.upArrowPics_mc.onPress = function() {
        _root.onEnterFrame = function() {
            if (_root.picturesHolder_mc._y < 85) {
                _root.picturesHolder_mc._y += 5;
            }
        }
    }
        
    _root.upArrow_mc.onRelease = function() {
        delete _root.onEnterFrame;
    }
};

The script fails here:


while (picturesLoaded <= noPicturesToLoad) {
        picHolder_clipName = "picHolder_mc" + picturesLoaded;
        picturesHolder_mc.attachMovie("picHolder_mc", picHolder_clipName, picturesHolder_mc.getNextHighestDepth(), {_x:0, _y:pictureStartY});
        _root.picturesHolder_mc[picHolder_clipName].loadMovie("../images/"+_root.contentVariable+"/thumbs/"+picturesLoaded+".jpg");
        pictureStartY += _root.picturesHolder_mc[picHolder_clipName]._height;
        trace(_root.picturesHolder_mc._height);
        trace(pictureStartY);
        picturesLoaded += 1;
    }

i loaded an xml file which contains a variable stating how many pictures are there for that particular topic. The idea is that the pictures are then loaded one on top of the other. This way i can have pictures with varying length, yet the same width (its for aestetic purposes; better than constant boxes). WHere the script goes wrong is where i attempt to retreive the hieght of the picture that has been loaded so that i may know where to place the following picture.

I’m going to go and attempt to modify the code so that i check the height of the last picture loaded on the NEXT iteration of the while loop rather than at the end of the while loop as you see above. I’m doing this because i believe that the reason I’m not returning the height, is because the picture hasn’t had time to load…

can anyone see something i may have missed?

-Ahmed