AS3 fullscreen doesn't work even with button click and allowfullscreen - actionscript-3

I'm trying to simply add fullscreen capability to my flash movie.
I created a button on the stage (root > setfullscreen) and added that code on root:
var isfullscreen=false;
setfullscreen.addEventListener(MouseEvent.CLICK, SetFullscreen);
function SetFullscreen(event:MouseEvent):void
{
if (isfullscreen)
stage.displayState = StageDisplayState.NORMAL;
else
stage.displayState = StageDisplayState.FULL_SCREEN;
isfullscreen=!isfullscreen;
trace(isfullscreen);
}
And I load the swf like that:
<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://macromedia.com/cabs/swflash.cab#version=6,0,0,0'
ID=flaMovie>
<PARAM NAME="movie" VALUE='movie.swf'>
<PARAM NAME="quality" VALUE="high">
<PARAM NAME="allowfullscreen" VALUE="true">
<EMBED src='movie.swf'
style='width:800px;height:560px'
TYPE='application/x-shockwave-flash'>
</EMBED>
</OBJECT>
I don't find anything else to do, but it doesn't work, nothing happen when clicking the button, just the trace which switch from true to false when testing the movie in flash.

I believe you need to add the allowFullScreen to the embed tag as well:
<embed src="movie.swf" allowFullScreen="true">

Related

How to load external variable into swf to play a different movie file using AS3

