FLVPlayBack not scaling to fullscreen - actionscript-3

I'm trying to make an instance of FLVPlayBack run in fullscreen, without affecting the rest of the application.
According to stuff I've read, I have set the players scale mode so it will fit the window when its scaled up.
flvPlayer.scaleMode = "exactFit";
And in order to stop the stage from scaling up I've also set the stage's scale mode too.
stage.scaleMode = "noScale";
Then in order to try and control what the video player does when I click the fullscreen button, I also use the fullScreenTakeOver setting on the player.
If I set the code like to 'false'
flvPlayer.fullScreenTakeOver = false;
Then the whole interface becomes fullscreen, with the stage positioned in the centre of the window, I guess this is because I set the stage not to scale. The video stays its normal size and carries on doing what it was doing. Exiting fullscreen shrinks the stage back to normal.
If, on the other hand I set it to 'true'
flvPlayer.fullScreenTakeOver = true;
Then the video takes over the screen, but it doesn't scale up, instead it positions the video in the middle of the page, and the clickable areas of the controls move to where they would be if the video was full size, leaving my guessing where the buttons should be.
In both cases the video carries on running fine.
Can anyone help me with the right combination of settings? I want the application to stay its windowed size and the fly player to scale to fit fullscreen by itself.
Thanks.

There is a property in flvplayback named fullScreenTakeOver which is set by true by default. this will interfere with fullscreen really bad. if you want to apply fullscreen without changing logic of your stage you better set this as false after instantiation. this will decrease your troubles a lot

You'll want to set a few settings which some you've already done
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
flvPlayer.fullScreenTakeOver = false;
Now when you enter full screen your application stuff will positioned top left. You will want to make an event listener for full screen mode.
stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
In that event is where you will handle resizing and moving the video (Also hiding other objects on the stage if need be)
function fullScreenHandler(e:FullScreenEvent):void
{
if (stage.displayState == StageDisplayState.NORMAL)
{
// Setup NORMAL Layout
// resize and reposition the flvPlayer
}
else
{
// Setup FULL_SCREEN Layout
// move the flvPlayer to x:0 and y:0
// set the flvPlayer width and height to stage.stageWidth and stage.stageHeight
}
}

Related

Is my Flash SWF on screen?

