How do I trigger Java function from Flash
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How do I trigger Java function from Flash

  1. #1
    Rock Your Face Off.
    Join Date
    Nov 2006
    Location
    UK
    Posts
    56

    Question How do I trigger Java function from Flash

    Hi everyone, I have a webpage that has standard windows buttons in it that allows a user to cycle through a sequence of images...pretty basic stuff. The buttons trigger one of two functions "backward()" and "forward()". This all works great but the problem is I want to replace these buttons with flash movies so as to keep them stylistically in line with the rest of my site. After a few random stabs at trying to get the correct code to work I'm a bit at a loss.

    Could anyone tell me what openUrl command do I need to have attached to my buttons (in my flash movie) in order to call these functions in the page the flash movie is in?

    thankyou!

    ps its flash 8

  2. #2
    No I can't do it by tommorow.. 1stbite's Avatar
    Join Date
    Feb 2003
    Location
    UK
    Posts
    1,300
    java or javascript?

    if javascript take a look here:
    http://www.spoono.com/flash/tutorial...rial.php?id=20
    Last edited by 1stbite; 12-30-2006 at 05:41 PM.
    and in a blink of an eye...
    Media and Multimedia Courses in Nottingham - First Diploma | IMedia | HND | Foundation Degrees | BA(Hons) Top Ups.

    Give a Twit a chance!

  3. #3
    Member Pepember
    Join Date
    Jul 2001
    Location
    Berlin
    Posts
    886
    use ExternalInterface. that way it is possible to call from inside Flash a function of the host application. so it doesn't matter whether your swf is hosted in HTML, a Java app or a C# app or whatever.

    Flash:
    Code:
    import flash.external.*;
    function callHost():Void
    {
    	ExternalInterface.call("anyFunction");
    }
    myButton.onPress=callHost;
    you can even send parameters that way, just look in Flash help.

    make sure that your host app provides a function called "anyFunction". e.g. JavaScript in HTML:
    Code:
    <html>
    <head>
    <script language="JavaScript" type="text/javascript">
        function anyFunction() {
        /* do something */
        
        }
    </script>
    </head>
    <body>
    <!-- Embedding code for Flash movie -->
    </body>
    </html>
    Last edited by theTick; 01-04-2007 at 08:29 PM.
    Please sign here

  4. #4
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,046
    just use:

    getURL("javascript:backward();");

    or

    getURL("javascript:forward();");

  5. #5
    Rock Your Face Off.
    Join Date
    Nov 2006
    Location
    UK
    Posts
    56
    thanks guys, much appreciated, have it all working now...will be up and going soon!

Posting Permissions

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




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com