Calling global javascript function from jangaroo game

Skip to first unread message

Kate Morris

Aug 20, 2014, 10:41:16 AM8/20/14
Hi there,

So I've successfully converted over an ActionScript game using Jangaroo. The game sits in a modal for a promotional page. At the end of the there's a score screen with a button. I added a click listener to the button but actually want to call a global javascript function that's in the web page, rather than the actual game. 

So I went into the packaged javascript and opened up the specific JS file and added the line 'window.launchRegistration()' to the onClick function. 

        "private function onClick",function onClick(event/* : Event*/)/* : void*/

The game runs fine but nothing seems to be happening when I hit the score screen button. I know the listener works because I checked it before with different contents in the function. But I also checked out the code in the inspector and that line doesn't seem to be showing up.

So I was wondering if it was even possible to just add javascript lines to the jangaroo packaged JS files.



Aug 21, 2014, 9:31:25 AM8/21/14
Hi Kate,

I'm not sure I fully understand what you are trying to do, but I'll try to answer your questions anyway.
The Jangaroo compiler translates ActionScript to "static" JavaScript. Of course you can change the generated code manually afterwards. Just be sure you edit exactly the file that is served by your Web server. On re-compilation, all changes may be overwritten.

But there might be a simpler solution to your problem. You can call any global JavaScript function from Jangaroo code using ActionScript's "untyped" syntax:

    private function onClick(event: Event):void {

Hope this helps,
Reply all
Reply to author
0 new messages