Getting Started with Flex 3 UI ActionScript Programming

Are there any good resources to run Flex 3 UI programming in ActionScript? I am having some problems with the following if anyone has any ideas. It gets the right size, but my buttons do not appear. Does anyone have any idea?

package { import flash.display.*; import mx.controls.Button; import mx.controls.TileList; import mx.controls.sliderClasses.Slider; import mx.controls.ProgressBar; import flash.net.FileReferenceList; [SWF(width="720", height="480", backgroundColor="#ffffff", framerate="30")] public class PhotoUploader extends Sprite { var AddPhotosButton:Button; var RemovePhotoButton:Button; var UploadPhotosButton:Button; public function PhotoUploader():void { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; AddPhotosButton = new Button(); AddPhotosButton.x = 10; AddPhotosButton.y = 10; AddPhotosButton.width = 100; AddPhotosButton.height = 20; RemovePhotoButton = new Button(); UploadPhotosButton = new Button(); addChild(AddPhotosButton); addChild(RemovePhotoButton); addChild(UploadPhotosButton); } } } 
+1
flex actionscript-3
source share
3 answers

For a true Flex application, I think you need to start at the top level of mx.core.Application (often defined in MXML, not ActionScript), to which you would add mx.core.UIComponent s. I think your PhotoUploader will be a good example of a custom UIComponent.

Flex help / tutorial pages are not bad. I would recommend starting there. Custom components are considered explicitly, but you might want to start earlier in the stream.

+1
source share

Try overriding your createChildren() component (don't forget to call super.createChildren() inside it) and move the three addChild() calls to it. Do not call your own createChildren method; The Flex framework ensures that it is called when your component is added to the display list.

Writing a component in MXML eliminates the need to know a lot about the Flex Component Lifecycle because mxmlc will generate the correct AS3 source code for you, but if you want to write your own component in AS3 yourself, you really need to familiarize yourself with it.

0
source share

Check out the liveocs page for actionscript projects . Namely:

About ActionScript Projects

Flex Builder allows you to create ActionScript projects that use the Flash API (rather than the Flex framework) . This uses the Workbench Flex Builder tools and the ActionScript editor, which means you have a fully featured development environment for developing ActionScript applications.

Therefore, you cannot use Flex components in an ActionScript project. I am surprised that you even managed to put together this class. If you use a different method, specify it in the question.

If you use Flex 3 and addChild , I assume that you are using ActionScript 3. In this case, you are importing instructions that point to the wrong packages. Button , TileList , Slider and ProgressBar are in the fl.controls package .

In addition, ActionScript recommendations recommend naming properties and methods that begin with a lowercase character.

Oh last one. I do not recommend importing the entire display package, because in fact there is a whole group of classes.

-one
source share

All Articles