(Flex 1.5, AS 2)
In my application I need to a call ActionScript function from _javascript_ and pass a couple of parameters back to Actionscript. I am using Flash-_javascript_ integration kit for it. I got it to call the _javascript_ function from ActionScript and back. But it does not pass my parameters back to ActionScript. The result parameter in "sayHelloReturn" function is "undefined".
Here is the script I am using.
===========================================================================
// ActionScript Document
import fast.echo.Echo;
import com.macromedia._javascript_._javascript_Proxy;
public var jsProxy:_javascript_Proxy;
private function appInit(event:Object):Void {
Echo.debug(_root.lcId);
jsProxy = new _javascript_Proxy(_root.lcId, this);
sayHello();
}
//Calls _javascript_ sayHello function
function sayHello():Void
{
jsProxy.call("sayHello", "Homer");
Echo.debug('Homer');
}
//This gets called when a value is returned from the sayHello function in
//_javascript_
function sayHelloReturn(result:Number):Void
{
Echo.debug('sayHelloReturn');
Echo.debug(result);
}
===========================================================================
//_javascript_ Document
<!--- required _javascript_ files to call an ActionScript function from _javascript_ --->
<script type="text/_javascript_" src="">
<script type="text/_javascript_" src="">
<script type="text/_javascript_" src="">
<script type="text/_javascript_" src="">
<script type="text/_vbscript_" src="">
<script language="_javascript_">
//create unique id
var uid = new Date().getTime();
//create proxy to flash
var flashProxy = new FlashProxy(uid, '/common/_javascript_/_javascript_FlashGateway.swf');
//this function is called from Flash
function sayHello(n)
{
//alert ('got here');
var returnString = "Hello " + n + "!";
alert (returnString);
flashProxy.call("sayHelloReturn",5, null);
}
</script>
<script type="text/_javascript_">
var tag = new FlashTag('/flex/internet/monitor/monitor/monitor.mxml.swf', '100%', '100%');
tag.setFlashvars('lcId='+uid);
tag.write(document);
</script>
===========================================================================
Any help you can provide will be greatly appreciated.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
----
To ensure compliance with requirements imposed by the IRS, we inform you that any U.S. federal tax advice contained in this document (including any attachments) is not intended or written to be used, and cannot be used, for the purpose of (i) avoiding penalties under the Internal Revenue Code or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein.
This email may contain confidential and privileged material for the sole use of the intended recipient(s). Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message.
To reply to our email administrator directly, send an email to
[EMAIL PROTECTED]
Littler Mendelson, P.C.
http://www.littler.com

