Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting flashvars in swf embedded in swf using Javascript 1

Status
Not open for further replies.

AndrewBaines

Technical User
Apr 19, 2002
463
GB
I'm setting and reading flashvars from javascript. All works well, but now I have a swf inside another swf.
Using SetVariable only sets the variable in the container swf, and I need it in the inner one.
I'm using Xcelsius to generate the swf, so I'm pretty limited on what I can do, so it all needs to be done in javascript.

How do I get to the inner swf?
Thanks
Andrew
 
From inner SWF you can access the variable like this:

_parent.variable

From container SWF you can set the variable in inner SWF:

MovieClipWithInnerSWF.variableToBeSet = variable

Kenneth Kawamoto
 
Not sure I can do that.
I'm hosting the swf in HTML. I access the outer swf using document.myMovie etc etc.
The code needs to be in the HTML, not the swf - I have no control over the swf itself.
 
Getting nearer!

Is /innerMC always the name of the inner swf (surely not?) or is it defined somewhere.

If it's defined somewhere, how do I find it? Is there a collection I can iterate over? I'm not able to set the name of the inner swf.

Thanks for help so far

Andrew
 
innerMC" is the name I gave to the MovieClip in the outer SWF (inner SWF is loaded into this MovieClip.) You mean you don't know the name of the MovieClip? You can either decompile the outer SWF, or create a Flash document which loads outer SWF and inspect. You also need to know the name of the variable in the inner SWF you're setting from Javascript. (In the example above I called it "variable".)

Kenneth Kawamoto
 
The inner movie clip is a linked swf. The weird way Xcelsius works means that I've defined the name of the variable in the inner swf, but I'm not able to give the clip or it's container a name.
I've decompiled it once, but it wasn't clear what the clip name was, I'll take a look in the morning to see if I can work it out.

What property is set to give the clip a name?
Thanks
Andrew
 
> What property is set to give the clip a name?

"_name" is the name of the property to set/get MovieClip instance's name. (But normally you will set the name of the MovieClip when it's created, i.e. using "attachMovie()" or "createEmptyMovieClip()", you may not find "_name" in the code.)

Have a look at Xray - create a Flash document with Xray, load outer SWF (which loads inner SWF) into it. You may be able to workout what's happening inside of both outer and inner SWFs.

Kenneth Kawamoto
 
I couldn't work out what to do with Xray (do I need flash or just the player), but I decompiled using Flash decompiler 2.99.
The code generated seems incredibly long winded!
I found every reference to attaching and creating movies (lots), and tried them all in my Javascript without any joy.
I also found the function that attaches the external swf. It's done as an onClipEvent, but doesn't appear to give a name (I guess that happens elsewhere?).
The constructor is just externalFile ={};
Then relevant properties appear to be:
externalFile.embed = false;
externalFile.filename = "test1/fpmdata2.swf"
externalFile.clipName = "pic"
externalFile.pathName = "\\\\......etc...\\...swf"

I thought maybe the clipName was relevant, but it's used for all external files.

Thanks for all your help, but I think I'll give up.

Andrew
 
onClipEvent" is old fashioned way of doing things and the problem here is you don't have to have the MovieClip named as the event handler is directly applied to the MovieClip. However Flash always assign a name if a MovieClip has no name - this name would be "instance1", "instance2" etc.

If you create a blank FLA which loads your SWF you may be able to see the name in the Debugger window (or use Xray) - if you haven't really given up yet...

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top