I've got the following javascript writing HTML for FlexPlayer:
document.writeln("<object width=\"489\" height=\"414\" FlashVars=\""+videoSource+"\">");
document.writeln("<param name=FlashVars value='sourceUrl=videoSource'>");
I need to have FlashVars="sourceUrl=videoSource"; where videoSource is a variable which I get from PHP for the current video and sourceUrl is variable form the Flex player. Please repair the int he first row cause this FlashVars syntax is driving me mad.
You should use SWFObject as an easier way to embed your swf into your website. It also has a very simple way to include parameters (flashvars) into your movie in the documentation.
Related
First, I tried finding an option to prevent Swiffy from compressing/minifying all the data when doing an export to HTML5 from Adobe Flash Pro. But no dice.
Even if I was able to read the unminified Javascript that Swiffy exported, I don't think there would be a simple function call for the "clickTag".
It's likely defining the variable clickTag in the huge haystack of {index: #, type: #}, and then doing processing each operations to eventually call the window.open() method (or something similar).
This is how it currently outputs (minified)
Does anyone have any clue how Swiffy implements clickTag?
Or what would be the Javascript equivalent that does the same job?
Swiffy uses the core API of the environment where the ad is served. If it's a DoubleClick Rich Media ad, it does use Enabler.exit("url").
If you want to have a better control on your output file, I'd suggest having a look at Google Web Designer. The closest experience to flash development in the HTML5 - JS era.
Google instructions are here, for plain HTML5 (non-swiffy) click tags.
At the bottom of the file is a snippet of code like this:
<script>
var stage = new swiffy.Stage(document.getElementById('swiffycontainer'),
swiffyobject, {});
stage.start();
Add this right before stage.start(); to mimic previous flash behavior. Ensure you use the proper capitalization.
stage.setFlashVars("clickTAG=http://stackoverflow.com");
**Note: Ensure to use url encoding if there are parameters...doesn't seem to like it otherwise
The main thing in this i have written a code for swf and also the html and i need to pass the 2 parameters from html to swf i am passing clicktag param and other parameter. i know how to access the clicktag param in action script but i am getting confused to use the another parameter passed with that. i am accessing clicktag as _root.clickTAG so i can easily access it but when i wanted to use another param in the same way nothing is happening . can you anyone please help me regarding this.
Thanks in Advance
You need to pass in two variables using FlashVars. At it's simplest you can just use
<PARAM NAME=FlashVars VALUE="clickTAG=http://www.domain.com&secondParam=12345">
(though it is worth looking at swfObject to embed the swf). Then in Flash (AS2) you can access the vars directly, eg
on (release) {
getURL(clickTAG + "&mySecondVarIs" + secondParam, "_blank");
}
inside a movie clip we have to address to root like _root.clickTAG otherwise it does not work.
Can you please give me some leads into passing variables from a HTML(or)ASP.NET file to Flash Action Script 3 file.
Please Help.
Thanks
Here is an in-depth tutorial by Adobe on this subject.
To summarize, you have two options:
Add FlashVars="myVariable=value" attribute to your <embed> tag which embeds your SWF
Add <param name=FlashVars value="myVariable=value"/> to your <object> tag which embeds your SWF
After this you can access your "key" variable from the document class or any display object attached to the stage using:
var myVariable:String = LoaderInfo(this.root.loaderInfo).parameters.myVariable.toString();
Good luck coding : j
I'm trying to get current browser url. I have already tried with External Call, and it didn't work. And with loaderInfo.url I receive the current SWF url.
Give this a go:
import flash.external.ExternalInterface;
var url:String = ExternalInterface.call("window.location.href.toString");
if (url) textfield.text = url;
should do the trick.
There are a couple of ways to solve this problem, however all of them involve the use of JavaScript to query the browser directly.
My preferred way to solve this problem would be to provide the URL via a flashVar property, direct from the embed code (personally, I would reccomend using SWFObject to make this easier); don't forget you will need to URL Encode it to avoid markup issues.
var flashvars = {
browserURL: escape(location.href)
};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0", "expressInstall.swf", flashvars);
Now you will be able to access the Browser URL via the loaderInfo object:
trace(stage.loaderInfo.parameters["browserURL"]);
note that this will only work if you have control of generated HTML for your SWF file - if users are going to be grabbing the SWF and writing their own embed HTML, it's not going to work.
If you don't have control of the flash embed HTML, then you will need to get flash to query the browser at runtime using the ExternalInterface class; other people have suggested the use of "window.location.href.toString" however this can prove problematic in IE6, I find the following works reliably across all browsers
const browserURL : String = ExternalInterface.call("eval", "window.location.href");
Note that in order for this to work, you will need to grant JavaScript access to your Flash movie, this is done, again, via the HTML embed code and the allowScriptAccess param
var url:String = loaderInfo.loaderURL;
seems to work too.
I would try passing the required info in as a flashvar. Not the best out of the box solution I know, but it will work.
Flash: FlashVars in AS3
i think its posible to use the external interface an do it with javascript window.location
I have been using flash for a long time and never noticed this one. It only gives the domain though for security. It does work through loaded swfs as well. Not sure about iframes.
Security.pageDomain
I have tried following things to access the FlashVars from HTML in the flash movie.
Added the Flashvars in embed tag
added the FlashVars in param tag
added the FlashVars in JavaScript code generated by the Adobe Flash compiler
Tried to access the FlashVars by using: root.loaderInfo.parameters.param_name and root.loaderInfo.parameters["param_name"]
But still I am not able to access the FlashVars. Can somebody guide me to the correct solution.
Have you tried embedding the swf with swfobject? is has a really simple syntax to pass flashvars.
to access them, I use:
var params:Object = LoaderInfo(this.root.loaderInfo).parameters;
var var1:String = params['var1'];