Following code shows the right way, please read the documentation of "
Flash JavaScript Integration Kit":

http://osflash.org/doku.php?id=flashjs


You need to place "com\macromedia\javascript\" directory,
JavaScriptFlashGateway.js and JavaScriptFlashGateway.swf  next to file
and you need other files.

That's why I am asking you to read documentation on above link to get an
idea, how to setup the Flash JavaScript Integration Kit.


##FJIKExample.jsp##

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="FlexTagLib" prefix="mm" %>
<HTML>
<HEAD>
<script type="text/javascript" src="JavaScriptFlashGateway.js"></script>
<script language="javascript">

 window.onbeforeunload = confirmExit;
  function confirmExit()
  {
       var flashProxy = new FlashProxy('mmid',
'JavaScriptFlashGateway.swf');
     flashProxy.call('comm');
     return "You have attempted to leave this page.  If you have made
any changes to the fields without clicking the Save button, your changes
will be lost.  Are you sure you want to exit this page?";
  }
</script>

<%@ page
language="java"
contentType="text/html; charset=GBK"
pageEncoding="GBK"
%>
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="../theme/Master.css" rel="stylesheet"
    type="text/css">
<TITLE>test.jsp</TITLE>
</HEAD>
<BODY>
    <mm:mxml id="mmapp" name="mmapp">
        <mm:flashvar name="lcId" value="mmid" />
        <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
creationComplete="onAppInit()">
            <mx:Script>
            <![CDATA[
                import com.macromedia.javascript.JavaScriptProxy;
                var jsProxy:JavaScriptProxy;
                var lcId:String;
                
                function onAppInit()
                {
                    jsProxy = new JavaScriptProxy(lcId, this);
                }
                function comm(){
                    alert("in flash");
                    trace("!!!ZF, this in test JS and AS
communication");
                }
            ]]>
            </mx:Script>
            <mx:Button label="click" click="comm();"/>
        </mx:Application>
    </mm:mxml>
 </BODY>
</HTML>



-abdul

 

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Abdul Qabiz
Sent: Wednesday, June 29, 2005 4:17 PM
To: [email protected]
Subject: RE: [flexcoders] puzzled with JavaScript and Flash Integration
Kit

 Hold on, I will post an example...something is going wrong here...

I am in meeting now :)

-abdul

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Banks
Sent: Wednesday, June 29, 2005 3:57 PM
To: [email protected]
Subject: Re: [flexcoders] puzzled with JavaScript and Flash Integration
Kit

Hi, Abdul,

Thank you very much.  i try this, but it does not take the effect. my 
jsp file is :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="FlexTagLib" prefix="mm" %>
<HTML>
<HEAD>
<script type="text/javascript" src="Exception.js"></script>
<script type="text/javascript" src="FlashTag.js"></script>
<script type="text/javascript" src="FlashSerializer.js"></script>
<script type="text/javascript" src="FlashProxy.js"></script>
<script language="javascript">

 window.onbeforeunload = confirmExit;
  function confirmExit()
  {
       var flashProxy = new FlashProxy('mmid', 'mmapp');
     flashProxy.call('comm');
     return "You have attempted to leave this page.  If you have made 
any changes to the fields without clicking the Save button, your changes

will be lost.  Are you sure you want to exit this page?";
  }
</script>

<%@ page
language="java"
contentType="text/html; charset=GBK"
pageEncoding="GBK"
%>
<META http-equiv="Content-Type" content="text/html; charset=GBK">
<META name="GENERATOR" content="IBM WebSphere Studio">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="../theme/Master.css" rel="stylesheet"
    type="text/css">
<TITLE>test.jsp</TITLE>
</HEAD>
    <mm:mxml id="mmapp" name="mmapp">
        <mm:flashvar name="lcId" value="mmid" />
        <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
            <mx:Script>
            <![CDATA[
                function comm(){
                    alert("in flash");
                    trace("!!!ZF, this in test JS and AS
communication");
                }
            ]]>
            </mx:Script>
            <mx:Button label="click" click="comm();"/>
        </mx:Application>
    </mm:mxml>
</HTML>



Abdul Qabiz wrote:

>Yeah...
>
>That should work, as long as you are also passing lcId to Flex App
using
>FlashVars attribute of <mm:mxml ../> like this:
>
><mm:mxml>
>   <mm:flashvar name="lcId" value="<%= lcId %>" />
>
>   <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
>      
>   </mx:Application>
></mm:mxml> 
>
>
>
>-abdul
>-----Original Message-----
>From: [email protected] [mailto:[EMAIL PROTECTED] On
>Behalf Of Banks
>Sent: Wednesday, June 29, 2005 12:01 PM
>To: [EMAIL PROTECTED] Com
>Subject: [flexcoders] puzzled with JavaScript and Flash Integration Kit
>
>Hi, All,
>
>I am try to use this tool. But as an flex new user, I am be puzzled
with
>
>this tool.
>The docs for this are about the flash file.
>
>
>if i place this tag "<mm:mxml source="/Test/test.mxml" id="mmapp" 
>name="mmapp"/>" in my JSP file, does this mean I can construct the 
>flashProxy like this:
>var flashProxy = new FlashProxy('mmapp', 'mmapp');
>
>  
>



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



 




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



 




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