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

Getting (xml) data into a swf file

New Here ,
Feb 11, 2010 Feb 11, 2010

hi Guys,

I posted here yesterday and thanks for being so nice to me!

My current query is how to get data into a flash file.

I inherited a .swf file and I am in the process of incorporating it into my java web application.

It currently reads in an xml file that sits in the same directory as the .swf file.

The previous programmer saved the xml file after a database query to fill it, and has the same file name each time. I'm thinking that this isn't very scaleable, if more than one person wants to use the application at the same time.

If I was going to add a session id to distunguish files, I'm not sure how I would do it as the Flash file has a hardwired string in it.

var strXML:String = "seq_list.xml";

I considered using FlashVars to load in the xml file but its going to be consistantly over the 64k limit so I'm guessing thats not going to work.

Does anyone have any ideas? Am I missing the big idea? Incidently, I am new to Flash and actionscript3 but willing to learn 🙂

Cheers

Sandy

TOPICS
ActionScript
1.7K
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
Feb 11, 2010 Feb 11, 2010

64K limit? There's no such thing. Using a FlashVar to point to the XML you want to load would probably be your best bet.

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
New Here ,
Feb 11, 2010 Feb 11, 2010

hi,

Thanks, at least thats an avenue I can explore.

Sandy

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
New Here ,
Feb 16, 2010 Feb 16, 2010

hi,

I am now trying to read in parameters from my html file into my as3 file.

The original code that I am reading in from used the same file name for the XML each time-I would rather add a date-stamp to the end of the XML file and then more than one person can use the app at the same time 🙂

So what I want to do is to read in a parameter name and value and then add this to the file name already in my as3 file and use that.

I know its dead simple but having read around about inputting parameters and retrieving them, I'm struggling.

original code------------------------------------------------------------------------------------

import fl.containers.ScrollPane;import fl.containers.ScrollPane;

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();

var cell_spacing:Number = 0.4425;

var strXML:String = "seq_list.xml";

xmlLoader.addEventListener(Event.COMPLETE, LoadXML); 
xmlLoader.load(new URLRequest(strXML + "?" + Math.random())); //

var sp:ScrollPane = new ScrollPane();
this.addChild(sp);

var mcHolder:MovieClip = new mc_holder();

....more code.....

my alterations in bold---------------------------------------------------------------------

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();

var cell_spacing:Number = 0.4425;

var myXmlId:String;

this.loaderInfo.addEventListener(Event.COMPLETE, xmlLoaderComplete);

var strXML:String = "seq_list_"+myXmlId+".xml";

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
 
xmlLoader.load(new URLRequest(strXML + "?" + Math.random())); //

var sp:ScrollPane = new ScrollPane();
this.addChild(sp);

var mcHolder:MovieClip = new mc_holder();


function xmlLoaderComplete(myEvent:Event):void
{
  var myQueryStrings=this.loaderInfo.parameters;
  myXmlId=myQueryStrings.xmlId;
}

....more code.....

The result that I am getting is that my application is looking for a file named "seq_list_null.xml" so presumably I'm not setting myXmlId correctly.

I'm sending it from the html file like:

<param name="movie" value="/seq_list.swf?xmlId=2" />

I presume this line is ok and the problem is coming in with the loading in the as3 file.

Can anyone point out what is wrong?

Thanks,

Sandy

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
New Here ,
Feb 17, 2010 Feb 17, 2010
LATEST

hi,

I found this eventually which works.

Sandra

try {
 
      var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;

      for (keyStr in paramObj) {

          valueStr = String(paramObj[keyStr]);

          theVars.push(keyStr, valueStr);
          // theVars.push({key:keyStr, val:valueStr}); didn't need an array of hashes

      }

      this.init();
 
      } catch (error:Error) {
 
      trace(error.toString());

}
var myXmlId:String = theVars[1];

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