That most definitely sounds like a bug ...  I think the following would 
work:

- Create a class LocalConnectionDaemon in AVM2 that is connected under a 
hardcoded LC name. ( e.g. "LC_DAEMON" );

-  Create a class LocalConnectionDaemon in AVM1 that does the following:
    - Generates a unique LocalConnection URL based on the 
current-time-millis ( e.g. var clientId:String = "LC_CLIENT_1324343243243" )
    - Send a command to LocalConnectionDaemon via - LC_SERVER  .. 
createClient( clientId )
    - Listen for a command (on that same LocalConnection, or one the 
server can figure out) called   onClientCreated( otherClientId:String )

- LocalConnectionDaemon should have a method  "createClient( 
clientId:String )" that takes the ID, and transforms it to a guaranteed 
unique name
    (e.g.  var newClientId:String = clientId + "_AVM2") and sends  
onClientCreated( newClientId );
 
Definitely more painful, but doable.  I should point out that one big 
issue with LocalConnection is that messages are limited to 40kb. You may 
need to chunk your requests over if they are large.


Also, just thought this would be a good time  to point out Adobe's  
bug-report / wishlist page. If you send them a *reproducable*
bug report, they will get back to you very quickly:

http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

Regards,
-D




Ian Thomas wrote:
>
> Hi guys,
>
> I've hit a huge hurdle when trying to communicate between AVM1 and AVM2.
>
> I've been trying to create a component - call it AVM1Loader - which
> will allow simple communication between an AVM2 flex app and a
> contained AVM1 file.
>
> In theory, it's pretty simple:
>
> - Use Loader to load the file.
> - Create a LocalConnection for AVM2 to talk to AVM1
> - Create a LocalConnection for AVM1 to talk to AVM2
>
> This all works fine, and communications all work.
>
> However, the problem comes with the naming of the LocalConnections.
> Clearly each AVM1Loader instance wants to have a differently named
> pair of LocalConnections; otherwise you'll get into trouble if you're
> trying to have two AVM1Loaders running together at the same time - or
> even two instances of the same Flex app running together at the same
> time.
>
> Generating a unique ID is easy, but I can't for the life of me work
> out how to communicate it to the contained AVM1 file.
>
> The obvious way would be to pass it as a parameter: e.g.
> _loader.load(new URLRequest("AVM1File.swf?key="+someUniqueKey));
>
> That works, but only (apparently) once. The next time you try to load
> AVM1File.swf with a _different_ key (under a whole new instance of
> AVM1Loader) something very odd happens. The key value does get
> transmitted correctly on the second run, but the _root of the
> contained movie gets screwed up.
>
> These simple trace statements are on the root of AVM1File.swf:
>
> trace(_root);
> trace(_root.clip); // (Clip is an instance defined on the stage of 
> AVM1File)
> trace(_parent);
>
> On the first (successful) load (i.e. loading
> "AVM1File.swf?key=someUniqueKey"), I get:
> "_root"
> "_root.clip"
> "undefined"
>
> Which is as expected. On the second run through (i.e. loading
> "AVM1File.swf?key=someOtherKey"), I get:
>
> "_root"
> "_level0.App0.Panel4.contentPane.AVM1Loader40.instance55.instance56.clip"
> "_level0.App0.Panel4.contentPane.AVM1Loader40.instance55"
>
> Which is very strange - suddenly my AVM1 code is seeing its AVM2
> instance name. And from that point on, the AVM1 code stops working
> correctly - loading clips etc. fails.
>
> If I change the URL to just "AVM1File.swf" it all works fine, but
> obviously my unique key doesn't get transmitted. Similarly, fixing the
> URL - sending "AVM1File.swf?key=dummy" each time - works fine.
> Somethings up when you alter the parameter.
>
> It's a new instance of Loader() - I'm not reusing anything.
>
> So - that's clearly some sort of bug, and I seem to have hit a blank
> wall there. If anyone's got any ideas on that peculiarity then great.
>
> But that aside, if anyone's got any brainwaves on how to simply
> communicate a unique ID to an AVM1 file I'm loading, that'd be great.
> :-)
>
> Yours in frustration,
> Ian
>
>  



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to