# \[Flash8\] Help with image selection/fade

**URL:** <https://forum.kirupa.com/t/flash8-help-with-image-selection-fade/249224>\
**Category:** flash\
**Created:** [January 16, 2008, 5:56pm UTC](https://forum.kirupa.com/t/flash8-help-with-image-selection-fade/249224 "2008-01-16T17:56:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay0316](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jay0316](https://forum.kirupa.com/u/jay0316)\
**Post date:** [January 16, 2008, 5:56pm UTC](https://forum.kirupa.com/t/flash8-help-with-image-selection-fade/249224/1 "2008-01-16T17:56:23Z")

</div>

Hi, I’m using Flash 8 and I’m a newbie to actionscript.

I have to create a flash document that will allow me to swap out colors, patterns, and hardware on our collars. I found a thread posted that was pretty much what I was looking for. I altered the files to use my images, so I have 3 images that are changing. I also have a rollover effect on the color swatches. Here is a link to the [files](http://www.coastalpet.com/ref-build-final.zip).

What I want to happen is this:  
When you roll over a color swatch: the black outline around the color swatch fades in  
When you click and release: the collar image changes and the black outline around the color swatch stays on until you click another color swatch  
When you rollout: the outline fade out unless the swatch was clicked.

Here is what I’m [modeling after]([http://www.llbean.com/webapp/wcs/stores/servlet/ShowMainCustomization?storeId=1&catalogId=1&langId](http://www.llbean.com/webapp/wcs/stores/servlet/ShowMainCustomization?storeId=1&catalogId=1&langId) =-1&categoryId=40297&sc1=Search&feat=sr).

Please look at my files to see what is happening now.

I could really use some help. If you don’t have time to check out the files, I also attached the code to review if that is faster. If there is an easier way to do this please let me know what that is as well.

Thanks,  
jay

```auto

//import the required classesimport mx.transitions.Tween;import mx.transitions.easing.*;fscommand("allowscale", "false");//substrate colors// create a loop to cycle thru all the buttons and backgroundsfor (var i:Number = 1; i<8; i++){	//create a reference to the background movieclips	var background:MovieClip = this["bk" + i];	//create a reference to the background movieclips	var background:MovieClip = this["rs" + i];	//set the backgrounds depth	background.swapDepths(i);	//set the backgrounds alpha	background._alpha = 0; //create a reference to the button movieclips	var button:MovieClip = this["btn" + i];	//associate the relevent background to the button	button.bk = this["bk" + i];	button.rs = this["rs" + i]; //create buttons functions	button.onRelease = function(){ fadeMovieClip(this.bk, "release"); fadeMovieClipRS(this.rs, "release");	}	//create buttons functions	button.onRollOver = function(){ fadeMovieClipRS(this.rs, "over");	}	button.onRollOut = function(){ fadeMovieClipRS(this.rs, "out");	}}//create a function to fade the movieclipfunction fadeMovieClip(bk:MovieClip, control:String) {	if (control == "release"){ // on release do this bk.swapDepths(7); var myTween:Tween = new Tween(bk, "_alpha", mx.transitions.easing.None.easeNone, 0, 100, .5, true); myTween.onMotionFinished = function(){ currentBackground._alpha = 0; currentBackground = bk8;//number has to be a bigger than what I have delete myTween; }	}}//test//create a function to fade the movieclipfunction fadeMovieClipRS(rs:MovieClip, control:String) {	if (control == "over"){ // on release do this rs.swapDepths(7); var myTween:Tween = new Tween(rs, "_alpha", mx.transitions.easing.None.easeNone, 0, 100, .5, true); myTween.onMotionFinished = function(){ currentBackground._alpha = 0; currentBackground = rs9;//number has to be a bigger than what I have delete myTween; }	} else if(control == "out") { // on rollout do this // loop thru the buttons and check if the mouse is still over one for (var i:Number = 1; i<8; i++){ var button:MovieClip = this["btn" + i]; if (button.hitTest(_root._xmouse, _root._ymouse, true)){ return; }// if the mouse is not over any of the buttons fade out var myTween:Tween = new Tween(rs, "_alpha", mx.transitions.easing.None.easeNone, 100, 0, .5, true); currentBackground = null; } } else if (control == "release"){ // on release do this rs.swapDepths(7); var myTween:Tween = new Tween(rs, "_alpha", mx.transitions.easing.None.easeNone, 0, 100, .5, true); myTween.onMotionFinished = function(){ currentBackground._alpha = 0; currentBackground = rs9;//number has to be a bigger than what I have delete myTween; }	} }

```
