Click to See Complete Forum and Search --> : How do I trigger Java function from Flash
robothouse
12-29-2006, 08:54 AM
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
1stbite
12-30-2006, 05:24 PM
java or javascript?
if javascript take a look here:
http://www.spoono.com/flash/tutorials/tutorial.php?id=20
theTick
01-04-2007, 05:14 AM
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:
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:
<html>
<head>
<script language="JavaScript" type="text/javascript">
function anyFunction() {
/* do something */
}
</script>
</head>
<body>
<!-- Embedding code for Flash movie -->
</body>
</html>
MyFriendIsATaco
01-04-2007, 05:19 AM
just use:
getURL("javascript:backward();");
or
getURL("javascript:forward();");
robothouse
01-04-2007, 07:32 AM
thanks guys, much appreciated, have it all working now...will be up and going soon!
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.