I have a Flash Builder 4 project that's hooked up to a Flash Professional CS5 FLA. I do NOT use MXML, and all code is handled directly in Flash Builder. (Flash itself is used simply for the library, and its easier for our artists to use)
Everything's been going along without a hitch, everything runs off of dynamically generated XML from the site the SWF is embedded to. But up until now I've had the XML path hardcoded in the actionscript. I wish simply to not make it so.
I have followed minimum 45 tutorials on getting FlashVars into FB4/As3, and quite simply nothing seems to be working. Old school < embed > method, using < object > method, and even using swfObject method, simply I cannot seem to access these flashvar properties.
here's the html that i currently have now:
<script>
var flashvars = {
xml: "/mapsystem/xml"
}; // yes that is definitely the correct path, its the same value as when it was hardcoded
$(function() {
swfobject.embedSWF("/flash/map.swf", "map", "960", "885", "10.0.0", "expressInstall.swf", flashvars);
});
</script>
<div id="map">
swfObject Aint Working
</div>
Heres the actionscript (this is in my Document class, first thing)
package
{
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import src.GlobalStage;
import src.Map;
import src.Styles;
public class map extends GlobalStage
{
public var xmlDoc = "map.xml";
public function map()
{
var test:TextField = new TextField();
test.x = 50;
test.y = 50;
test.autoSize = TextFieldAutoSize.LEFT;
test.text = "XML Doc: ";
this.addChild(test);
var test2:TextField = new TextField();
test2.x = 50;
test2.y = 80;
test2.multiline = true;
test2.border = true;
test2.autoSize = TextFieldAutoSize.LEFT;
test2.text = "Parameters: \n";
test2.appendText("Total Parameters: ");
this.addChild(test2);
var _params:Object;
if ( this.loaderInfo.parameters.length != null ) {
_params = this.loaderInfo.parameters;
} else {
// run alt code to init
}
for(var pItem:String in _params) {
test2.appendText("Name: " + pItem + " :: " + _params[pItem] + "\n" );
}
if(_params['xml'] != null) xmlDoc = _params['xml'];
test.appendText(xmlDoc);
var map:Map = new Map(xmlDoc);
Now, when i run this on my local test, nothing shows up as per expected, but when it comes to being on the site itself, with a passed flashvar, the xmlDoc remains "map.xml", my counter tells me there are 0 parameters, and of course nothing shows up in my list of parameters.
I have spent 8 hours trying to get this to work, quite frankly I'm losing hair and sleep over this.
root.loaderInfo.parameters
instead ofthis
. – weltraumpirat