You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Jim Norris <ji...@e-work.com> on 2017/08/23 13:40:45 UTC
Javascript functions
In FlexJS, is there a way to call a Javascript function from ActionScript?
I did not see an obvious way to do it but I may have missed something.
Thanks,
Jim
Re: Javascript functions
Posted by Harbs <ha...@gmail.com>.
Typedefs makes the signatures known, but the javascript needs to be loaded.
Generally, loaded javascript is in the global space and is attached to the window.
If you have typedefs defined you can just access the global MyFoo.doSomething() directly. If you don’t have typedefs defined, you can do the same things like this:
window["MyFoo"]["doSomething"]()
What I’ve found is that defining typedefs is worhtwhile when you are doing extensive integration. Otherwise, bracket access to the window object gets you to where you want to be very quickly…
HTH,
Harbs
> On Aug 23, 2017, at 7:53 PM, Olaf Krueger <po...@olafkrueger.net> wrote:
>
> Piotr, whats about just creating some TypeDefs?
>
> Olaf
>
>
>
> --
> View this message in context: http://apache-flex-development.2333347.n4.nabble.com/Javascript-functions-tp63954p63956.html
> Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: Javascript functions
Posted by Olaf Krueger <po...@olafkrueger.net>.
Piotr, whats about just creating some TypeDefs?
Olaf
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/Javascript-functions-tp63954p63956.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: Javascript functions
Posted by Piotr Zarzycki <pi...@gmail.com>.
Hi Jim,
Yes we can, but you have to assume that your library is part of your loaded
webpage. [1] - In this html template you can see that material.min.js is
included. We are doing calls of JS functions from AS in MDL module. Example
is UpgradeElement bead (method: upgradeElement) which just gets object from
window and calls on it some existing function [2]
[1]
https://github.com/apache/flex-asjs/blob/develop/examples/flexjs/MDLExample/src/main/resources/mdl-js-index-template.html
[2]
https://github.com/apache/flex-asjs/blob/develop/frameworks/projects/MaterialDesignLite/src/main/flex/org/apache/flex/mdl/beads/UpgradeElement.as
Let me know it it is enough understandable.
Piotr
2017-08-23 15:40 GMT+02:00 Jim Norris <ji...@e-work.com>:
> In FlexJS, is there a way to call a Javascript function from ActionScript?
>
>
>
> I did not see an obvious way to do it but I may have missed something.
>
>
>
>
>
>
>
>
>
>
>
> Thanks,
>
>
>
> Jim
>
>