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

how do i send variables to a flash file using swfloader???

New Here ,
May 19, 2010 May 19, 2010

Copy link to clipboard

Copied

hey guys... so im trying to load a swf using the SWFLoader, and i need to some how send a variable to that swf, and in that swf i need to capture that variable if that makes any sence...

the swf is made in flash, and a function init is called everytime the swf loads...

in that init function in the flash actionscript i need to capture the variable i send from flash builder....

so far i have the following code...


in this code i have no idea on how to send variables to my swf

        var swfLdr:SWFLoader = new SWFLoader();
        swfLdr.horizontalCenter = 0;
        swfLdr.verticalCenter = 0;
       
        swfLdr.source = "http://test-broadcast.apxinsider.com/Content/swf/office_weekly_UF.swf";
        swfLdr.addEventListener(Event.INIT, swfLoaded);
        swfLdr.load();

now i was htining i could do somehting like office_weekly_UF.swf?id=1304 or somehting... but if i do that, how do i capture this in my swf???

any thing would help! thank you so much!

Views

1.1K

Translate

Translate

Report

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 ,
May 20, 2010 May 20, 2010

Copy link to clipboard

Copied

any takers??

Votes

Translate

Translate

Report

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
Jun 02, 2010 Jun 02, 2010

Copy link to clipboard

Copied

Hi,

I'll put up what i think is the answer. Do tell me if this is what you are looking for. When I created the swf in Flash Pro.This is the code I used

var keyStr:String;

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

for (keyStr in paramObj) {

urlText.text = String(paramObj[keyStr]);

}

urlText is a text box whose content text is passed as a URL parameter. The parameters can be retrieved from paramObj. Is that what you meant by capturing the variables?

Then on the flex side, this is the code i used to display from SWFloader

           import mx.controls.SWFLoader;
            private var swfLdr:SWFLoader;
            private function startSWF():void
            {
                swfLdr = new SWFLoader();
                swfLdr.horizontalCenter = 0;
                swfLdr.verticalCenter = 0;
                swfLdr.source = "MySWF.swf?urlText=verbose";
                addElement(swfLdr);
            }

I hope this helps.

Nishad

Votes

Translate

Translate

Report

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 ,
Jun 02, 2010 Jun 02, 2010

Copy link to clipboard

Copied

hi Nishad, well i looked a lot into this, and i found out that after loading the swf i am able to access public function and variables after the swf has loaded, therefore i just modified all the swfs to fit my need, where i just ended up doing somehting like the following

     swfLdr = new SWFLoader();
          swfLdr.horizontalCenter = 0;
          swfLdr.verticalCenter = 0;
          swfLdr.source = "/content/swf/" + tempFileName;
          swfLdr.addEventListener(Event.COMPLETE, swfLoaded);
          swfLdr.load();
}
private function swfLoaded(event:Event):void{
     swfLdr.removeEventListener(Event.COMPLETE, swfLoaded);

     childSwf = new MovieClip();
     childSwf = event.target.content;

     childSwf.init(1);

}

Votes

Translate

Translate

Report

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
Jun 02, 2010 Jun 02, 2010

Copy link to clipboard

Copied

Oh.. Nice. This is good info. If you've resolved any of the other issues like the sandbox issue, do post your findings.

Nishad

Votes

Translate

Translate

Report

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 ,
Jun 03, 2010 Jun 03, 2010

Copy link to clipboard

Copied

LATEST

i havent read thru the sandbox article yet, but i just ended up moving my release build swf to the server to get around that problem....

Votes

Translate

Translate

Report

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