How to set dynamic variables in flash (swf) that are passed from javascript?

271 Views Asked by At

I'm trying to modify an SWF using a flash decompiler. I found a SWF that plays a live crypted stream rtmps and I want to use it to embed on my website. I want to be able to change the url for the stream with javascript:

//FUNCTION IN FLASH

public var serverName:String;

function frame1() : *
  {
     this.nc = null;
     this.serverName = "rtmps://and_the_stream_url";
     this.streamName = "A name";
     this.stageListener = new Object();
     this.videoSizeTimer = Number(0);
     this.videoLastW = Number(0);
     this.videoLastH = Number(0);
     this.fullscreenCapable = false;
     this.hardwareScaleCapable = false;
     this.debugInterval = Number(0);
     this.bufferTime = Number(3);
     this.mainInit();
  }

So I basicly want to be able to set the serverName variable with something that I pass with javascript when embedding it on my website.

The javascript i´v been looking at is SWFObject.. for example:

var flashvars={};
flashvars.serverName = "my url..";

swfobject.embedSWF("myContent.swf", "my-target-element", "300", "120", "10.0.0", flashvars);

How do I modify the code in flash (swf file) so that it reads the value I´m passing from javascript?

(IF there are other better ways to include a live stream rtmps stream on a website then also let me know :) I have tried using the flowplayer but I only manage to play rtmp-streams with it)

1

There are 1 best solutions below

0
On BEST ANSWER

The flashvars are stored in stage.loaderInfo.parameters. So if you want to loop over all flashvars it would be something like this:

var flashVars:Object = stage.loaderInfo.parameters;

for (var key:String in flashVars) 
{
    var value:String = flashVars[key] as String;
    trace(key + ' = ' + value);
}