| Flash In your Flash application create a LocalConnection object and add to it functions that you want the Flex application to call. These are the 'messages' I've been mentioning. var fromFlex_lc:LocalConnection = new LocalConnection(); fromFlex_lc.stopMe = function() { stop(); } fromFlex_lc.playMe = function() { play(); } fromFlex_lc.connection( "lc_from_flex" ); The stopMe and playMe functions are very simple and just stop and play the timeline. But they can of course, be much more complex. Flex is going to invoke them when the user clicks a button. Flex In your Flex application, create a LocalConnection object and use it to invoke the stopMe and playMe functions in the Flash SWF. import flash.net.LocalConnection; var toFlash_lc:LocalConnection = new LocalConnection(); The buttons invoke the LocalConnection.send() method, naming the connection that the Flash SWF is listening on. The second argument to the send() method is the name of the function to invoke. If the functions have any arguments, they follow the method name. Flash to Flex As you might expect, having the Flash SWF send messages to the Flex SWF is just the reverse. And that is true with the exception of where you define the messages the LocalConnection.send() method invokes. In the Flex application you create an object which has the functions you want invoked from the LocalConnection. For example: <mx:Application xmlns:mx="..." initialize="initApp()" > |
Posted on 2006/10/13 14:30
Filed Under 분류없음