Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing functions from outside of applet

Status
Not open for further replies.

johnnyv

Programmer
Jul 13, 2001
216
CA
Hello

I have created an applet that displays images on my web page. I am currently using java buttons to manually step forward or backwards through the images.
I would like to be able to 'hide' the java buttons from the user and instead have the user click on one of 2 flash buttons(one forward and one backward button). When the flash button is clicked it would tell the java applet to perform the task assigned to the java button pressed function.

My question. how do I tell the java applet to perform the button pressed event from outside the applet?

I am new to java so bear with me I hope my question is clear
 
Hi johnnyv,
I've been researching how to do what you asked and I got so caught up in it, I wrote out an entire little demo demonstrating how to do it. You can find it here:
The html file has some commenting about what to do in it, but the rest I'm going to explain here. For the demo, I used Flash 5; I assume similar techniques will work for Flash 6.
I could find no way of linking directly from Flash to an Applet, but there is a way to link from Flash to Javascript. By using the
Code:
FSCommand (String command, String args)
in your buttons, you can interact with a Javascript function, shown below:
Code:
  function movieName_DoFSCommand (command, args) {
    var FmovieNameObj = InternetExplorer ? movieName: document.movieName;
  }
You do not have to write this function, Flash can create it for you if you use the Flash with FSCommand Template when you publish.
Next comes the part of interacting with the applet, which Javascript can do. By naming your applet like so:
Code:
  <APPLET CODE=&quot;someApplet.class&quot; NAME=&quot;someApplet&quot;>
you can use Javascript to communicate with it. Any public fields or methods in the applet can be accessed like so:
Code:
  window.document.someApplet.stop ();
After that, it's just a matter of setting your Flash interface up with the correct commands and having you application respond to them.
If anyone knows a more direct way to communicate with Applets, let us know.

Hope this helps,
MarsChelios
 
excellent responce MarsChelios

this exactly what I was looking for

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top