Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Load external AS2 SWF, pass it a root variable

Guest
Nov 27, 2007 Nov 27, 2007
Hello all,

I am creating an AS3 program, but unfortunately I need to load some legacy SWF files that I can't alter. These old files are dynamic charts, and each one is fed an XML file with it's data.

The original implementation had these chart files on HTML pages, and each one was given it's datafile URL on the query string, like so:

<PARAM NAME=movie VALUE="FC2MSColumn.swf?dataUrl=../ChartXML/ideationbyage.xml">

My problem is that I now need to load these same SWF files into my AS3 program, and somehow feed it this _root variable in the same way it would have gotten them in the original HTML implementation. I'm kind of stumped on how to accomplish this though. I've heard grumbling about the Localconnection methods, but in my case I don't need to read anything from my old AS2 files, I need to set that initial value, just as if I'd put the file on a webpage and given it a flashvar or query string value.

Any pointer or tips would be greatly appreciated! I'd be stunned if this was not possible.
TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Nov 28, 2007 Nov 28, 2007
well it took a little messing about with, but yes, Raymond's suggestion did work. As he said, it will only work in the browser. I had to make a few minor changes, as the way he had it results in a type coercion error when trying to directly enter the file path into the request. Ultimately I ended up with this:

var imgDisplay:Loader=new Loader;
var url:String = screenXML.image[imgtoload] + "?dataUrl=" + screenXML.image.@df;
var req:URLRequest = new URLRequest(url);
imgDisplay.load(req);
displayC...
Translate
Community Expert ,
Nov 27, 2007 Nov 27, 2007
the previous advice you'd received was correct: use localconnection.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 27, 2007 Nov 27, 2007
Can you elaborate at all? Everything i read shows examples where there needs to be some kind of scripting in BOTH sides, sending and receiving, but as I said I can't alter my original AS2 files as I didn't create them and don't have the source. So I can't tack in any kind of logic to them.

I load my AS2 file via the loader and need to give it that "dataUrl" variable parameter when it initializes.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2007 Nov 27, 2007
Why not just use the original path? It won't work with the file system, but
should function properly in a browser.

var loader:Loader = new Loader();
addChild(loader);
var req:URLRequest = new
URLRequest("FC2MSColumn.swf?dataUrl=../ChartXML/ideationbyage.xml");
loader.load(req);



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 27, 2007 Nov 27, 2007
quote:

Why not just use the original path? It won't work with the file system, but
should function properly in a browser.

var loader:Loader = new Loader();
addChild(loader);
var req:URLRequest = new
URLRequest("FC2MSColumn.swf?dataUrl=../ChartXML/ideationbyage.xml");
loader.load(req);



hmm, that's an interesting though. I'll have to give that a try and see if it works. Might be better than nothing I suppose. Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2007 Nov 27, 2007
that's correct. you'll need to add script to your as2 file to enable its use of the variable. if you're unable to do that, you're out of luck using as3 to load that as2 file.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 27, 2007 Nov 27, 2007
ah, well that really sucks. Thanks for the help anyways.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2007 Nov 27, 2007
you're welcome.

the problem lies in that as2 file that can't be edited: it must have that variable defined immediately upon opening.

so, there's no hope of devising a work-around without using a html file to pass that value to the as2 swf.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2007 Nov 27, 2007
did it work?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 28, 2007 Nov 28, 2007
LATEST
well it took a little messing about with, but yes, Raymond's suggestion did work. As he said, it will only work in the browser. I had to make a few minor changes, as the way he had it results in a type coercion error when trying to directly enter the file path into the request. Ultimately I ended up with this:

var imgDisplay:Loader=new Loader;
var url:String = screenXML.image[imgtoload] + "?dataUrl=" + screenXML.image.@df;
var req:URLRequest = new URLRequest(url);
imgDisplay.load(req);
displayContainer.addChild(imgDisplay);


Thanks for the that suggestion, that saved me a huge amount of hassle.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines