I’ve been making a video player based on Lee Brimelow’s tutorials and everything works fine, but I would like to add a few things - like the ability to change the position of the scrubber with a mouse click and not only by dragging. I would also like to add volume control to the movie.
I’m not very good with AS, so I figured this would be a good place to look for help.
I have uploaded the source file for your convenience
My next question.
The controls on the player fade out if the mouse is not on them. The menu usues a simple hitTest function. However, when I move the mouse out of the stage too fast the menu will not fade out. I know there is a function in AS3 that let’s you check if the mouse left the stage, but is there a way to do something similar in AS2?
[QUOTE=pantas;2352338]how is the hitTest called? is it onEnterFrame? or set Interval?
you can get the size of the stage, and check the position of the mouse then. if it isn’t within it, means its out :)[/QUOTE]
Interval. Here is the code:
var d = 1;
var delay = setInterval(startTracking, 30);
function startTracking() {
if (menuBar.hitTest(_root._xmouse, _root._ymouse) && d) {
d = 0;
menuBar.alphaTo(100,1);
}
if (!menuBar.hitTest(_root._xmouse, _root._ymouse)) {
if (!d) {
menuBar.alphaTo(0,1);
d = 1;
}
}
}
Could you give me an example of what you mean? Do I just define the stage size and make a if/else statement?
I have added a button that makes the player go into a fullscreen mode.
The problem is that when I set the Stage.scaleMode to scale the movie scales nicely, but the movieclip with controls scales with it and I can’t seem to scale it back to it’s original size.
When I set the scaleMode to noScale and scale the video itself I have the MC with controls the size I want it, but the video looses it’s original aspect ratio and is stretched either horizontally or vertically depending on it’s original aspect ratio.
So my question is, how do I scale something with “scale” scaleMode, or how do I retain the original proportions of a scaled object with “noScale”?
Ok, for anyone interested. With some internet resources I’ve menaged to get the scaling code right. Now the video is scaled retaining it’s aspect ratio and the controls stay unscaled and always on the bottom of the video (not on the bottom of the stage).
I’ve also changed the control fade out/fade in code, so now the fading is based on mouse activity. It uses an Inactivity class that you can download from here.
import org.casaframework.util.Inactivity;
///MENU ACTIVARION SCRIPT
var inactiveTime:Number = 1;
function onInactive(sender:Object):Void {
menuBar.alphaTo(0,1,"easeInOutQuad");
}
function onReactive(sender:Object):Void {
menuBar.alphaTo(100,1);
}
var inactivityDetect:Inactivity = new Inactivity(inactiveTime * 1000);
this.inactivityDetect.addEventObserver(this, Inactivity.EVENT_INACTIVE);
this.inactivityDetect.addEventObserver(this, Inactivity.EVENT_REACTIVE);
As you can see the code, thanks to the class, is fairly simple, but lacks one thing - I would lke the controls to stay in the most “fade in” state while the mouse is over them and not disappear. I can do that with a simple hitTest, but there are 2 problems with that.
Problem 1. If the menu was fading out and you move the mouse over it, the menu will stop in the middle of the fadeout animation and be very faint. I’m pretty sure if’s because I’m calling the alphaTo function twice for the same object.
Problem 2. Again, if I use the hitTest and move the mouse too quickly away from the stage the menu will not fade out.