views:

344

answers:

2

Hi, I have one swf file in that i used fscommand to get final output when submit button clicked in that swf , i am loading that swf in SWFloader in flex3 .i need to get fscommand value as Alert, how to get that value first and display as alert.

Thanks in advance

+1  A: 

fscommand cannot be used for communication between loaded and containing SWFs.

From livedocs

fscommand: Lets the SWF file communicate with either Flash Player or the program hosting Flash Player, such as a web browser. You can also use the fscommand() function to pass messages to Director or to Visual Basic, Visual C++, and other programs that can host ActiveX controls.

You can call a method in the loaded swf OR access its properties directly OR use events OR use local connection to pass data between parent and loaded SWFs.

Amarghosh
A: 

TECHNICALLY this is feasible, but a bad idea. You'd need to register a callback which would call the child swf (generally done from the child swf). But, you will risk a good deal of headache, and you'll have to rely a lot more on the browser than other options. It would also be slower than an AS only solution.

You're much better off (in this order):

  1. Using a shared Singleton. This allows for complete separation of the two swf's without requiring any major coordination between the two. The only real potential problem can be caused if you want the child swf to have its own ApplicationDomain, but even with that, there are work-arounds
  2. Using events. This can work if you have the child swf dispatch a bubbling, non-cancel-able event and have the event.target recorded by the parent swf. You may have to adjust to avoid SecuritySandboxViolations, however.
  3. Using LocalConnections. The two detriments to LocalConnections are:
    • You will need to continually re-generate unique connection names to avoid the error thrown by connecting two LocalConnections to the same channel.
    • LocalConnections do have bandwidth limitations which can call slowdowns if there is a high volume of traffic or if the messages are too large.
  4. Using direct manipulations like loader.content.foo.bar.baz; I don't like this solution because it is much harder to maintain. It is also much worse from a design perspective: you want to use encapsulation as much as possible in this situation -- this technique actively works against that.
Christopher W. Allen-Poole