We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Open flash file over processing window
Pages: 1 2 
Open flash file over processing window (Read 3919 times)
Open flash file over processing window
Apr 10th, 2007, 9:38am
 
Hi,
I'm trying to understand Quasimodo's way to interact between flash and processing. I need to interact between a flash and a processing presentation and would like to open the flash window in the same window having a smooth transition. I'm trying to get to it through the fscommand, unfortunately without success. Could somebody show an easy example... thanx.
Re: Open flash file over processing window
Reply #1 - Apr 10th, 2007, 9:54am
 
is that gonna happen on a website?
Re: Open flash file over processing window
Reply #2 - Apr 10th, 2007, 11:05am
 
hi thanx for reply.
Yes I actually would like to integrate this action in an if sequence in processing, that each time I release a keep it happens the transition to the flash stuff.
Re: Open flash file over processing window
Reply #3 - Apr 10th, 2007, 11:47am
 
ok, you are having an applet on a website and want to transfer to flash each time you click or you press a button, right from your title i guess flash should lay over the processing applet ..

there are several problems with this. first, there is no way doing this without javascript. communication between javascript and java (especially in that direction) is not fully supported on all browsers and might not work at all. second, from my experience applets and embedded flash will have thrading issues. that means that one or both might flicker while playing. especially when you try to lay one over the other (which might not work at all ..).

you can call from java to javascript, have a look at the callback-function here. which works most of the time.

to get rid of the flickering you will have to try to stop the applet or the flash-swf upon hiding and have it continue (resume) once it's shown. noLoop() and loop() are part of PApplet in addition to that you could try stop() and resume() (inherited from Applet). on the flash-side there should be similar calls ...

an somewhat easier way to do this might be to use params. this means that only the applet or the flash-project will be running on the page and that the page has to be reloaded after each click (see open()). params and open is available on the flash-side via query-variables and getURL

F
Re: Open flash file over processing window
Reply #4 - Apr 10th, 2007, 11:57am
 
Thanx,
yes I've read it might be possible just with explorer, but the Quasimodo stuff also worked with Mozilla. Very detailed information you gave me, now I'm goin to try this out...

D
Re: Open flash file over processing window
Reply #5 - Apr 10th, 2007, 1:04pm
 
let me know if you have something to look at or into ...
F
Re: Open flash file over processing window
Reply #6 - Apr 11th, 2007, 12:45am
 
Hey thank you for your help...
I didn't really get what the params is doing but I also tried the open() version and the same for flash geturl()... it seams that's going to open the files in different windows... So I'm trying get along with javascript. But that's very new to me. So I wanted to ask you for even a more detailed explanation or example, how you would integrate into a processing if sequence, that as soon I release a mouse button it makes a transition to a flashfile on the same area and then comes back again....
Thank you, you've already been helpful..
Re: Open flash file over processing window
Reply #7 - Apr 11th, 2007, 5:17am
 
Ok... Now I jumped into cold water and I think now I understand a lot more. It seams like I would need to do this:
I have to open the java-file and then use javascript to interact between the processing applet and the flash file like the example you showed me. Right? So time is running and I'm not sure if I'm able to make it in time. If you could show me a clear example of it, how you can do it... it would be soo great! I guess there is no way to use javascript in processing. Right?
Thanx,
D
Re: Open flash file over processing window
Reply #8 - Apr 11th, 2007, 7:44am
 
nope. no javascript inside processing.

and sorry, i don't have an example for you. i still think you're on the wrong way trying to integrate processing and flash via javascript on the same website. i recommend you do some little tests to see if it could work at all:

- overlay a processing applet with a flash-movie ( to see if it flickers or comes thru )
- test calling javascript form processing ( use the code i already gave you ) and test fscommand ( or how it's called ) from flash
- now test calling the processing applet and the flash-movie from javascript

if all that is working as you think it should, you can merge it and are almost where you wanted to get.

F
Re: Open flash file over processing window
Reply #9 - Apr 11th, 2007, 8:01am
 
Hi...
but here I have the basic question: do I have open the the javafile and change it to create a new jar? Right? It's not possible to use the code you gave me in processing?
What's exactly the difference between param and open. As far as I got it. param() just works on html and is accessing to codes there. So actually it should compared to open() be able to open the flashfile in the same window? I'm sorry, but I'm kind of new in the processing world and especially in the java. I'm still researching and understanding the differnces between java and javascript and their communication in html. My experience comes from Pascal, Logo, Ti92 to Mel, rhino vb as being industrial designer/architect. So very new here... sorry for the slow understanding...
D
Re: Open flash file over processing window
Reply #10 - Apr 11th, 2007, 8:18am
 
sorry again...
and if yes- I have to write a java file and convert it to jar to replace the existing one, then how would you do it, besides doing it with the texteditor and the commandline?
thanx,
D
Re: Open flash file over processing window
Reply #11 - Apr 11th, 2007, 8:31am
 
ok. no problem. sure you can add the callback to a Processing sketch:

create a new sketch and copy the following into it:
Code:

void setup ()
{
JSCallback.jsCallback( "alert(\"test\");", this );
}


in that sketch create a new tab, name it "JSCallback.java" and copy the following into it:
Code:

import processing.core.*;
import java.applet.*;

class JSCallback
{
static void jsCallback ( String _jsCommand, PApplet _papplet )
{
if ( !_papplet.online ) return;
try {
Class c = Class.forName("netscape.javascript.JSObject");
java.lang.reflect.Method getWin = c.getMethod("getWindow",new Class[]{ java.applet.Applet.class } );
java.lang.reflect.Method eval = c.getMethod("eval",new Class[]{ String.class } );
Object jswin = getWin.invoke(c, new Object[]{ _papplet } );
if ( jswin != null )
eval.invoke( jswin, new Object[]{ _jsCommand } ).toString();
return;
} catch (Exception e) { ; }

try {
java.applet.AppletContext context = _papplet.getAppletContext();
if ( context != null ) {
context.showDocument( new java.net.URL("javascript:" + _jsCommand) ,"_self" );
}
} catch (Exception e) { ; }
}
}


save, press export (export for web) and open the index.html file in your browser. you should get an alert window with the text from setup ...

param is a way to _read_ params from the html-file that contains the applet. it's a simple way to pass variables to an applet. these can only be set before the applet has loaded and will not change the html or execute any javascript.

forget open(), use link() instead. it will open an url in the browser if you pass one to it.

if you want to have the flash-movie replace the applet you will have to use javascript. link() ( or open() ) will reload the contents of the window or open a new one ...

F
Re: Open flash file over processing window
Reply #12 - Apr 11th, 2007, 8:37am
 
Wow, your nice, I'll try it out right now and give more feedback soon...
thanx.
D
Re: Open flash file over processing window
Reply #13 - Apr 11th, 2007, 9:00am
 
Great!
Yes it works! So now you mean I could use the javascript callback to call fscommand and run the flashfile? I'll try that out...
Re: Open flash file over processing window
Reply #14 - Apr 11th, 2007, 9:18am
 
jep. for example. you might need to use some more js to hide the papplet and show the flash-movie before calling it's fscommand.

F
Pages: 1 2