Hi guys,

Check this out, if you make the following changes to Jason Wong's
little example, then SWF is able to call a function in Flex2.  I got
it to fire a function -- no sending of arguments yet.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";
xmlns="*" layout="absolute">
   <mx:Script>
   <![CDATA[
        import mx.controls.Alert;
        public var arg:String;
                
        private function onClick(): void
        {
        var swf: MovieClip = MovieClip(myLoader.content);
        var myMC: MovieClip = MovieClip(swf.getChildByName("myMC"));
        myMC.myRect = this.source();   //get function reference.  

        }
 
         public function  source():void {
                Alert.show ("callback");
        }

                ]]>
        </mx:Script>
        
        <mx:Loader id="myLoader" x="5" y="5" source="SimpleSWF.swf"/>   
        <mx:Button x="10" y="167" label="Button" click="onClick()"/>
</mx:Application>


In the myClip.as file -- By the way, in order to get jason's
Simple.swf to compile in the flash IDE, you'll need to change the
following:

1. MyClip movie Linkage from "MyClip" to "myClip" 
2. Change the "MyClip.as" file name to "myClip"


Make the following changes to myClip.as
-----------------------------------------------------------------

class myClip extends MovieClip

{
        
 
        function set myRect(funcRef: Object): Void
        {
                _parent.lineStyle(2, 0xff0000);
                _parent.moveTo(60, 60);
                _parent.lineTo(200, 60);
                _parent.lineTo(200, 100);
                _parent.lineTo(60, 100);
                _parent.lineTo(60, 60);
 

                funcRef;

        }
        
 
}

-----------------------------------------------------------------

What should happen....  If you click on the button it should popup an
Alert box displaying the word "callback"

Cheers,

Tim













--
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/

<*> 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