Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual page 13

Migrating applications to flex 2
Table of Contents

Advertisement

Replace _root
Remove the use of "
_root
instance. In Flex 1.x, you could use
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
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()
mx.controls.Alert.show()
method, as the following example shows:
Alert.show()
import mx.controls.Alert;
public function myEventHandler(event:Event):void {
Alert.show("An event occurred!");
}
If you call the
show()
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>
" from your application code if you used it to access the Application
to refer to the main application from anywhere in
_root
Application.application
convenience method was removed. You must now use the
method. You import the mx.controls.Alert class and call the
method in an MXML tag, then you must also include a script block
.
Step 1: Find and replace
13

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex 2

Table of Contents