# Load and unload image

**URL:** <https://forum.kirupa.com/t/load-and-unload-image/278734>\
**Category:** flash\
**Created:** [January 4, 2009, 9:01pm UTC](https://forum.kirupa.com/t/load-and-unload-image/278734 "2009-01-04T21:01:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rumr](https://avatars.discourse-cdn.com/v4/letter/r/9fc348/32.png) [@Rumr](https://forum.kirupa.com/u/Rumr)\
**Post date:** [January 4, 2009, 9:01pm UTC](https://forum.kirupa.com/t/load-and-unload-image/278734/1 "2009-01-04T21:01:27Z")

</div>

I am working on a portfolio site, ![](http://www.jamespg.com/ref.jpg)

i would like to create a custome class that I can plug into all my project buttons to load up a title.JPG and a img.JPG in there movieclip location.

I want to tween out current IMG and tween in new selected IMG. this is what I have started. I would like to make a custom class for this but im taking it one step at a time.

* * *

import caurina.transitions.Tweener;  
//  
var imageLoader:Loader;

function loadImage(url:String):void {  
// Set properties on my Loader object  
imageLoader = new Loader();  
imageLoader.load(new URLRequest(url));  
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);  
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);  
}  
function imageLoaded(e:Event):void {  
// Load Image  
imageArea.alpha = 0;  
imageArea.addChild(imageLoader);  
Tweener.addTween(imageArea, {alpha:1, time:0.5});  
}

function imageLoading(e:ProgressEvent):void {  
// Use it to get current download progress  
// Hint: You could tie the values to a preloader 🙂  
}

//----------------------------------------------------------

worksBtn.addEventListener(MouseEvent.ROLL\_OVER, worksOver);  
worksBtn.addEventListener(MouseEvent.ROLL\_OUT, worksOut);  
worksBtn.addEventListener(MouseEvent.CLICK, worksClick);  
worksNav.alpha = 0;

function worksOver(evt:MouseEvent) {  
Tweener.addTween(worksBtn, {alpha:.5, time:1});  
}

function worksOut(evt:MouseEvent) {  
Tweener.addTween(worksBtn, {alpha:1, time:1});  
}

function worksClick(evt:MouseEvent):void {  
loadImage(“projects/3d/img/01.jpg”);  
}

any help would be much appreciated.  
Thanks
