Brian Chia
       
 
categories
actionscript
actionscript 1.0
actionscript 2.0
misc
 
processing
 
links
brian chia
kelvin zhao
ronald leong
 
 
Return Browser URL Address
 

With ExternalInterface class, we can now call any Javascript function that is written on the HTML page or even inside the flash file itself. ExternalInterface is similar in functionality to the fscommand() but is recommended for Javascript-Actionscript communication.

In the example below, i wrote the javascript function inside the flash file inside instead of on the HTML page. Next, i use the ExternalInterface.call method to execute the javascript function and pass the variable back into a actionscript function.

One important condition that you need to set in order to work is you had to give an id value to the flash object tag in the HTML file:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="browser_address" ....>


import flash.external.ExternalInterface;

// write the javascript function into flash
var jsFunction:String ="function() { return window.location.toString(); }";

// execute the javascript function and pass the value into the function
getAddress(ExternalInterface.call(jsFunction));

function getAddress(url:Object):Void{

url_txt.text=url;

}





suggestion

 
 
 
         
  © copyright 2007 THINKLUNATIC.    
Brian Chia Jonathan Ng