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'];
Related
I am bound to provide a full URL : www.abc.com/folder1/folder2/my.xml rathar than just giving relative URL "./my.xml" .
How can i solve this ? This forces me to hardcode the URL inside the .as file .
I can't understand what you actually need: relative or absolute URL?
If relative, use it. Just consider that it should be relevant to the HTML wrapper, not the SWF itself.
If absolute and you just do not want to embed it into the code, pass it to your SWF from the HTML wrapper using FlashVars.
You can use a relative url in the flash, and the fact that it's working when you test locally indicates a problem with the embed. My guess is that you have placed the swf in a subfolder from the html page but not specified a base url when embedding the swf. Is the swf file located in www.abc.com/folder1/folder2/ or any other folder other than the html itself?
If so, you need to tell the flash player which url all relative url:s in the flash should use as a starting point. This is done using the "base" parameter. If you embed the swf using SWFObject you specify it with an object with a base property:
var flashvars = {
};
var params = {
base: "/folder1/folder2/"
};
var attributes = {
};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0","expressInstall.swf", flashvars, params, attributes);
Note that I assumed that the .swf is in folder2/ in the example above.
Hope this solves your problem.
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.
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