I used Ordinathorreur’s example (from http://www.kirupa.com/forum/showthread.php?t=201509&highlight=load+jpg) on how to load an external jpg and then use the bitMapdata class to copy it to avoid jaggies when i rotate the pic…but:
I dont like having an onEnterFrame running the whole time just to load a pic every once in a while so i tried using a loadClip (which i want anyway) and then use the onLoadComplete or the onLoadProgress to test if the pic is loaded.
Nothing works… probably just som stupid mistake but i would be grateful if someone would take a look at my code:
import flash.display.BitmapData;
loaded = 0;
getThisPic = 0;
var polClip:MovieClipLoader = new MovieClipLoader();
var polLoadListener:Object = new Object();
polClip.addListener(polLoadListener);
but.onRelease = function() {
loadPic();
};
loadPic = function () {
i = 0;
while (getThisPic == loaded) {
i++;
getThisPic = Math.floor(Math.random()*5+1);
}
loaded = getThisPic;
polClip.unloadClip(target_mc);
polClip.loadClip("randomgallery/"+getThisPic+".jpg", "holder");
};
//**************method1
polLoadListener.onLoadComplete = function(target_mc) {
myBitmapData = new flash.display.BitmapData(holder._width, holder._height, true, 0x00FFFFFF);
myBitmapData.draw(_root.holder);
_root.holder2.attachBitmap(myBitmapData, 1, "auto", true);
};
//**************method2
/*
polLoadListener.onLoadProgress = function(target_mc, lBytes, tBytes) {
pText.text = Math.round((lBytes/tBytes)*100);
if (lBytes == tBytes) {
myBitmapData = new flash.display.BitmapData(holder._width, holder._height, true, 0x00FFFFFF);
myBitmapData.draw(_root.holder);
_root.holder2.attachBitmap(myBitmapData, 1, "auto", true);
}
};
*/
//**************method3
/*
_root.onEnterFrame = function() {
if (_root.holder.getBytesLoaded() == _root.holder.getBytesTotal()) {
myBitmapData = new flash.display.BitmapData(holder._width, holder._height, true, 0x00FFFFFF);
myBitmapData.draw(_root.holder);
_root.holder2.attachBitmap(myBitmapData, 1, "auto", true);
}
};
*/
… as i said: the only one of the three methods above that works is the onEnterFrame.