How do I use AS3 to hide a playbar skin?
I would like to use an overlay skin on a flash project with an imported video. The video is taking up the entire window, so the skinAutoHide attribute does not work, because the mouse leaves the window before the skinAutoHide functionality kicks in. I found this code snippet that hides the playbar as soon as the mouse leves the window:
vpl.skinAutoHide = false;
stage.addEventListener(Event.MOUSE_LEAVE, hideSkin);
stage.addEventListener(MouseEvent.MOUSE_MOVE, showSkin);
function showSkin(evt:Event=null):void {
vpl.skinBackgroundAlpha = .01;
vpl.skin = "SkinOverPlaySeekMute.swf";
}
function hideSkin(evt:Event=null):void {
vpl.skinBackgroundAlpha = 0;
vpl.skin = "";
}
vpl is of course is replaced by your instance name.
This solution works really well until I click the maximize window icon. Now the playbar is stuck in the visible state because the mouse no longer leaves the window. I've read about solutions that involve placing a pixel buffer around the video and enabling skinAutoHide, but this doesn't work if the user moves the mouse quickly off the window.
The same poster of the above code posted a second snippet, that was supposed to hide the skin after several seconds of mouse inactivity.
vpl.skinAutoHide = false;
var LastMouseMove=getTimer();
var MouseStill=false;
stage.addEventListener(MouseEvent.MOUSE_MOVE,function(ev:MouseEvent) { LastMouseMove=getTimer(); });
var MainCheckLoop=setInterval(function() {
if((getTimer()-LastMouseMove)>1000) {
if(MouseStill==false) {
hideSkin();
MouseStill=true;
}
} else {
if(MouseStill==true) {
showSkin();
MouseStill=false;
}
}
},1000);
stage.addEventListener(Event.MOUSE_LEAVE, hideSkin);
stage.addEventListener(MouseEvent.MOUSE_MOVE, showSkin);
function showSkin(evt:Event=null):void {
vpl.skinBackgroundAlpha = .01;
vpl.skin = "SkinOverPlaySeekMute.swf";
}
function hideSkin(evt:Event=null):void {
vpl.skinBackgroundAlpha = 0;
vpl.skin = "";
}
I do not get any compiler errors, but my screen is blank (and I did remeember to change the vpl.skin name to my skin name and name my instance vpl).
I do, however, get an output error: Error #2044: Unhandled skinError:. text=Error #1009: Cannot access a property or method of a null object reference.
If I can get this to work, I think it would be the best solution.
Can anyone help?
Thanks!
Peter
