IT Community - Software Programming, Web Development and Technical Support

Javascript and Flash

This is a discussion on Javascript and Flash within the Flash Actionscript Programming forums, part of the Web Development category; I have heard we can invoke functions used in flash using javascript. If its possible please help me in this ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Flash Actionscript Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 10-03-2007, 06:20 AM
Anand Anand is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 52
Anand is on a distinguished road
Default Javascript and Flash

I have heard we can invoke functions used in flash using javascript. If its possible please help me in this regard and how to use it.
__________________
None of us is As Strong as All of us.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-19-2007, 12:40 AM
geoblow geoblow is offline
D-Web Trainee
 
Join Date: Jul 2007
Posts: 19
geoblow is on a distinguished road
Default Re: Javascript and Flash

Read this
moock>> web>> flash>> fs command
it will give you some idea about flash using actionscript.
__________________
Geo
Actionscript Villain
geoblow.com
Atleast an inch move every day!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-31-2007, 08:57 PM
arunsamini arunsamini is offline
D-Web Trainee
 
Join Date: Oct 2007
Posts: 8
arunsamini is on a distinguished road
Post Re: Javascript and Flash

Hi...Anand
Javascript is invoked in Flash by using GetURL function...For example one button is there u can invoke javascript in button onPress event...The code sample is

btn.onPress=function(){
getURL("javascript:alert('button1')");
}

Then save the application and publish the flash file in Html..Run the newly published file..while running the application and press the button..then u see that alert window is open for ur browser...

Thanks,
S.Arun
Less Talk Work More
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-25-2008, 09:25 PM
aramesh aramesh is offline
D-Web Programmer
 
Join Date: Mar 2007
Posts: 71
aramesh is on a distinguished road
Default Re: Javascript and Flash

Hi,


In flash there is a way to call a function written in javascript from flash. We can simply call like this.

getURL("javascript:function_name('parameters seperated by comma')","");


But we can't return values from javascript to flash. To return value use the function below.

var exint = flash.external.ExternalInterface.call("Function Name", Param1, Param2, etc);

The return value should be stored in the "exint" variable.

To call a function written in Flash from Javascript use see this sample below.

Codes to be Written in Flash:

import flash.external.*;

var methodName:String = "goHome";
var instance:Object = null;
var method:Function = goToMacromedia;
var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName, instance, method);

var txtField:TextField = this.createTextField("txtField", this.getNextHighestDepth(), 0, 0, 200, 50);
txtField.border = true;
txtField.text = wasSuccessful.toString();

function goToMacromedia() {
txtField.text = "http://www.macromedia.com";
getURL("http://www.macromedia.com", "_self");
}

And codes to be in Html page:

<form>
<input type="button" onclick="callExternalInterface()" value="Call ExternalInterface" />
</form>
<script>
function callExternalInterface() {
thisMovie("externalInterfaceExample").goHome();
}

function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
}
</script>


Regards

A.Ramesh
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-15-2008, 02:22 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: Javascript and Flash

Using FScommands, externalInterface or JavaScript with IFRAME tags or DHTML layers

In order for FSCommand, externalInterface or JavaScript to work from a Flash movie in an IFRAME tag or DHTML layer, the browser itself must support these calls.

FSCommand with IFRAME was first supported in Internet Explorer 4 and Netscape 6. However, Netscape 6 support of the IFRAME tag was very limited.

ExternalInterface is supported by Explorer 5.0 and later, Firefox 1.0 and later, Mozilla 1.7.5 and later, Netscape 8 and later, and Safari 1.3 and later.
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/flash-actionscript-programming/4014-javascript-flash.html
Posted By For Type Date
DiscussWeb IT Community - Technical Support and Technology Discussions This thread Refback 03-16-2008 05:36 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript to include flash file in asp.net kingmaker ASP and ASP.NET Programming 3 03-10-2008 02:20 AM
How does JavaScript Reporter differ from JavaScript editors? Pvinothkumar HTML, CSS and Javascript Coding Techniques 1 09-13-2007 04:59 AM
2D, Flash or 3D??? 3DProf4online Web Design Help 7 04-19-2007 07:04 PM
Flash mari10 Web Design Help 1 03-08-2007 08:10 PM
web flash spain11 Flash Actionscript Programming 0 03-07-2007 03:43 AM


All times are GMT -7. The time now is 09:47 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0