[Flashjs] New to the list, my two cents on the current version

lti-1a8g@myamail.com lti-1a8g at myamail.com
Mon Nov 14 19:33:42 EST 2005


Hi,

I'm new to the list, and I now I should first read the archives but, heh ;)

I found that the currently available version of the Flash Javascript 
Integration Kit (downloaded from 
http://weblogs.macromedia.com/flashjavascript/) was somehow buggy (at 
least on my configuration) :
PC Windows 2000
Authoring Env : Flash Studio Pro MX2004, 7.2

Since I managed to get it working anyway, here's the thing I found (I've 
only tried so far to do JS to AS)

1) The documentation on OSFlash is not in sync with the current release
http://osflash.org/flashjs/docs/usage/astojs

a)
"To call an ActionScript function from JavaScript, make sure the four 
required JavaScript files are included in your HTML page like this: "
===> The "VBCallback.vbs" file is not packaged with the kit. Is this 
sample code up to date ?

b)
 "Now, create an instance of the FlashProxy JavaScript class and pass in 
the unique ID you just created, the ID or name of your Flash content 
(the value of the id attribute you will use in the object tag, and the 
value of the name attribute you will use in the embed tag), and the path 
to the JavaScriptFlashGateway.swf file, like this:
var flashProxy = new FlashProxy(uid, 'myFlashContent', 
'/path/to/JavaScriptFlashGateway.swf');
"
=> the example code should be modified as
var flashProxy = new FlashProxy(uid, '/path/to/JavaScriptFlashGateway.swf');
since the FlashProxy constructor only has two arguments : (uid, 
proxySwfName)

c)
"The FlashTag class contained in the project makes it easy to generate 
Flash tags and add the necessary flashvars, like this:
<script type="text/javascript">
// The arguments below are path, width, height, and Flash Player version.
var tag = new FlashTag('/path/to/flashContent.swf', 300, 300, '7,0,14,0');
tag.addFlashVars('lcId=' + uid);
tag.setId('myFlashContent');
tag.write(document);
</script> "
===> the "addFlashVars" in the FlashTag class doesn't exists, it's (now 
?) "setFlashvars"

d) Whole paragraph
"For more advanced use cases, the FlashProxy object takes an additional 
optional argument called "callbackScope". If you want Flash to invoke 
functions in a scope other than the default document, pass in a 
reference to the desired scope. For example, if I have a JavaScript 
object called "callback," I can instantiate the FlashProxy like this in 
order to have Flash call functions on the "callback" instance:

var flashProxy = new FlashProxy(uid, 'myFlashContent', '/path/to/JavaScriptFlashGateway.swf', callback);
"
==> huh ? The only constructor in FlashProxy.js is 
function FlashProxy(uid, proxySwfName)
{
	[...]
}


2) As given, the Flash Javascript Integration Kit doesn't work on my platform
When I add the two lines in order to receive javascript calls in my swf, whenever I compile (target : Flash Player 6, ActionScript 2.0), I have errors, can't debug, and can't get the AStoJS communication working:
The errors are located in 'com.macromedia.javascript.JavaScriptProxy.as', in the constructor :
line #108 ("receiving_lc.controller = this;") : No such property as 'controller'.
line #110 ("receiving_lc.callFlash = callFlash;") : No such property as 'callFlash'.

The solution I found is just to extend the "LocalConnection" class to add the two properties 
in a "JavaScriptLocalConnection" class (package com.macromedia.javascript) :
=> File "JavaScriptProxy.as"
==> add the following line
import com.macromedia.javascript.JavaScriptLocalConnection;
below (line 64)
"//import the serializer class
import com.macromedia.javascript.JavaScriptSerializer;"
==> replace "private var receiving_lc:LocalConnection;" with "private var receiving_lc:JavaScriptLocalConnection;"
==> in the function JavaScriptProxy, replace
	receiving_lc = new LocalConnection();
     by 
	receiving_lc = new JavaScriptLocalConnection();

=> Create the file JavaScriptLocalConnection.as (along JavaScriptProxy.as and JavaScriptSerializer.as in com/macromedia/javascript)
--------------------------------------------------
import LocalConnection;

class com.macromedia.javascript.JavaScriptLocalConnection extends LocalConnection
{
	var controller:Object;
	var callFlash:Object;
}
--------------------------------------------------


=> Modify the SWF gateway source code (file JavaScriptFlashGateway.as)
==> add the following line at the beginning of the file :
import com.macromedia.javascript.JavaScriptLocalConnection;
==> replace mentions to "LocalConnection" by "JavaScriptLocalConnection"
--------------------------------------
//LocalConnection object used to talk to JavaScriptProxy instance in main app / content
// var sending_lc:LocalConnection;
var sending_lc:JavaScriptLocalConnection;

//if lcId is not passed in via HTML, then we abort, since we can't do anything without
//it
if(_root.lcId != undefined)
{
	//sending_lc = new LocalConnection();
	sending_lc = new JavaScriptLocalConnection();
	[...]
}
[...]
--------------------------------------


Enjoy if it helps in some way :)




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/flashjs_osflash.org/attachments/20051115/68cd7057/attachment.htm


More information about the Flashjs mailing list