I'd like my flash movie to not play until it's visible on screen and then pause when off screen. Is there a way to capture some event indicating that the swf is rendering or visible or within the visible bounds of the browser window that I can addEventListener to so I'll know when it's within view?
Use Flash's ExternalInterface to call a javascript function that checks to see if the element of off screen. In javascript, use JQuery with the Viewport plugin to figure out if we're off screen. (http://www.appelsiini.net/projects/viewport).
I haven't tested the Viewport plugin, but I've talked to people who use it, and it worked out OK for them.
In as3:
var returnValue:int = ExternalInterface.call("jsCheckerFunction");
if(returnValue == 1) // your flash is on-screen.
in javascript:
function jsCheckerFunction()
{
if($("#flashContent:in-viewport").length > 0)
return 1; // flash div visible
return 0; // returns 0 if the element is offscreen
}
You could have it call jsCheckerFunction on each frame to see if the status has changed.

Changing the Stage size during runtime in AS3

Can we change the stage size during runtime?
I need to change the size of the stage dynamically during the runtime when the swf receives a flashvar from the html page. Can this be done?
If you resize the <object> / <embed> elements in your HTML, that will resize the stage of the SWF.
The content of the SWF however will scale unless you specify that there will be no scaling within AS3:
stage.scaleMode = StageScaleMode.NO_SCALE;
It is also important to note when working with scalable SWFs that by default, the exported stage dimensions will always sit centred within the resized area, e.g.
I find it easier when everything is measured from the top-left of the resized area, which can be done by adding this as well:
stage.align = StageAlign.TOP_LEFT;
It's possible using flash.external.ExternalInterface
if (ExternalInterface.available) {
ExternalInterface.call('JSResizeBlockFunction');
}
JSResizeBlockFunction should be a javascript function defined on top level on the same page as running swf.
In this function you should change size of div in which <object>/<embed> is wrapped.
But your swf on page should have size in percents to receive RESIZE event.

Retrieve original stage width and height after scale

Does anyone know how I can retrieve the "ORIGINAL" stage height and width that was set during compile of an Air/Flash Application
I have set the Application to compile to 1920x1080;
I have stage.scaleMode = StageScaleMode.SHOW_ALL;
and stage.nativeWindow.maximize();
But when I trace stage.stageWidth I get 1280 which is the resolution of the screen.
I was hoping to get the 1920.
I cannot use stage.width or stage.getBounds(stage) because this returns 6000. Due to items being masked off screen.
With the stage.stageWidth being the screen resolution, I was hoping I could use that and mathematically work out the original using stage.scaleX. but even with SHOW_ALL scaling the entire application, stage.scaleX returns 1.
I would love to hardcode 1920x1080 into the application, but this code is being used in multiple applications of various dimensions. And now I have become stumped.
Any help would be welcome.
EDIT: I know what "Show all" does, you do not need to tell me about it.
I also know what stage.width and stage.stageWidth do, but stage.stageWidth is returning what I believe is incorrect in this example and need an alternative.
Resize does not help either as I need it after the fact.
when you are setting:
stage.scaleMode = StageScaleMode.SHOW_ALL;
the Event.RESIZE is not beeing dispatched from the stage, because no RESIZE of the stage is happening.
stage.width - is the parameter which gives you the size of all the display objects placed on it ( imagine everything what is places on the stage as a one MC ).
stage.stageWidth - this parameter will give you back the default width only ( because no REIZE is happening, since you have scaleMode=SHOWALL, normally it does return the visible flash stage size.
If you want to get the size of a screen ( device rezolution ):
Capabilities.screenResolutionX
SHOW_ALL parameter for scaleMode says application to stretch to the flash display size.
If you want to change something for different sizes of the screen / flash display stage,
you need to use NO_SCALE property.
p.s. for width parameter same rules applies.
UPDATE
After some testing found a solution for it:
stage.scaleMode = StageScaleMode.NO_SCALE; // reseting the scale to get actual width
ACTUAL_STAGE_WIDTH = stage.stageWidth; // this is where you getting the width you need
stage.scaleMode = StageScaleMode.SHOW_ALL; // setting back the scale.
#Jevgenij Dmitrijev solution was a bit of a hack. (No Offense)
The real answer for getting the published SWF Size is using
this.loaderInfo.width;
this.loaderInfo.height;
Found it on an older actionscript forum and it was something that i myself forgot.
you can look up loader info on ASdoc's and they'll give you an in-depth explanation.

AS3 How do you scale video down?

I have a webcam capturing video at a certain resolution, but I want to display it at a lower resolution for preview purposes.
When I scale the video down using another another video object set at this lower res, the image quality seems to be quite bad.
What is the best way of doing this?
On the video object set
video.smoothing = true;
set smoothing to true and change the scaleX and scaleY properties.
myVideo.smoothing = true;
myVideo.scaleX = myVideo.scaleY = 0.5;

as3 | Flash | How Can I make fixed width-height when on full screen

After I export the .swf file in a certain size (1024*768) and then resize it manually (dragging the mouse to enlarge the screen) - everything stays in the same width and height.
After I export the .exe/.app file in a specific size (1024*768) and then resize it manually - everything scales (and I don't want that).
How can I define in the as3 settings to leave the width/height size static and not dynamic.
How can I tell the .exe file to get the full width and height of the current display?
I ask that because I want to have a full-size flash file that in the center there is the static sized stage.
To prevent scale use:
stage.scaleMode = StageScaleMode.NO_SCALE;
To enter fullscreen use:
stage.displayState = StageDisplayState.FULL_SCREEN;
Have a look at the docs
Take a look at the scaleMode property of stage. In your case it seems you would want to set it to StageScaleMode.NO_SCALE. The stageAlign property might be of interest too.
Read more in the livedocs.