MACROMEDIA COLDFUSION MX 7.0.2-USING COLDFUSION MX WITH FLEX 2 Guide de l'utilisateur Page 96

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 256
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 95
96 Using ActionScript
Referring to Flex components in ActionScript
When you refer to Flex components in ActionScript, the component must have an id
property set. You then use the
id to refer to that component.
For example, you can define a TextArea control in MXML using the
<mx:TextArea> tag. To
access that component’s methods or properties, use dot syntax. The following example sets the
value of the
text property of the TextArea named ta1:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="setTextValue()">
<mx:Script>
<![CDATA[
public function setTextValue():void {
ta1.text = "Congratulations. You are a winner.";
}
]]>
</mx:Script>
<mx:TextArea id="ta1"/>
</mx:Application>
You can refer to the current enclosing document or current object using the this keyword.
For more information, see Chapter 4, “Using ActionScript,” in Flex 2 Developer’s Guide.
Including ActionScript code versus importing
ActionScript classes
To make your MXML code more readable, you can also reference ActionScript files in your
<mx:Script> tags, rather than insert large blocks of script. You can include or import
ActionScript files.
There is a distinct difference between including and importing in ActionScript. Including is
copying lines of code from one file into another. Importing is adding a reference to a class file
or package so that you can access objects and properties defined by external classes. Files that
you import must be found in the ActionScript classpath. Files that you include must be
located relative to the application root or use an absolute path.
You use the
include directive or the <mx:Script source="filename"> tag to add
ActionScript code snippets to your Flex applications.
You use
import statements in an <mx:Script> block to add ActionScript classes and packages
to your Flex applications.
For more information, see Chapter 4, “Using ActionScript,” in Flex 2 Developer’s Guide.
Vue de la page 95
1 2 ... 91 92 93 94 95 96 97 98 99 100 101 ... 255 256

Commentaires sur ces manuels

Pas de commentaire