Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Action Script 'source' attribute example 
 

In the following example, an action script file with .as extension has been imported in the main 'Operations.mxml' file. The '.as' file instance is brought through the 'source' attribute in tags.

 

Action Script 'source' attribute example

                         

In the example below an action script file with .as extension has been imported in the main Operations.mxml file. This .as file instance is brought through the source attribute in <mx:Script> tags. 

Syntax for using 'source' attribute:-        

<mx:Script source  =  '     '> ...... </mx:Script>

In the imported action script file four functions are defined and they are called through the click attribute property of buttons in the main mxml file. 

IncludedFile.as

public function addition(x:Number, y:Number):Number {
return x + y;
}

public function product(x:Number, y:Number):Number{
return x*y;
}

public function division(x:Number, y:Number):Number{
return x/y;

}
public function subtraction(x:Number, y:Number):Number{
return x - y; 
}

Operations.mxml

<?xml version = '1.0' encoding = 'ISO-8859-1'?>
<mx:Application xmlns:mx = 'http://www.adobe.com/2006/mxml'>
  
  <mx:Script source = 'includes/IncludedFile.as'/>

    <mx:TextInput id = 'value0' />
    <mx:TextInput id = 'value1'/>

  <mx:HBox>

    <mx:VBox>
      <mx:Label text = 'Addition result'/> 
      <mx:TextArea id = 'result'/>

      <mx:Button label = 'Add
click = "result.text = String(addition(Number(value0.text),Number(value1.text)))"/> 

      <mx:Label text = 'Multiplication result'/> 
      <mx:TextArea id = 'result1'/>
      <mx:Button label = 'Product
click = 'result1.text = String(product(Number(value0.text),Number(value1.text)))'/>
    </mx:VBox>


    <mx:VBox>
      <mx:Label text = 'Division result'/> 
      <mx:TextArea id = 'result2'/>

      <mx:Button label = 'Divide
click = 'result2.text = String(division(Number(value0.text),Number(value1.text)))'/>


      <mx:Label text = 'Subtraction result'/> 
      <mx:TextArea id = 'result3'/>
      <mx:Button label = 'Subtract
click = 'result3.text = String(subtraction(Number(value0.text),Number(value1.text)))'/>
    </mx:VBox>

  </mx:HBox>

</mx:Application>

Operations.swf

Download the code

                         

» View all related tutorials
Related Tags: c gui com class controls ui select button style control io components sed implementation component definition tag name using this

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.