how to call static method from javascript?

22 views
Skip to first unread message

mb

unread,
Aug 19, 2011, 4:05:55 PM8/19/11
to JSInterface
Hello,

Is it possible to call static method AS3 class from javascript
(FLObject) ?
eg.
AS3 code:
com.greensock.TweenMax.to(mc, 1, {bevelFilter:{blurX:10}});

Олег Галабурда

unread,
Aug 20, 2011, 4:51:37 AM8/20/11
to jsint...@googlegroups.com
Hi!

1.You can pass Class object to JavaScript:

JSInterface.window.TweenMax = TweenMax;

In this case you should use FLObject.call method to call TweenMax methods:

TweenMax.call("to", [box, time, params]);

2.You can pass only needed methods from TweenMax:

var window:JSDynamic = JSInterface.window;
window.TweenMax = new JSDynamic();
window.TweenMax.to = TweenMax.to;

In this case you can call TweenMax methods as in ActionScript:

TweenMax.to(box, time, params);

3. You can get link to ActionScript class directly from JavaScript
after JSInterface initialization:

window.TweenMax = FLObject.instance('com.greensock.TweenMax');

But in this case don't forget to mention TweenMax somewhere in your
code to be sure it was compiled into SWF:

package{
import com.greensock.TweenMax;

public class JSClassLinkage extends AbstractApplication{
TweenMax;
....

Check attached examples in "bin-debug" folder. I've used FLSimple
objects to pass parameters AS IS, without linkage.

2011/8/19 mb <syf...@gmail.com>:

--
Oleg Galaburda
http://blog.actualwave.com/
http://jsinterface.googlecode.com/
http://guibuilder.org/

JSInterfaceFlashLinkage.zip

mb

unread,
Aug 22, 2011, 7:08:44 AM8/22/11
to JSInterface
Hello,

Thanks a lot for answer, example and excellent library ,

look at my last project :))

http://www.dolegro.vdl.pl/jseval/example3.html (source - flash develop
- is here http://www.dolegro.vdl.pl/jseval/jseval.zip)


On 20 Sie, 10:51, Олег Галабурда <burd...@gmail.com> wrote:
> Hi!
>
> 1.You can pass Class object to JavaScript:
>
....

Олег Галабурда

unread,
Aug 24, 2011, 7:51:03 AM8/24/11
to jsint...@googlegroups.com
Hi!

Nice work!
Currently I am working on third version of this library, it will be up
to three times faster(It will replace ExternalInterface JavaScript
code by own version) in modern browsers with Flash Player 11.
It will not be backward complatible, but I will use JavaScript
getters/setters and dynamic JavaScript class creation and this will
allow to call Flash methods/properties as usual:
var easeOut=Bounce.easeOut;
or create instances
var movieClip = new MovieClip();

So, stay tuned. :)

2011/8/22 mb <syf...@gmail.com>:

--

Reply all
Reply to author
Forward
0 new messages