Hi guys.
Got the script from senocular.com and it works super, for a slideshow - or just by pressing buttons
like below. The thing is though, that after watching the nice transition i couldn’t help noticing the
dynamically loaded images getting jagged, ■■■■. Next thing I tried to fix this as you can se below in
this.contents_mc2, which I placed above this.contents_mc in container1_mc and also container2_mc.
So far so good - my image was fine - not jagged, my I got a new problem - now the alpha transiton was
slow and cpu-heavy. I’d really like to keep the transition - and hope you can see what my problem is about.
Thank you very much, Tonni.
var bottomcontainer = container1_mc;
image1_btn.onPress = function(){
startPreload(“load/beach.jpg”);
}
image2_btn.onPress = function(){
startPreload(“load/building.jpg”);
}
function startPreload(url){
attachMovie(“preloader anim”, “preloader_mc”, 500, {_x:275, _y:165});
bottomcontainer._alpha = 0;
bottomcontainer.contents_mc.loadMovie(url);
bottomcontainer.onEnterFrame = preloadContents;
}
function preloadContents(){
var bytes_loaded = this.contents_mc.getBytesLoaded();
var bytes_total = this.contents_mc.getBytesTotal();
if (bytes_total > 0){
var percent_loaded = bytes_loaded/bytes_total;
preloader_mc.value = percent_loaded;
if (percent_loaded == 1){
myBitmapData = new flash.display.BitmapData(this.contents_mc._width,this.contents_mc._height, true, 0x00FFFFFF);
//copy the bitmap into the bitmapdata variable we just created
myBitmapData.draw(this.contents_mc);
//now attach it to a different mc for the sake of example
this.contents_mc2.attachBitmap(myBitmapData,1,"auto",true);
delete this.onEnterFrame;
this.onPreloaderComplete();
}
}
}
container1_mc.onPreloaderComplete = preloadComplete;
container2_mc.onPreloaderComplete = preloadComplete;
function preloadComplete(){
container1_mc.swapDepths(container2_mc);
if (container1_mc.getDepth() < container2_mc.getDepth()){
bottomcontainer = container1_mc;
}else{
bottomcontainer = container2_mc;
}
preloader_mc.removeMovieClip();
this.onEnterFrame = fadeIn;
}
function fadeIn(){
if (this._alpha < 100){
this._alpha += 5;
}else{
delete this.onEnterFrame;
}
}