MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manuel d'utilisateur Page 13

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 184
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 12
Step 1: Find and replace 13
Replace _root
Remove the use of “_root” from your application code if you used it to access the Application
instance. In Flex 1.x, you could use
_root to refer to the main application from anywhere in
your application or one of the components. This was never a recommended practice, but was
a convenient way to access the application root. To access the Application instance from
anywhere in your application, use
Application.application.
import mx.core.Application;
function myFunction():void {
//_root.ta1.text = "Thank you!"; // Flex 1.x
Application.application.ta1.text = "Thank you!"; // Flex 2
}
Also, “_global” and “_level0” no longer exist.
Alerts
The Application.alert() convenience method was removed. You must now use the
mx.controls.Alert.show() method. You import the mx.controls.Alert class and call the
Alert.show() method, as the following example shows:
import mx.controls.Alert;
public function myEventHandler(event:Event):void {
Alert.show("An event occurred!");
}
If you call the show() method in an MXML tag, then you must also include a script block
that imports the mx.controls.Alert class, as the following example shows:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
import mx.controls.Alert;
]]></mx:Script>
<mx:Button id="b1" label="Show Style" click="Alert.show('Alert!');"/>
</mx:Application>
Vue de la page 12
1 2 ... 8 9 10 11 12 13 14 15 16 17 18 ... 183 184

Commentaires sur ces manuels

Pas de commentaire