Search code examples
flashactionscript-3transparencymouseeventrollover

Mouse over help in ActionScript 3 Flash


Im very new to actionscript 3 and I just cant seem to convert my old action script into the newest version (as3). I am trying to set my movie clips from alpha (transparent) to visible when the mouse is rolled over a button. Here is my old code.

//btnOver is a gaint button over my screen that is transparent

function btnOver(event:MouseEvent):void{
    button_overlay._visible = false;
on(rollOver){
    minutes_mc._visible = true;
    hours_mc._visible = true;
    seconds_mc._visible = true;
}
on(rollOut){
    minutes_mc._visible = false;
    hours_mc._visible = false;
    seconds_mc._visible = false;
}

Here is the rest (or whole) of my code in AS3.

import flash.events.MouseEvent;

var date:Date;
var theDate:Date = new Date(  );
var day = theDate.toLocaleDateString()
var time = theDate.toLocaleTimeString()


addEventListener(Event.ENTER_FRAME, refreshHour);
addEventListener(MouseEvent.ROLL_OVER, btnOver);


function refreshHour(event:Event):void{

    date = new Date();

    hour_mc.rotation = date.getHours()*30 + (date.getMinutes()/2);
    hours_mc.rotation = date.getHours()*30 + (date.getMinutes()/2);
    minutes_mc.rotation = date.getMinutes()*6 + (date.getSeconds()/10);
    minute_mc.rotation = date.getMinutes()*6 + (date.getSeconds()/10);
    seconds_mc.rotation = date.getSeconds()*6 + (date.getMilliseconds()/(1000/6));
    second_mc.rotation = date.getSeconds()*6 + (date.getMilliseconds()/(1000/6));
}

date_txt.text = day;

//btnOver is a gaint button over my screen that is transparent

function btnOver(event:MouseEvent):void{
    button_overlay._visible = false;
on(rollOver){
    minutes_mc._visible = true;
    hours_mc._visible = true;
    seconds_mc._visible = true;
}
on(rollOut){
    minutes_mc._visible = false;
    hours_mc._visible = false;
    seconds_mc._visible = false;
}

Basically Im making a flash watch that glows when you roll over it:)

Thanks Joe


Solution

  • const GLOW:GlowFilter = new GlowFilter(0xFF0000);
    
    screen.addEventListener(MouseEvent.ROLL_OVER, _rollOver);
    screen.addEventListener(MouseEvent.ROLL_OUT, _rollOut);
    
    function _rollOver(e:Event):void
    {
        watch.filters = [GLOW];
    }
    
    function _rollOut(e:Event):void
    {
        watch.filters = [];
    }