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
Related
I creadet a class that has more ResourceBundles in it. My app is multilanguage so I will need many ".properties" files.
here is a sample code
[ResourceBundle("LocalizedStrings_en_US")]
[ResourceBundle("LocalizedStrings_fr_FR")]
...
public class LocaleLoader
{
...
}
My question is if I add many ResourceBunlde lines in this class, will the file size of the main swf increase drastically or not?
Should use separata class files to load separate ResourceBundles for each language?
The [ResourceBundle] annotation itself won't have any effect on the file size. It's the -locale compile option of the mxmlc that matters.
-locale=en_US means to embed only the US-locale in the SWF
-locale=en_US, ja_JP means to embed both the US-locale and the Japan-locale
If you don't embed the Japan-locale you can load it at runtime with resourceManager.loadResourceModule(...).
To address completely the topic of Flex Localization Support please refer to the Slides & Samples in the Flex Localization Support article I wrote in the Obecto Training Portal.
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.
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 ActiveX control done in VC++/MFC. It embeds into html web page. Now I need to be able to configure it by providing parameters in html tag. like:
The question is how do I read those parameters during my ActiveX initialization? My research revealed that it has to be done through IPersistPropertyBag interface, but I could really use some code examples to figure that out.
Any examples in VC++ please?
Thanks,
Mike
I will answer my own question...
Basically from ActiveX point of view those HTML parameters are "persistent storage" parameters.
So in your HTML file:
<OBJECT ID="activex1" WIDTH=300 HEIGHT=200
...
<PARAM NAME="ServerAddress" VALUE="192.168.1.1:1234">
...
</OBJECT>
And in your MFC ActiveX control:
void Cubcam_activexCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
// TODO: Call PX_ functions for each persistent custom property.
PX_String(pPX, _T("ServerAddress"), m_serverAddress, _T(""));
}
Interesting; I will have to try the method you describe. The way that I know of to do this is to implement the IPersistPropertyBag interface and implement the Load method.
I haven't used MFC, just ATL, but I implemented this by hand. I will have to look into the solution you provided to see if there are advantages to the underlying approach used by MFC.