Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Flex Javascript and flex
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


bikrantsingh
Javascript and flex
1 Answer(s)      4 years and 3 months ago
Posted in : Flex


Hi.....

How do you call javascript from Flex?

Give the right example.


Thanks

Advertisement
View Answers

October 15, 2010 at 1:23 PM


Ans: Using the ExternalInterface API to access JavaScript from Flex. In flex application, you may have called function defined in action script. Sometimes you may need to call a javascript function defined in html file where your flex file is embed. For this purpose, ExternalInterface api is used which makes it possible to communicate between ActionScript and flash player container like html.

for example: The MXML file are following

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">;
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.external.*;
public var _brandProduct1:Object = {brand: "Sony", product: "Sony Bravia S Series LCD TV, KLV-26S400A", price: "Rs.34,900"};
public var _brandProduct2:Object = {brand: "Sony", product: "Sony Bravia S Series LCD TV, KLV-40S310A", price: "Rs.77,990"};
private function callJS(brandProduct:Object):void {
if (ExternalInterface.available){
ExternalInterface.call("displayBrandProduct", brandProduct);
}else {
Alert.show("Failed.");
}
}
]]>
</mx:Script>
<mx:Button label="Get 1st Product Info" click="callJS(_brandProduct1)"/>
<mx:Button label="Get 2nd Product Info" click="callJS(_brandProduct2)"/>
</mx:Application>

The java Script file are following:

<script language="javascript">
function displayBrandProduct(brandProduct){
if(brandProduct != null){
alert("Brand: "+brandProduct.brand+"\nProduct: "+brandProduct.product+"\nPrice: "+brandProduct.price);
}else{
alert("Please select a person, or maybe I screwed up.");
}
}
</script>



Related Tutorials/Questions & Answers:
Javascript and flex
Javascript and flex  Hi..... How do you call javascript from Flex... the ExternalInterface API to access JavaScript from Flex. In flex application, you may have called function defined in action script. Sometimes you may need to call a javascript
how to call javascript function from flex
how to call javascript function from flex  how to call javascript function from flex
Advertisements
Calling Flex Function From JavaScript
From JavaScript Sometimes, you may need to call flex function from JavaScript... by JavaScript to call the flex function, and the second parameter is the actual...:Application> To Call Flex method from JavaScript do the following
Flex - Call JavaScript Function And Open a Popup Window that Displays Data
Flex - Call JavaScript Function And Open a Popup Window that Displays Data  Flex - Call JavaScript Function And Open a Popup Window that Displays Data
Calling Anonymous JavaScript Function From Flex
: #FFFFCC; } Calling Anonymous JavaScript Function From Flex In flex application, you can call javascript function defined in html file where your flex file is embed. But you can also call an anomymous javascript function
JavaScript call from flex application
; } A JavaScript call from flex application In flex application, you may... a javascript function defined in html file where your flex file is embed...() method is used to call the javascript function. The first argument takes the name
Flex Looping
Flex Looping  I need example for flex looping mechanisam example
Flex - Framework
Flex  database conectivity in flex
JavaScript
JavaScript  clone JavaScript
Flex Combobox
Flex Combobox  flex combobox with database as dataprovider   You can visit the following link for detailed tutorial on the topic. May this will be helpful to you. http://www.roseindia.net/flex/flex-combo-box.shtml
Sitemap Adobe Flex Tutorial
Introducing Flex | Downloading and Installing Flex | Downloading and Installing Flex Builder | Compiling MXML application | Eclipse flex ant coding | Compiling MXML files with FlexBuilder | Flex Combo Box
Flex event
Flex event  Hi.... Please tell me about How to create your own event in flex? Thanks
Flex and Java
Flex and Java  hi..... Please give similiarities between Java and Flex. Thanks
Flex basic
Flex basic  Hi...... please just tell me about Can we run Flex applications in MAC? Thanks
javascript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml http://www.roseindia.net/javascript/javascript-add-row-to-table.shtml http://www.roseindia.net
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
Flex and Java
Flex and Java  Hi.... What are the config files that are used to connect Java and Flex applications? Please provide the solution of this prob so i connect java and flex.... Thanks
Flex and Java
Flex and Java  Hi...... Give the name of Collection which can be mapped to java and Flex and vice-versa. please give the name of all collections which is used in flex and java.. Thanks
Flex basic
Flex basic  Hi.... Can flex application communicate with each other on the client? please give me the answer ASAP..... Thanks   Ans: See the LocalConnection API In the flex documentation. Thanks
Flex Updates
Flex Updates  Sir, first Thanks For Good Resource for Every One! i am New to Flex... but,in Current Updates Tell Us Flex Becomes To down!(Sorry To say).. May I know Future groom & Advantage of Flex Over Other Web
Flex as a Service
Flex as a Service  Hi....... just tell me about How do I run Flex as a service? please give me an example if possible Thanks  Ans: Flex is not a server. It is the pert of your web application. you can use
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  write a program to display implement about browsers using javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
JavaScript
JavaScript  how to get full path of a file type in javascript
JavaScript
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
Flex basic
Flex basic  Hi.... I want to know Do we need any plugins to run Flex applications? please give the ans ASAP....... Thanks
Flex basic
Flex basic  Hi.... can you tell me about Is Flex OS specific or operating system independent? please give the description about it....... Thanks
Flex application
Flex application  Hi..... What kind of applications you can create from flex? please give the name of these applications....... Thanks
Flex basic
Flex basic  Hi.......... I want to know about What is localToGlobal and globalToLocal in flex? please give me ans ASAP..... Thanks
javascript
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
Advertisements
 

 

 

DMCA.com