Flex ProgressBar component problem - apache-flex

I am trying to use the ProgressBar Flex component inside a custom Actionscript 3.0 component derived from the UIComponent class. I have set the minimum and maximum values etc.
_progressBar = new ProgressBar();
_progressBar.label = "Loading";
_progressBar.minimum = 0;
_progressBar.maximum = 100;
_progressBar.direction = ProgressBarDirection.RIGHT;
_progressBar.mode = ProgressBarMode.MANUAL;
The component shows the "Loading" text but not the loading bar.
Anything like _progressBar.setProgress(20, 100) does not have any effect on the code. Any ideas why this is not working?

The problem is that I was adding the component to a UIComponent. Flex components need to be added to something derived from a container like a Canvas. I could not get buttons to display in my custom component derived from UIComponent. Changing it to Canvas fixed the issue. Hope this helps someone.

There is no problem with the current code you have provided (it works fine in an individual instance).
Perhaps the problem lies in your custom AS3.0 component, but without further information it's not possible to assist you.

Related

How can I scale the icon of a Spark button?

I have a Spark button with an icon, and I want to be able to scale it, as with an Image component, but I can't find any property for that. Is there any way to achieve that? Thanks.
You could look into Button Class, and then write a custom Class extends Button and implement what you want.
I remember that the icon is displaied by BitmapImage, you could get it's reference and then scale that.
If you want to scale the icon; but not the button; you can do so by accessing the properties directly on the iconDisplay skin part:
myButtonInstance.iconDisplay.scaleX = 2;
myButtonInstance.iconDisplay.scaleY = 2;
myButtonInstance.iconDisplay.scaleZ = 2;
The properties used for scaling are scaleX, scaleY, and scaleZ. The BitMapImage also has a property called scaleMode

flex popup that stays inside a container

I retrieved a fine component for drawing in flex. It uses some floating toolpalette like:
toolBox = PopUpManager.createPopUp( this, ToolPalette ) as ToolPalette;
I tried to integrate that component into a new flex MXML component like a tileWindow:
Works fine except that these tools palette are OUTSIDE the component.
Is there a way to constrain the toolBox created with PopupManager to stay within its parent container ?
regards
I used createPopUp when the popup component was "titleWindow". But when I want a Canvas component added in the popup, I created a titleWindow and added the Canvas component as a child to the TitleWindow.
var titleWindow:TitleWindow;
titleWindow=new ResizableTitleWindow();
titleWindow.showCloseButton=true;
//Canvas Component
var toolPalette:ToolPalette=new ToolPalette();
// Add the Canvas component to the Titlewindow
titleWindow.addChild(toolPalette);
PopUpManager.addPopUp(titleWindow, this, true);
Set the modal property when you call the createPopup method to true.
createPopUp(this, toolPalette, true, null)
By deffinition on adobes site no you can not constrain
createPopUp -- Creates a top-level
window and places it above other
windows in the z-order.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/managers/PopUpManager.html#addPopUp%28%29
Thats' not saying you couldn't try to create a mask of some sort

Animating a sequence of images in the background using Flex 3/Actionscript?

I would like to animate a sequence of background images within a uicomponent but also dynamically add and remove components to this component.
My first question would be:
1.) What's the best way to animate a sequence of images using Flex 3?
2.) What's the best way to handle adding and removing components on top of the background dynamically?
Any help/information would greatly be appreciated!
Thank you!
In the mxml for your ui component declare an mx:Image and give it an id. Set up a timer loop that changes the "source" attribute (id.source = ) on your mx:Image at an interval you like. To add and remove components dynamically just use addChild/removeChild or addElement/removeElement depending on the type of display object you're working with. The mx:Image should always be behind the dynamically added components as it was created and added before them.

difference between <s:Line> and graphics.lineTo()

If I skin a button and use the AS3 graphice.clear() and graphics.lineTo and beginFill to create a shape, the button overlaps other items in the container.
When I use the and mxml to create the same shape, the button is neatly positioned inside the container.
Why is that?
This is probably happening because Flex is unable to calculate the size of your dynamically drawn button, while the MXML version allows the size to be calculated prior to being displayed. You may need to override the measure method to calculate the width/height. If that's not the issue, then post some code so we can take a closer look. Hope that helps.
Because the Line Object is doing a bunch of checks and extra work you aren't doing when you use the Graphics object. Look at the code for spark.primitives.Line to see what its doing that you aren't.

Flex: Setting the resgistration point on a display object

What is the best way to change/set a registration point on a Flex 3 display object? I know this isn't really built in to easily change, but does anyone have any suggestions on how I could extend UIComponent to achieve this?
For some reason, the Flash Player API doesn't expose the registration point of DisplayObjects (and the Flash IDE makes them a pain to modify once an object is created). The best solution, as David pointed out, is to add your component as a child of another component (UIComponent would be fine). So, for example, if I had a Button and I wanted its registration point at its center, I'd add it as a child of a UIComponent (not Canvas) and offset the child by setting its position to (-button.width/2, -button.height/2).
Put your DisplayObject inside a sprite and set the DisplayObject's x & y positions to the negitive of your target registration point. Apply all transforms to the Sprite container.
Put it inside a Canvas container, with its clipContent attribute set to false. Within the canvas, you can put your object wherever you like.

Resources