[mtasc] Issues with Flash / Javascript Kit

Mike Leahy mgleahy at alumni.uwaterloo.ca
Sat Sep 24 20:40:21 CEST 2005


Ok, I finally got it to work.  I just changed my JavaScript to match
yours Swithun (i.e., two FlashProxy args, and no tag.setId), and I
changed the scripts that were being called from:


<script type="text/javascript" src="/web/jsfl/Exception.js"></script>
<script type="text/javascript" src="/web/jsfl/FlashProxy.js"></script>
<script type="text/javascript" src="/web/jsfl/FlashSerializer.js"></script>
<script type="text/javascript" src="/web/jsfl/FlashTag.js"></script>
<script type="text/vbscript" src="/web/jsfl/VBCallback.vbs"></script>
       
to:

<script type="text/javascript"
src="/mapchat/jsfl/JavaScriptFlashGateway.js"></script>
<script type="text/vbscript" src="/mapchat/jsfl/VBCallback.vbs"></script>

Now it works like a charm...*except* I'm now getting a javascript error
that says "functionToCall has no properties".  As I understand it, from
looking at the code, this is to handle Flash to JS calls - any
suggestions on how to make this work?

Thanks so much for your help.

Mike

Swithun Crowe wrote:

>Hello
>
>  
>
>>Can anyone suggest how I need to alter my Tuto.as script to make this work?
>>    
>>
>
>I've just got this to work with a project I've been working on. There are
>a few differences between my code and yours, but not many.
>
>/*
>  main.as
>*/
>import MySound;
>import com.macromedia.javascript.JavaScriptProxy;
>
>class Main
>{
>   static function main(mc:MovieClip) {
>      _root.s = new MySound();
>      _root.proxy = new JavaScriptProxy(_root.lcId, _root.s);
>   }
>}
>
>/*
>  MySound.as
>*/
>class MySound {
>  var s:Sound;
>  public function MySound()
>  {
>    this.s = new Sound();
>  }
>  public function playSound(t:String)
>  {
>    this.s.loadSound(t + ".mp3", true);
>    this.s.start(0, 1);
>  }
>}
>
><!-- some html page -->
>....
><script type="text/javascript">
>  var uid = new Date().getTime();
>  varflashProxy = new FlashProxy(uid, '../JavaScriptFlashGateway.swf');
></script>
><script type="text/javascript">
>  function playFile(t) {
>    flashProxy.call('playSound', t);
>  }
></script>
>....
><script type="text/javascript">
>  var tag = new FlashTag('../playtune.swf', 1, 1, '7,0,14,0');
>  tag.setFlashvars('lcId='+uid);
>  tag.write(document);
></script>
>
>The main differences are that I use _root.proxy, a different class to
>accept the proxy calls (_root.s, not this), and that the JavaScript
>FlashProxy constructor takes just 2 arguments. I've just looked at the
>documentation for the  Flash JavaScript Integration Kit, and they do show
>a constructor with 3 arguments. But it doesn't look like they have
>released a new version since I got mine a few weeks ago. Check your copies
>of FlashProxy.js and JavaScriptFlashGateway.js to see what they accept.
>
>Maybe you just need to change the line
>
>proxy = new JavaScriptProxy(_root.lcId, this)
>
>to
>
>this.proxy = new JavaScriptProxy(_root.lcId, this);
>
>(is the ; missing in your actual code?)
>
>Hope some of this helps.
>
>Swithun.
>
>  
>
>>~~~~~~~~~~~~~~~~~~~~~~~~~Tuto.as~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>import com.macromedia.javascript.JavaScriptProxy;
>>
>>class Tuto {
>>
>>    static var app:Tuto;
>>
>>    var mySocket:XMLSocket = new XMLSocket();
>>
>>    var proxy:JavaScriptProxy;
>>
>>    //var uid = Date().getTime();
>>
>>    //var flashProxy = new FlashProxy(uid, 'myFlashContent',
>>'/mapchat/jsfl/JavaScriptFlashGateway.swf');
>>
>>    function Tuto() {
>>
>>        proxy = new JavaScriptProxy(_root.lcId, this)
>>
>>        _root.createTextField("tf",0,0,0,800,600);
>>
>>        mySocket.onConnect = handleConnect;
>>        mySocket.onClose = handleClose;
>>        mySocket.onXML = handleIncoming;
>>        //mySocket.onData = handleData;
>>        // specify your server and port number here
>>        //if (!mySocket.connect("localhost", 800))
>>gotoAndStop("connectionFailed");
>>        if (!mySocket.connect("localhost", 9999))
>>        {
>>            _root.tf.text += "\n" + "connection failed";
>>        }
>>
>>    }
>>
>>    function handleConnect (succeeded) {
>>        if(succeeded) {
>>            _root.tf.text += "\n" + _root.lcID + "\n" + "connection
>>succeeded";
>>        } else {
>>            _root.tf.text += "\n" + "connection failed";
>>        }
>>    }
>>
>>    function handleClose () {
>>        _root.tf.text += "\n" + "connection closed";
>>    }
>>
>>    function handleIncoming (messageObj) {
>>
>>        _root.tf.text += "\n" + messageObj.toString();
>>
>>    }
>>
>>    public function addText (someText) {
>>        _root.tf.text += "\n" + someText;
>>    }
>>
>>    // entry point
>>    static function main(mc) {
>>        app = new Tuto();
>>    }
>>}
>>
>>~~~~~~~~~~~~~~~~~~~~~~~~~Flashtest.html~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>><html-DEFANGED>
>>    <head-DEFANGED>
>>        <title-DEFANGED>title</title>
>>        <script-DEFANGED type="text/javascript"
>>src="/web/jsfl/Exception.js"></script>
>>        <script-DEFANGED type="text/javascript"
>>src="/web/jsfl/FlashProxy.js"></script>
>>        <script-DEFANGED type="text/javascript"
>>src="/web/jsfl/FlashSerializer.js"></script>
>>        <script-DEFANGED type="text/javascript"
>>src="/web/jsfl/FlashTag.js"></script>
>>        <script-DEFANGED type="text/vbscript"
>>src="/web/jsfl/VBCallback.vbs"></script>
>>        <script-DEFANGED type="text/javascript">
>>            var uid = new Date().getTime();
>>            var flashProxy = new FlashProxy(uid, 'myFlashContent',
>>'/web/jsfl/JavaScriptFlashGateway.swf');
>>
>>            function callFlashEvent()
>>            {
>>                flashProxy.call('addText','whatever');
>>            }
>>
>>        </script>
>>    </head>
>>    <body-DEFANGED>
>>        <script-DEFANGED type="text/javascript">
>>
>>            // The arguments below are path, width, height, and Flash
>>Player version.
>>        var tag = new FlashTag('/mapchat/Tuto.swf', 800, 400, '7,0,14,0');
>>        tag.addFlashVar('lcId=' + uid);
>>        tag.setId('myFlashContent');
>>        tag.write(document);
>>
>>        </script>
>>        <input-DEFANGED type="button" value="Add Text"
>>onClick="callFlashEvent();">
>>    </body>
>></html>
>>--
>>MTASC : no more coffee break while compiling
>>
>>    
>>
>
>  
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/mtasc/attachments/20050924/236e5b7f/attachment-0003.htm


More information about the mtasc mailing list