Examples

Primative Pong Game
Primative Black Jack Game
Basic OO Black Jack Game
Basic Form
Complex Form
JavaScript from ActionScript
Basic Image Animation
Hello World on a Timer
Tads Basic Checker Class
A Simple FLV Player
Simple getter use
A liaison Class
Parent Child Control
Wrapper to server bridge
Primative Space Shooter Game
Simple XML Loader
Primative Speed Simulation
Simple Sound Mixing
AS3 wrapper to server and back bridge via ExternalInterface
 




Overview: This is a basic example of using a swf file as a bridge between the server and the wrapper.
Doing things this way is much like ajax.

The same methodology is used by this section to change content.
The banner above acting as the bridge to the database that holds each example.


The example below shows just the basics of an AS3 bridge method.
Because the swf is used only as a bridge, its size does not matter, neither does its visibility.
In this example the swf is a little square just so you can see it.
package { import flash.display.Sprite; import flash.external.ExternalInterface; import flash.events.Event; import flash.net.URLRequest; import flash.net.URLLoader; import flash.net.URLVariables; import flash.net.URLRequestMethod; public class ActionScriptBridge extends Sprite { public function ActionScriptBridge() { if (ExternalInterface.available) { /* we are using this file only as the transport between wrapper and server in the wrapper a function will be set up to call jsinitiate */ ExternalInterface.addCallback("jsinitiate", theBridge); } else { /* external interface fallback options would go here */ } } private function theBridge(thisFile:String):void { var getThis:URLLoader = new URLLoader(); getThis.addEventListener(Event.COMPLETE, showDataGot); var theVars:URLVariables = new URLVariables(); theVars.needforpost="avar"; var theRequest:URLRequest = new URLRequest(thisFile); theRequest.data=theVars; theRequest.method = URLRequestMethod.POST; getThis.load(theRequest); } private function showDataGot(event:Event):void { /* this function gives the response to the wrapper by calling thedatagot with the response as the arg */ var dataGot:URLLoader = URLLoader(event.target); ExternalInterface.call("thedatagot", dataGot.data); } } }

The JavaScript used with this example:
function bridgecrosser(thisfile)
{

  try
  {
  var fcontenterj=window.document.getElementById('tbridge');
  }
  catch(e)
  {
    try
    {
     var fcontenterj=window.document.tbridge;
    }
    catch(e)
    {
       var movie=tbridge;
       
       if (navigator.appName.indexOf("Microsoft")!=-1 || navigator.appName.indexOf("MSIE")!=-1)
       { 
          if (window.document[movie])
          {var fcontenterj=window.document[movie];}
          else
          {var fcontenterj=window[movie];};
       }else{
         if (document.embeds[movie])
         {var fcontenterj=document.embeds[movie];}
         else
         {var fcontenterj=document[movie];};
       }
    }
  }
  try
  {
  fcontenterj.jsinitiate(thisfile);
  }
  catch(e)
  {
    var nojstoflerthreeas="yes";
  }
}

function getinputthencross()
{

var firstnum = document.getElementById("fnum").value;
var secondnum = document.getElementById("snum").value;

bridgecrosser("responsivepage.php?numf="+firstnum+"&nums="+secondnum);

}


function thedatagot(fjdata)
{

document.getElementById('fjholder').innerHTML=fjdata;

}

The php used with this example:
if (isset($_GET["numf"]) && isset($_GET["nums"]))
{

$firstn=strip_tags(urldecode($_GET["numf"]));
$secn=strip_tags(urldecode($_GET["nums"]));

//validation...

$additionre = $firstn + $secn;
$subtractre = $firstn-$secn;
$multiplyre = $firstn*$secn;

echo("your numbers when: <br>added = ".$additionre."<br>subtracted = ".$subtractre."<br>multiplyed = ".
$multiplyre."<br><br> the epox time is now: ".time());
exit;

}

Compiled Result:

Usage examples:

call bridgecrosser function for poem1

call bridgecrosser function for poem2

call bridgecrosser function for poem3

Choose first number:

Choose a second number:


enter two numbers above then call getinputthencross.
doing this gets the input then calls bridgecrosser with a call to responsivepage.php with your input added as variables.

The response will appear in this div.