PDA

View Full Version : load dynamic images into scroll pane


mojito
03-01-2007, 08:52 AM
Im still unresolved on this so if you have any ideas I'd really like to hear.
Im simply trying to load external jpegs into a scroll pane component. Here is my code sp is the scrollpane and image_mc is a blank movie clip. Both are on the stage

var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
sp.contentPath=image_mc;
};
var image_mc1:MovieClipLoader = new MovieClipLoader();
image_mc1.addListener(mclListener);
image_mc1.loadClip("content/visual/images/01010000_00.jpg", image_mc);

tnx

_global.kevin
03-02-2007, 01:22 PM
Making a seperate swf that calls in the pics and then call that swf into the scrollPane?

mojito
03-02-2007, 01:26 PM
Hi and thanks for that, it did work and I shamefully hadnt returned here to show my code, well here it is for loading in the dynamic images and then the scroll pane unfortunately has to have an onEnterFrame to update on the invalidate(); method.


dynamic image loading (beware that the order loaded is sequential but the init function is dependant on which loads first etc

//labels for images
var aLabels = [];
//images-----------------------------------------
var maxWidth = 450;
var maxHeight = 450;
//-----------------------------------------------
//test with three images
aTotalLoadedImages = [];
totalHeight = 0;
for (var a = 0; a<=3; a++) {
ref = this["mclListener"+a];
var ref:Object = new Object();
ref.onLoadInit = function(target_mc:MovieClip) {
trace("height is "+target_mc._height);

if (target_mc._width>maxWidth) {
var factor = target_mc._width/maxWidth;
target_mc._width = target_mc._width/factor;
target_mc._height = target_mc._height/factor;
}
if (target_mc._height>maxHeight) {
var hfactor = target_mc._height/maxHeight;
target_mc._width = target_mc._width/hfactor;
target_mc._height = target_mc._height/hfactor;
}
//centre the image horizontally
target_mc._x += target_mc._width/2;
aTotalLoadedImages.push(target_mc);
if (aTotalLoadedImages.length == 3) {
//trace("loaded all "+aTotalLoadedImages);
target_mc._y=totalHeight;
trace("height is "+totalHeight);
} else {
target_mc._y=totalHeight;
totalHeight+=target_mc._height;
trace("height is "+totalHeight);
}
};
var ref2:MovieClipLoader = new MovieClipLoader();
ref2.addListener(ref);
//trace("LOADING content/visual/images/"+_root.currentScreenObject.images[a]);
ref2.loadClip("content/visual/images/"+_root.currentScreenObject.images[a], "bttn"+a);
}