MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Bedienungsanleitung Seite 26

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 184
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 25
26 ActionScript 2.0 to 3.0
Using packages
The package statement syntax has changed. In addition, you are now required to put custom
ActionScript components inside packages.
If you do not put a class inside a package, then the class is only visible in the current script.
For example:
class Foo {}
is a class that is not in any package, so it is only visible in the current script. If you put a class
in an unnamed package:
package { public class Foo {} }
Then you can access the class from any script. All scripts import the unnamed package by
default.
Package statement syntax
You now use a package statement rather than dot notation syntax to declare classes inside
packages. You add
package statements before imports, wrapped around the entire class. For
example, to place the Button class in the mx.controls package in Flex 1.5:
class mx.controls.Button extends mx.core.UIComponent {
function Button() {
}
}
This implicitly declared that class Button was in package mx.controls. To place the Button
class in the mx.controls package in Flex 2:
package mx.controls {
public class Button extends mx.core.UIComponent {
public function Button() {
}
}
}
Custom component packages
ActionScript 3.0 now requires that all ActionScript components be inside packages. These
packages can be unnamed; for example:
package {
class MyClass { ... }
}
Seitenansicht 25
1 2 ... 21 22 23 24 25 26 27 28 29 30 31 ... 183 184

Kommentare zu diesen Handbüchern

Keine Kommentare