I'm an AS3 noobie and need some help.
I want to load a movie dependant on a variable. For example i want to load from
'http://example.com/test/'+variable+'.mp4'
So i decide this time i want to play x.mp4 - how do i do this in AS3?
This is what i have so far:
// ActionScript 3.0
var video:Video = new Video();
addChild(video);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = {onMetaData:ns_onMetaData, onCuePoint:ns_onCuePoint};
video.attachNetStream(ns);
ns.play("http://example.com/test/"+variable+".mp4");
function ns_onMetaData(item:Object):void {
trace("metaData");
// Resize video instance.
video.width = item.width;
video.height = item.height;
// Center video instance on Stage.
video.x = (stage.stageWidth - video.width) / 2;
video.y = (stage.stageHeight - video.height) / 2;
}
function ns_onCuePoint(item:Object):void {
trace("cuePoint");
trace(item.name + "\t" + item.time);
}
thanks for your help
You use FlashVars for that:
http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html
Here's the code from the example. Notice that there are two different Flashvars entries:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
width="550"
height="400"
align="middle"
id="main">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="main.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="FlashVars" value="one=1&two=2" />
<embed src="main.swf"
width="550"
height="400"
autostart="false"
quality="high"
bgcolor="#ffffff"
FlashVars="one=1&two=2"
name="main"
align="middle"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
If you use swfobject (https://code.google.com/p/swfobject/) it has built in support for it.
EDIT:
A more simple example would be:
http://helpx.adobe.com/flash/kb/pass-variables-swfs-flashvars.html
It contains an example for just 1 variable named "myVariable":
LoaderInfo(this.root.loaderInfo).parameters.myVariable;
The page also has a test project online.

actionscript full screen not allowed

This is my code to add the button onto stage
private function add_fullScreenBtn(height:Number):void
{
button_fullScr = new Sprite();
button_fullScr.useHandCursor = true;
button_fullScr.buttonMode = true;
button_fullScr.mouseChildren = false;
button_fullScr.x = height;
button_fullScr.y = btn_y;
var fullScr_Btn:Bitmap = new fullScreenImage();
button_fullScr.addChild(fullScr_Btn);
button_fullScr.addEventListener(MouseEvent.CLICK, fullScreenHandler);
addChild(button_fullScr);
}
This is the code for handling the event when the user clicks on fullscreen button
private function fullScreenHandler(event:MouseEvent):void
{
trace("Here");
// stage.displayState = StageDisplayState.FULL_SCREEN
if (this.stage.displayState== StageDisplayState.NORMAL) {
//stage.displayState="fullScreen";
this.stage.displayState=StageDisplayState.FULL_SCREEN_INTERACTIVE;
stage.scaleMode = StageScaleMode.NO_SCALE;
} else {
//stage.displayState="normal";
this.stage.displayState=StageDisplayState.NORMAL;
}
}
This is the code of html page
<html>
<head>This is the Test Page
</head>
<body>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://.../swflash.cab#version=9,0,0,0"
width="550" height="400" id="sample" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="movie" value="sample.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#333333" />
<embed src="sample.swf" quality="high" bgcolor="#333333"
width="550" height="400"
name="sample" align="middle"
allowscriptaccess="sameDomain"
type="application/x-shockwave-flash"
allowFullScreen="true"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</embed>
</object>
</body>
</html>
When I am running this page I am getting error that full screen mode is not allowed. security exception. When I am tracing it on console its printing "here"
can anyone suggest how can i solve the error
I had to add the line to scale the image i.e i added the following line
stage.scaleMode = StageScaleMode.NO_SCALE;
before
stage.displayState = StageDisplayState.FULL_SCREEN;
and it worked

Flash redirect SWF file

Is there a way to get click event then redirect on swf embedded object?
Below is the code I have at the moment but it doesn't seem to be working
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="560" height="80" id="ad_cat" align="">
<param name="movie" value="http://roadsonline.com.au/assets/ads/COA0460_560x80.swf?clickTAG=catredir.php">
<param name="wmode" value="transparent" />
<embed src="http://roadsonline.com.au/assets/ads/COA0460_560x80.swf?clickTAG=catredir.php" quality="high" width="560" height="80" name="movie" wmode="transparent" align="" type="application/x-shockwave-flash" plugins page="http://www.macromedia.com/go/getflashplayer">
</object>
There are two parts, HTML and the clickTAG in the SWF.
I believe your html should work - although i recommend a hardlink like http://yoursite.com/redirect.php. So lets talk Flash shall we?
I wrote a tutorial for click tags for my employees a while back which explains what you need to do in flash. This is AS2:
http://ryanhollingsworth.com/index.php/banner-ad-tutorials/item/34-actionscript-20-basic-clicktag-and-fundamentals
AS3 ClickTAG:
import flash.display.MovieClip;
var hit = new MovieClip();
hit.graphics.beginFill(0xFFFFFF);
hit.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
var clicky = new SimpleButton(null,null,null,hit);
this.addChild(clicky);
clicky.addEventListener(MouseEvent.CLICK, function(e){
if(root.loaderInfo.parameters.clickTAG) navigateToURL(new URLRequest(root.loaderInfo.parameters.clickTAG), "_blank");
e.stopPropagation();
});
further reading:
http://helpx.adobe.com/flash/kb/pass-variables-swfs-flashvars.html

startimage for swf video

Hi I am trying to show startimage before my swf video starts playing, I am using flashVars to do this but for some reasons its not working, below is my code:
<object id="M97012085" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1440" height="900" style="overflow: auto; align:middle;" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0">
<param name="movie" value="path_to_swf" />
<param name="loop" value="false" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="wmode" value="transparent" />
<param name="play" value="true" />
<param name="flashVars" value="image=path_to_png" />
<embed bgcolor="#ffffff" align="middle" name="M97012085" loop="false" src="path_to_swf" width="1440" height="900" flashVars="image=path_to_png" style="overflow: auto; align:middle;" play="true" wmode="transparent" quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Could you please point out what I am doing wrong ? Is it possible to have a image which user can click to start the video ? Thanks
Ravi, please use a swfobject to embed your flash files:
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = { 'image' : 'path-to.png' };
var params = { 'allowFullScreen' : 'true', 'wmode' : 'window' };
var attributes = { };
swfobject.embedSWF( 'index.swf, 'flashIndex', '100%', '100%', '10.1.0', 'swf/expressInstall.swf', flashvars, params, attributes );
</script>
More info: http://code.google.com/p/swfobject/
Then if you are using AS3.
before you initialize the video player, load image which was parsed to you by flashvars:
imageLoader = new Loader ();
imageLoader.contentLoaderInfo.addEventListener ( Event.COMPLETE, placeImageOnStage )
imageLoader.load ( new URLRequest ( loaderinfo.parameters.image ) ); // the flashvar parameter
after it is beeing loaded initialize your video.
function placeImageOnStage ( e : Event ) : void
{
addChild ( imageLoader.content ) // add your image to stage
enableVideoControls ();
prepearVideo ();
// or something else
}
What is the flash player you are using? Are you certain that startimage is a parameter that your specific player uses?
if your video is or can be an FLV file have a look at flowplayer. Specifically this page with a splash image example.

jwPlayer in IE does not auto start video on display of rolling banner

I got a probleme with the famous jwPlayer. In fact the probleme is with the way IE (8 or 7) handle the flash player.
Their's the probleme: I got a rolling banner (using jquery cycle), in this banner i got 2 images an a video. The video is drive using jwPlayer. The way I expect the banner work is this:
roll on each banner
if the banner is the video start it.
This is the javascript:
$('#slideshow')
.before('<div id="nav">')
.cycle({
fx: 'fade',
timeoutFn: calculateTimeout,
timeout: 20000,
pause: 1,
pager: '#nav'
});
function calculateTimeout(currElement, nextElement, opts, isForward) {
if ($(nextElement).attr("class") == "video-banner") {
return 20000;
} else {
return 8000;
}
I have set the loop variable at true and the autostart at true either as you can see:
<div runat="server" id="video" class="video-banner">
<!-- START OF THE PLAYER EMBEDDING TO COPY-PASTE -->
<object id="Object1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" height="384" type="video/mp4">
<param name="movie" value="/uploads/Banner/Rainmaker.mp4" />
<param name="wmode" value="window" />
<param name="allowfullscreen" value="false" />
<param name="allowscriptaccess" value="always" />
<param name="loop" value="true" />
<param name="flashvars" value="file=/uploads/Banner/Durp.mp4&autostart=true" />
<embed
type="application/x-shockwave-flash"
id="player2"
name="player2"
src="/jwplayer/player.swf"
width="612"
height="384"
allowscriptaccess="always"
allowfullscreen="false"
autostart="true"
wmode="window"
loop="true"
flashvars="file=/uploads/Banner/Durp.mp4&autostart=true&amp"
/>
</object>
<!-- END OF THE PLAYER EMBEDDING -->
<img style="border-width: 0px;" src="/Uploads/Banner/banner.jpg">
</div>
In all normal browser, when the video come in the banner he start by himself.
Can someone help me to me make me doing the same behavior in IE (7 and 8) as in normal browser?
You should try FlowPlayer
Here is the website: http://flowplayer.org/