canvas would be global reference, so you wouldn't need that extra 'globalreference.'. Correct me if I'm wrong. Actually that's not really well documented.
Raju

On Jun 20, 2009, at 10:10 PM, Sarah Allen wrote:

Can I just declare a method on the canvas and call it with:
value = lz.embed.lzapp.callMethod('globalreference.canvas.anyMethod(...)')

Also, do I need all the lz embed stuff to do this? I was just using swfobject_tag in rails... and then I would just call the method on the object in javascript.

Sarah

On Jun 20, 2009, at 12:59 PM, Max Carlson wrote:

It just means you need a top-level instance with an ID. You can do this in a script if you want to...

Sarah Allen wrote:
What does this mean: "You can call any available method in the application as long as 'globalreference' can be found in the global scope." ?
Do I need to define "globalreference" in a script tag?
Thanks,
Sarah
On Jun 19, 2009, at 1:20 PM, Max Carlson wrote:
Yes!  See the docs for any app with lzt=deployment, e.g.:
http://labs.openlaszlo.org/trunk-nightly/my-apps/copy-of-hello.lzx?lzt=deployment

To call a method in an application, use:

value = lz .embed.lzapp.callMethod('globalreference.reference.anyMethod(...)')

passing a string representation of the method and any arguments you wish to pass. You can call any available method in the application as long as 'globalreference' can be found in the global scope.

To call a method in all applications on the page, use:

lz.embed.callMethod('globalreference.reference.anyMethod(...)')

Sarah Allen wrote:
So, is there any native-LZX way to do this? or is the Flash API the best I can do for now?
Thanks!
Sarah
On Jun 12, 2009, at 10:12 AM, Henry Minsky wrote:
You're looking at out of date docs, the new docs say it has two args.

See the docs at http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/

addCallback    ()    method

| public static function addCallback(functionName:String <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html >, closure:Function <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Function.html >):void <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/specialTypes.html#void >|
* Language Version : *    ActionScript 3.0

* Runtime Versions : *    AIR 1.0, Flash Player 9

Registers an ActionScript method as callable from the container. After a successful invocation of |addCallBack()|, the registered function in Flash Player can be called by JavaScript or ActiveX code in the container.

*Note:* For /local/ content running in a browser, calls to the | ExternalInterface.addCallback()| method work only if the SWF file and the containing web page are in the local-trusted security sandbox. For more information, see the following:

 * The security chapter
   <http://www.adobe.com/go/flashCS3_progAS3_security> in the
   /Programming ActionScript 3.0/ book and the latest comments on
   LiveDocs
 * The Flash Player 9 Security white paper
   <http://www.adobe.com/go/fp9_0_security>

Parameters


|functionName:String <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html >| — The name by which the container can invoke the function.

|closure:Function <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Function.html >| — The function closure to invoke. This could be a free- standing function, or it could be a method closure referencing a method of an object instance. By passing a method closure, you can direct the callback at a method of a particular object instance.


Throws

|Error <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Error.html > | — The container does not support incoming calls. Incoming calls are supported only in Internet Explorer for Windows and browsers that use the NPRuntime API such as Mozilla 1.7.5 and later or Firefox 1.0 and later.

|SecurityError <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/SecurityError.html > | — A callback with the specified name has already been added by ActionScript in a sandbox to which you do not have access; you cannot overwrite that callback. To work around this problem, rewrite the ActionScript that originally called the | addCallback()| method so that it also calls the | Security.allowDomain()| method.

|SecurityError <http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/SecurityError.html > | — The containing environment belongs to a security sandbox to which the calling code does not have access. To fix this problem, follow these steps:

1. In the |object| tag for the SWF file in the containing HTML
   page, set the following parameter:

   |<param name="allowScriptAccess" value="always" />|

2. In the SWF file, add the following ActionScript:

   |flash.system.Security.allowDomain(/sourceDomain/)|

See also



On Fri, Jun 12, 2009 at 12:51 PM, Sarah Allen <[email protected] <mailto:[email protected]>> wrote:

 I'm seeing a weird compiler error in trunk... might be recent
regression (it is possible, but unlikely that I somehow left this
 code in a state that had a compiler error a couple of months ago
when I last looked at this app) I'll be looking at this more, but
 I wanted to send a note in case anyone else is seeing something
 similar or has any ideas.

 org.openlaszlo.sc.CompilerError: main.lzx: 41: Error: Incorrect
 number of arguments. Expected no more than 2, in line:
 flash.external.ExternalInterface.addCallback("playMedia", null,
 playMedia)

 The Flash docs indicate that there are three arguments:
 
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001653.html
<http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001653.html >

 Also, is there any LZX-native way that I should be making this
 call instead of devolving into calling Flash directly?

 Thanks in advance,
 Sarah





--
Henry Minsky
Software Architect
[email protected] <mailto:[email protected]>


http://www.ultrasaurus.com

--
Regards,
Max Carlson
OpenLaszlo.org
http://www.ultrasaurus.com

--
Regards,
Max Carlson
OpenLaszlo.org

http://www.ultrasaurus.com






Reply via email to