Adobe Flex is composed of two distinct pieces; a set of pre-built components known as the client-side framework, and a set of runtime services that allow Flex applications to integrate with back-end systems. The client-side framework is a series of ActionScript class that you utilize in MXML or ActionScript. Did you know that you can create your own ActionScript classes and reference them the same way? Remember, MXML is just short-hand notation for ActionScript.
Start by creating an ActionScript class that extends the Flex Panel component.
compClassXPanel.as
-
// Import the client-side framework components needed
-
// The .* is a wildcard that will only import classes that are needed.
-
import mx.containers.*;
-
class compClassXPanel extends Panel
-
{
-
public function compClassXPanel() {}
-
public function init():void {}
-
}
Next, create a component that uses this class as it’s root node:
myComponent.mxml
-
<?xml version="1.0" encoding="utf-8"?>
-
<compClassXPanel xmlns="*" width="400" height="400">
-
</compClassXPanel>
Finally, create your main application that invokes your custom component:
Main.mxml
-
<?xml version="1.0" encoding="utf-8"?>
-
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*">
-
<myComponent />
-
</mx:Application>
Now, this is a very simple example of how you can do this. You would normally continue to build upon your extended class. The point is that your classes are really not that different from the client-side framework.






0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment