SRL Archive - Computer Help and Tutorials

[Photoshop/Flash CS4] Create an Emulating Bulb Effect


WhoCares357

2009-02-13 22:58:04

A little video I made showing the process of two things:
1) Creating a simple bulb image in Photoshop.
2) Animating that bulb image (with a little actionscript) to add a dim out/brighten up effect on mouse over/mouse out.

http://www.youtube.com/watch?v=szjVyIuRRGs&feature=channel_page

The code on frame 1 in the "actionscript" layer:
stop();

var changeFrameBy:int = 0;

backBulb.addEventListener(MouseEvent.MOUSE_OVER, posDir);
backBulb.addEventListener(MouseEvent.MOUSE_OUT, negDir);

addEventListener(Event.ENTER_FRAME, moveFrame);

function posDir(event:MouseEvent):void
{
changeFrameBy = 1;
}

function negDir(event:MouseEvent):void
{
changeFrameBy = -1;
}

function moveFrame(event:Event):void
{
if ((currentFrame > 0) && (currentFrame <= 30)
&& (changeFrameBy < 0))
{
gotoAndStop(currentFrame + changeFrameBy);
}

if ((currentFrame >= 0) && (currentFrame < 30)
&& (changeFrameBy > 0))
{
gotoAndStop(currentFrame + changeFrameBy);
}
}