# BitmapData/transition - I'd like both

**URL:** <https://forum.kirupa.com/t/bitmapdata-transition-id-like-both/198148>\
**Category:** flash\
**Created:** [August 22, 2006, 7:35pm UTC](https://forum.kirupa.com/t/bitmapdata-transition-id-like-both/198148 "2006-08-22T19:35:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonni](https://avatars.discourse-cdn.com/v4/letter/t/9fc348/32.png) [@tonni](https://forum.kirupa.com/u/tonni)\
**Post date:** [August 22, 2006, 7:35pm UTC](https://forum.kirupa.com/t/bitmapdata-transition-id-like-both/198148/1 "2006-08-22T19:35:37Z")

</div>

Hi guys.

Got the script from [senocular.com](http://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 &gt; 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() &lt; 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;  
}  
}
