MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual do Utilizador Página 13

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 184
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 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>
Vista de página 12
1 2 ... 8 9 10 11 12 13 14 15 16 17 18 ... 183 184

Comentários a estes Manuais

Sem comentários