Copy link to clipboard
Copied
Hello,
I'm very new to Flash and I'm having a bit of an issue with my first ActionScript.
I am working on a project where I have a black and white picture. When you mouse over the picture, it turns to a color version of the same picture. When you take your mouse off of the picture, it goes back to black and white.
I have three instances of the picture, a black and white image at frame 1, a color image at frame 10, and a black and white image at frame 20. Currently, when I mouse over the black and white picture, it turns to the color picture like I had hoped. However, when my mouse leaves the picture, it stays on the color picture.
My code looks like this:
import flash.events.MouseEvent;
stop();
btnCory.addEventListener(MouseEvent.MOUSE_OVER, coryOn);
btnCory2.addEventListener(MouseEvent.MOUSE_OUT, coryOff);
function coryOn(event:MouseEvent):void {
gotoAndStop(10)
}
function coryOff(event:MouseEvent):void {
gotoAndStop(20)
}
btnCory is the first black and white picture at frame 1, btnCory2 is the color picture at frame 10.
Any feedback / help would be much appriciated.
Thanks,
Jeremy
your movieclip with images on frame 1, 10 and 20 should have one name (eg, image_mc) and you don't need to convert the images on frames 1 and 10 (and 20 though there's no point to having a duplicate image on frames 1 and 20) to objects and your code should look something like:
...
import flash.events.MouseEvent;
stop();
image_mc.addEventListener(MouseEvent.MOUSE_OVER, onF);
image_mc.addEventListener(MouseEvent.MOUSE_OUT, offF);
function onF(event:MouseEvent):void {
image_mc.gotoAndStop(10)
}
function offF(e
Copy link to clipboard
Copied
your movieclip with images on frame 1, 10 and 20 should have one name (eg, image_mc) and you don't need to convert the images on frames 1 and 10 (and 20 though there's no point to having a duplicate image on frames 1 and 20) to objects and your code should look something like:
import flash.events.MouseEvent;
stop();
image_mc.addEventListener(MouseEvent.MOUSE_OVER, onF);
image_mc.addEventListener(MouseEvent.MOUSE_OUT, offF);
function onF(event:MouseEvent):void {
image_mc.gotoAndStop(10)
}
function offF(event:MouseEvent):void {
image_mc.gotoAndStop(1);
}
and from a message in the cc forum i see you're using 5 images, so use:
import flash.events.MouseEvent;
stop();
image_mc.addEventListener(MouseEvent.MOUSE_OVER, onF);
image_mc.addEventListener(MouseEvent.MOUSE_OUT, offF);
function onF(event:MouseEvent):void {
MovieClip(e.currentTarget).gotoAndStop(10)
}
function offF(event:MouseEvent):void {
MovieClip(e.currentTarget).gotoAndStop(1);
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now