Connecting Tech Pros Worldwide Forums | Help | Site Map

Flash return to Javscript

Member
 
Join Date: Sep 2007
Posts: 43
#1: Jan 7 '09
So i got a question is it possible to do this
in my flash file is a button and when i press that button i what what flash would return to my javascript code that i pressed what button
so is it possible to do this and if it is how???

Familiar Sight
 
Join Date: Jul 2007
Location: United Kingdom
Posts: 203
#2: Jan 8 '09

re: Flash return to Javscript


yes just assign javascript function in flash
it's works fine.
Member
 
Join Date: Sep 2007
Posts: 43
#3: Jan 8 '09

re: Flash return to Javscript


and hot to do that can you write me a demo or something
Familiar Sight
 
Join Date: Jul 2007
Location: United Kingdom
Posts: 203
#4: Jan 10 '09

re: Flash return to Javscript


Expand|Select|Wrap|Line Numbers
  1. on (release, rollOver) 
  2. {
  3. getURL ("javascript:NewWindow.close(); void(0);");
  4.  }
  5.  
advance thing is create the function in html file & just call it on simple way.
Expert
 
Join Date: Nov 2007
Location: Germany
Posts: 294
#5: Jan 13 '09

re: Flash return to Javscript


let's say you inserted your flash with:
Expand|Select|Wrap|Line Numbers
  1.    <object id="MY_FLASH" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/s...ersion=5,0,0,0" width="402" height="190">
  2.     <param name='wmode' value='transparent'>
  3.     <param name=movie value="myFlash.swt">
  4.     <param name=quality value=high>
  5.     <embed src="myFlash.swt" quality=high pluginspage="Adobe - Adobe Flash Player" type="application/x-shockwave-flash" width="402" height="190" wmode="transparent" name="flashRedirect" swLiveConnect="true">
  6.     </embed>
  7.    </object>
  8.  
  9.  
into your html-page. Then you need to insert for example:

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT language="Javascript" event=FSCommand(command,args) for=MY_FLASH>
  2.  alert("You pressed" + command);
  3. </SCRIPT>
  4.  
gopan's Avatar
Member
 
Join Date: Apr 2009
Location: Kochi (COK), India
Posts: 41
#6: Apr 23 '09

re: Flash return to Javscript


getURL is not a good way to calling javascript function

its better to use ExternalInterface.call( );

Expand|Select|Wrap|Line Numbers
  1. if(ExternalInterface.available){
  2.    ExternalInterface.call("alert","This call is from flash movie!");
  3. }
  4.  
See Adobe Live Docs
Member
 
Join Date: May 2009
Location: Goregaon, मुंबई IN :)
Posts: 85
#7: May 18 '09

re: Flash return to Javscript


Quote:

Originally Posted by chaarmann View Post

let's say you inserted your flash with:

Expand|Select|Wrap|Line Numbers
  1.    <object id="MY_FLASH" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/s...ersion=5,0,0,0" width="402" height="190">
  2.     <param name='wmode' value='transparent'>
  3.     <param name=movie value="myFlash.swt">
  4.     <param name=quality value=high>
  5.     <embed src="myFlash.swt" quality=high pluginspage="Adobe - Adobe Flash Player" type="application/x-shockwave-flash" width="402" height="190" wmode="transparent" name="flashRedirect" swLiveConnect="true">
  6.     </embed>
  7.    </object>
  8.  
  9.  
into your html-page. Then you need to insert for example:

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT language="Javascript" event=FSCommand(command,args) for=MY_FLASH>
  2.  alert("You pressed" + command);
  3. </SCRIPT>
  4.  


can you pls tell me how to call that FSCommand(command,args) from javascript??
Member
 
Join Date: May 2009
Posts: 81
#8: May 20 '09

re: Flash return to Javscript


ExternalInterface.addCallback()

Look up the Adobe documentation on it.
Member
 
Join Date: May 2009
Location: Goregaon, मुंबई IN :)
Posts: 85
#9: May 20 '09

re: Flash return to Javscript


Thanks @unauthorized

Hello tader,
you can use JavaScript and Flash Integration Kit ( http://weblogs.macromedia.com/flashjavascript/ ),

Expand|Select|Wrap|Line Numbers
  1. http://weblogs.macromedia.com/flashjavascript/
it can call javascript from flash actionscript and vice versa.

regards,
Nitin Sawant
Reply