On 3/1/06, Mike Potter <[EMAIL PROTECTED]> wrote:
> I'm going through the example here,
> http://labs.macromedia.com/wiki/index.php/ActionScript_3:resources:FAQ#How_can_I_call_a_JavaScript_function_from_ActionScript.3F
> on how to call a JS function from ActionScript.
>
> I have the following MXML:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml";
> xmlns="*" layout="absolute">
>         <mx:Script>
>                 <![CDATA[
>                         import flash.external.ExternalInterface;
>
>                         public class ExternalInterfaceTest
>                         {
>                                 public function ExternalInterfaceTest()
>                                 {
>                                         
> ExternalInterface.call("myJavaScriptFunction", "Hello World");
>                                 }
> }
>                 ]]>
>         </mx:Script>
> </mx:Application>
>
> Why do I get an error that says "Classes must not be nested" on the
> line for public class ExternalInterfaceTest?

... because you're declaring ExternalInterfaceTest inside your main
application class.  It should be in a separate file instead, not
nested the way it is here.

> More importantly, what is the correct code for calling a JS function
> via AS, and vice versa?  Oh, and I'm happy to edit the wiki when I
> find out what's wrong. :)

This is the correct way.

Manish


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