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



Home Answers Viewqa Flex Javascript and flex

Have Programming Question? Ask it here!
 
 
 


bikrantsingh
Javascript and flex
1 Answer(s)      3 years and 11 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
Flex basic
Flex basic  Hi...... please just tell me about Can we run Flex applications in MAC? Thanks
Flex and Java
Flex and Java  hi..... Please give similiarities between Java and Flex. Thanks
Flex event
Flex event  Hi.... Please tell me about How to create your own event in flex? Thanks
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
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
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 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 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
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
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
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 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 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.......... I want to know about What is localToGlobal and globalToLocal in flex? please give me ans ASAP..... Thanks
Flex application
Flex application  Hi..... What kind of applications you can create from flex? please give the name of these applications....... Thanks
Flex difference
Flex difference  Hi.... please tell me about What is the difference between Flex 2.0 and Flex 3.0? Thanks  Ans: There are some advantages of Flex3.0 over Flex 2.0 they are following: 1. Faster compilation time
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
JavaScript
JavaScript  how to get full path of a file type in javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
javascript
javascript  write a program to display implement about browsers using javascript
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
Flex with JSP
Flex with JSP  i want to draw chart in jsp page using flex. how can i do that? any solution??   Flex charts You can visit the following links: http://www.roseindia.net/tutorial/flex/flex4/components/charteffect.html
javascript
javascript  how to set the request or session attribute in javascript head part of jsp page
javascript
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
javascript
javascript  hi sir, if i want to learn javascript. what concepts i want to know
Flex basic
Flex basic  Hi...... Please tell me about What are non-visual components in flex? What class do they extend? please give the name of these components....... Thanks
Adding a flex table in another flex table column
Adding a flex table in another flex table column  how to add a flex table in another flex table column
Flex Managers
Flex Managers  Hi... Please tell me about How to override Managers? give me an example for that.... Thanks
Image in Flex
Image in Flex  Hi..... Can you manipulate images using Flex programs? please give me the example....... Thanks
Flex event
Flex event  hi...... How to capture and event if the component is disabled? please give an example..... Thanks in advance
Metadata in flex
Metadata in flex  Hi......... please tell me about the meta data in flex. Thanks
XML in flex
XML in flex  Hi... just tell me about What is e4X and XML in flex? Thanks
Mask in Flex
Mask in Flex  Hi...... Is it possible to create 'gradient mask' in flex? please give me the ans ASAP..... Thanks in advance
Adobe flex
Adobe flex  Hi... please give me the description about What is Adobe Flex? Thanks
JAVASCRIPT
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance
Javascript
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
Advantage of Flex
are the Advantages and Disadvantages of flex? Thanks   Advantages: Flex IDE is very capable. Flex output is a movie and images is the major part of this movie. you can not directly download the flex running file. When we right click
Resize browser in flex
Resize browser in flex  Hi........ Please tell me about How can I Resize the Internet Explorer browser window from flex ? please give me... with JavaScript in the HTML wrapper: getURL('javascript:window.resizeTo(900,900
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
 

 

 

DMCA.com