Flash redirect SWF file - html

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

Related

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

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">

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.

FLV Player not works in IE Browser?

I have the following piece of code which play the flv file,
<embed align="middle" width="185" height="121"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" allowfullscreen="true"
allowscriptaccess="sameDomain"
name="vidplayer" bgcolor="#eae7db" quality="high" f
lashvars="file=<?= $vUrl; ?>" src="scripts/flvplayer.swf" />
Above code which works only in FF,chrome not in IE Browser.
Also i refered link How to embed a SWF file in an HTML page? changed the above code like below,
<object width="185" height="121">
<param name="movie" value="<?php echo BASE_URL; ?>scripts/flvplayer.swf">
<embed align="middle" width="185" height="121"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" allowfullscreen="true"
allowscriptaccess="sameDomain" name="vidplayer" bgcolor="#eae7db"
quality="high" flashvars="file=<?= $vUrl; ?>"
src="scripts/flvplayer.swf" >
</embed>
</object>
This above code works only in FF not in Chrome and IE.
How can i play my flv file in all browsers ?
Try this way.
<script type="text/javascript">
var flashvars = {};
var params = {};
var attributes = {};
flashvars.mp3="mast.mp3";
var so = new swfobject.embedSWF("player.swf", "myContent", "300", "120", "9.0.0",true, flashvars, params, attributes);
so.write("myContent");
</script>
and have a look at this Documentation.

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.

Passing variables to Class from HTML

I want to pass some image names and numbers as string to my flash, so in html file I have :
src="imgvid-00.swf?imageData=image00/00.gif,3,image00/01.gif,6,image00/02.gif,10"
in flash swf I have a class like this:
package src{
import flash.display.*;
import flash....
public class imgvid extends MovieClip {
public var dataBANK:Array = new Array();
public function imgvid():void {
//put all var in Array dataBANK
}
}
}
How I do this?
I try :
public var paramObj = this.loaderInfo.parameters;
but that does not work ...
You need to pass paramters in as flashvars. query parameters are not passed into flash in the way you have in your example. Read up about flashvars here:
http://kb2.adobe.com/cps/164/tn_16417.html
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="myFlashMovie" align="middle">
<param name="movie" value="myFlashMovie.swf" />
<param name=FlashVars value="myVariable=Hello%20World&mySecondVariable=Goodbye">
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="myFlashMovie.swf" width="550" height="400">
<param name="movie" value="myFlashMovie.swf" />
<param name=FlashVars value="myVariable=Hello%20World&mySecondVariable=Goodbye">
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
using swf object to do all this makes it easier than doing it manually as above
http://code.google.com/p/swfobject/