# Going back to the original color?

**URL:** <https://forum.kirupa.com/t/going-back-to-the-original-color/244341>\
**Category:** Uncategorized\
**Created:** [November 16, 2007, 3:21pm UTC](https://forum.kirupa.com/t/going-back-to-the-original-color/244341 "2007-11-16T15:21:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Urme](https://avatars.discourse-cdn.com/v4/letter/u/f1d935/32.png) [@Urme](https://forum.kirupa.com/u/Urme)\
**Post date:** [November 16, 2007, 3:21pm UTC](https://forum.kirupa.com/t/going-back-to-the-original-color/244341/1 "2007-11-16T15:21:34Z")

</div>

I’m playing around with some AS3 for fun atm.

I have two files, I create two boxes with different colors. I have a mouseover function that change the color when the mouse is over the box, and a mouse\_out function. How do I go back to the original color in my “MouseOUT” function instead of setting a new color?

Main.as

```auto

package {

    import flash.display.Sprite;
    import flash.events.Event;

    public class Main extends Sprite {

        public function Main() {
            addEventListener(Event.ENTER_FRAME, init);
        }
        
        public function init(eve:Event) {
            removeEventListener(Event.ENTER_FRAME, init);
            var redBox:Box = new Box ("100", "200", "0xFF0000");
            var blackBox:Box = new Box ("100", "200", "0x000000");
            blackBox.x = redBox.width;
            addChild(redBox);
            addChild(blackBox);
        }
    }
}

```

Box.as

```auto

package {
    
    import flash.display.Sprite;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.ColorTransform;
    
    public class Box extends Sprite {
        
        public var box:Shape = new Shape ();
        
        public function Box(boxWidth, boxHeight, boxColor) {
            box.graphics.beginFill (boxColor);
            box.graphics.drawRect (0, 0, boxWidth, boxHeight);
            box.graphics.endFill ();
            addChild(box);
            addEventListener(MouseEvent.MOUSE_OVER, MouseOVER);
            addEventListener(MouseEvent.MOUSE_OUT, MouseOUT);            
        }
        
        public function MouseOVER(eve:Event) {
            var newColor:ColorTransform = box.transform.colorTransform;
            newColor.color = 0x00FF00;
            box.transform.colorTransform = newColor;
        }
        
        public function MouseOUT(eve:Event) {
            var newColor:ColorTransform = box.transform.colorTransform;
            newColor.color = 0xF00FF0;
            box.transform.colorTransform = newColor;
        }        
    }
}

```
