Flash integration - An Answer

Gary Rathbone gary.rathbone at btclick.com
Sun Feb 9 06:35:01 EST 2003


OK. When I click on a button in Flash I get a "HelloRev" message in my Rev
stack. Rev then returns a "HelloFlash" message. So the two can talk to each
other and pass parameters for parsing and other actions. When I said I was
no Flash expert I actually meant I'd never used the program, so I'm sure
there's much more on the Flash side that can be done rather that just
displaying the Rev response in a browser.

In Flash I created a button with the following script...

-----------
on (press) {
getURL("http://127.0.0.1:8181/$HelloRev$", "_blank");	
}
-----------

I then created a stack with a single button 'Start' and a field 'tfld'. The
'Start' button has the following script. This is very similar to the
Javascript/WebForm/Browser 'integrator' stack previously published.

-----------
on mouseup
  put "" into fld "tfld"
  get the OpenSockets
  repeat with c=1 to the number of lines in it
    close socket (line c of it)
  end repeat
  accept connections on port 8181 with message "wRequest"
end mouseup

on wRequest skt
  set the itemdel to "$"
  set the socketTimeoutInterval to 20000
  read from socket skt for 1 line
  put item 2 of it into fld "tfld"
  write "HelloFlash" to socket skt
  close socket skt
end wRequest
-----------

So, Rev is 'listening' for a request on port 8181 of IP 127.0.0.1 (which is
the local machine - you don't need to change this IP address as every (?)
computer uses this IP address as its own reference - the loopback IP). When
the Flash button is pressed it sends a request to the Rev stack which parses
the parameter and puts the result into the field. Rev then returns a string
which currently appears in a browser window, but I'm sure someone more
competant in flash could do more with this...

Hope this helps.

Regards

Gary Rathbone






More information about the use-livecode mailing list