User Tag List

Results 1 to 9 of 9

Thread: Is it possible to call javacript from a Fusion swf?

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Question Is it possible to call javacript from a Fusion swf?

    Is it possible somehow right now to call a javascript command from a Fusion swf? And if not, would it be complicated to create such an extension?

    I recently got this message from a publisher that wants two of my games, but I don't know if this is possible?

    "how are you? I've got a proposal for you to solve the issues with our AS3 api and Fusion software, this applies to Coco Block and Loot Hero too. You can use a simple JS call to unlock achievements, no api keys/tokens involved. No need to have any kind of highscores, just achievements.
    If you agreed you can resume Loot hero, as that one have already achievements created. If everything goes fine (you should not have problems with Fusion as it just javascript) I will proceed to create Coco achievements

    Call this to unlock, for example, unlock_woods

    lechuck.stat.put(function(response){
    console.log(response);
    }, "unlock_woods ",1);

    To send ie 12345 to enemies stat use simply
    lechuck.stat.put(function(response){
    console.log(response);
    }, "enemies ",12345);

    Let me know if you need anything
    You can add me to skype if you prefer to chat there
    Regards, "

  2. #2
    Clickteam Clickteam
    Olivier's Avatar
    Join Date
    Jun 2006
    Posts
    3,000
    Mentioned
    9 Post(s)
    Tagged
    1 Thread(s)
    Yes it is possible with the The Flash® Player Object. Read the extension's Help file for some more information. And of course the current HTML page must contain the Javascript functions you mentioned.

    EDIT: You should take a look at how Kimera wrote his jsFusion Library, it's all open source: http://community.clickteam.com/threads/88338-jsFusion-Library

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Hmm Kimeras files seemed to be made for Html5?

    I need to call something like this but have no idea how :S

    lechuck.stat.put(function(response){
    console.log(response);
    }, "unlock_woods ",1);

  4. #4
    Clickteam Clickteam
    Olivier's Avatar
    Join Date
    Jun 2006
    Posts
    3,000
    Mentioned
    9 Post(s)
    Tagged
    1 Thread(s)
    Both Flash and HTML5 objects work the same way when it comes to JavaScript. I'm not fluent enough with JavaScript so I'm having a hard time to understand these 2 functions, even after having read the basics. But I am sure that other users are able to help.

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Thanks Oliver, anyone else know?

    I talked to the techguy over at MiniPlay (the ones who wants this implemented) and if I opened the console in the browser on their host page where the game is and just pasted
    lechuck.stat.put(function(response){
    console.log(response);
    }, "unlock_woods ",1);

    it works and the achievement is unlocked. So I guess I just need to send this message from the game somehow?
    I could do a "Call function": "lechuck.stat.put(function(response){
    console.log(response);
    }" and getting it as a valid expression in Fusion. But if I add the last line ", "unlock_woods ",1); " I get an expression error... Anyone know how to write it properly?

    Valid expression: https://dl.dropboxusercontent.com/u/...-17_131815.png
    Unvalid expression: https://dl.dropboxusercontent.com/u/...-17_131901.png

  6. #6
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're getting the expression error because of the double quote characters in the expression around "unlock_woods" - MMF thinks that you're ending the string. To solve this, you can either double them up so that it reads ""unlock_woods"" (MMF will understand "" as 'I want to actually have a " character in the string here') or use 'unlock_woods' instead - Javascript understands strings in single quote marks without problems.

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    Thanks DavidN, the expression is now valid. But when i use it in a call function when pressing a button https://dl.dropboxusercontent.com/u/...-17_200618.png
    I still get an error in the console that reads "Uncaught SyntaxError: Unexpected token ;"

    Again, if I just paste the same line "lechuck.stat.put(function(response){console.log(r esponse); }, 'unlock_woods ',1); " into the console it works so i dont understand what I do wrong?

  8. #8
    Forum Moderator Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export Module
    DavidN's Avatar
    Join Date
    Jun 2006
    Location
    Boston, MA, USA
    Posts
    4,044
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is your test page public? It would probably be easier to see what's going on first-hand. "Unexpected token ;" is usually caused by parentheses being paired wrongly (the line is ending unexpectedly), but your expression looks right.

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export Module
    Outcast's Avatar
    Join Date
    Jan 2011
    Location
    Sweden
    Posts
    3,156
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    It seems to work when I removed the last ; in the expression

Similar Threads

  1. Load On Call
    By Spike in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 17th June 2013, 06:54 PM
  2. Make a Call without "Call Phone" permission?!?
    By StingRay in forum Android Export Module Version 2.0
    Replies: 4
    Last Post: 21st April 2013, 09:35 AM
  3. Initiating a call
    By Game_Master in forum iOS Export Module Version 2.0
    Replies: 4
    Last Post: 10th April 2012, 09:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •