I am using 2 mx:html controls, one of them is hidden an it's used by the application to load external data from a page. When it's done loading the application will scrape the information from this hidden html control.
The hidden control does not have to take up any space but setting the width and height to 1 will break the page for some reason.
In the example below I set the hidHTML visible property to false yet it keeps taking up space in the main window.
Is there a way for hidHTML to have a width and height but not take up any space and not be visible?
<mx:HTML id="gui" location="main.html" enabled="true"
complete="mainComplete(event)"
paddingLeft="0" paddingRight="0" width="100%" height="100%" />
<mx:HTML visible="false" x="1" y="1"
location="http://externalinfo.com"
id="hidHTML"
width="250"
height="100"
horizontalScrollPolicy="off"
verticalScrollPolicy="off"
enabled="true"
paddingLeft="0"
paddingRight="0"
/>
You need to also set includeInLayput="false" and then the control will then take up no space.
Related
I'm using several custom MXML components in my Flex 4.5 application.
They all use absolute coordinates to place Image, Label, Line, etc. components and are currently based on a spark.components.BorderContainer:
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="160" height="140" borderWeight="0"
creationComplete="init(event)">
<s:layout>
<s:BasicLayout />
</s:layout>
<s:Image id="_avatar" x="0" y="0" width="160" height="120" />
<s:Label id="_username" x="1" y="122" width="80" />
<s:Label id="_bid" x="80" y="122" width="40" textAlign="center" />
<s:Label id="_trix" x="120" y="122" width="36" textAlign="right" />
.... and so on: Images, Labels, Paths, Lines, Rects ....
</s:BorderContainer>
Then I've realized, that I probably don't have to use BorderContainer, because I don't draw/need any borders around my custom components.
But I don't know, what to take instead of it.
I've tried taking <mx:UIComponent> (and removing <s:Layout> tag above), but then I get the error:
'Image' declaration must be contained within the <Declarations> tag since it does not implement 'mx.core.IUIComponent'.
'Label' declaration must be contained within the <Declarations> tag since it does not implement 'mx.core.IUIComponent'.
Any suggestions please? Is there some simplest possible spark "container"? And do I need a "container" at all if I use (and want to use) absolute coordinates?
I recommend you to use s:Group. And you can omit layout declaration as far as BasicLayout is default layout.
UIComponent isn't container so it hasn't default placeholder for children to add them with MXML.
How can I have two labels on a Flex button, one label on top and another on the bottom?
With a Spark architecture button, you should just be able to create a custom button skin.
If you're using the Halo/MX architecture, then you'll have to extend the component. IF you google for multilabel button, a bunch of solutions come up.
You can make custom skin for your button. In that skin's Label, set the maxDisplayedLines attribute to as many lines as you need.
<mx:VBox verticalGap="0" x="60" y="107">
<mx:Canvas cornerRadius="5" backgroundColor="0xff0000" backgroundAlpha=".5" borderStyle="solid">
<mx:Label text="Step 1" fontSize="20" fontStyle="italic" fontWeight="bold" width="171" />
</mx:Canvas>
<mx:Canvas cornerRadius="5" backgroundColor="0xff0000" backgroundAlpha=".5" borderStyle="solid">
<mx:Label text="Initial Request" fontSize="20" fontStyle="italic" fontWeight="bold" width="100%" />
</mx:Canvas>
</mx:VBox>
This is not the correct solution, but you can make a Canvas feel like button if you want. Flexlib has a component where they provide solution for Multiline Label.
Suppose I have a ViewStack like this:
<mx:ViewStack id="s" left="5" right="5" bottom="5" top="0" width="100%" height="100%" creationPolicy="all" minHeight="0">
<mx:Repeater id="repeater" dataProvider="{dp}" height="100%" width="100%" minHeight="0">
<mx:Box id="bx" label="{repeater.currentItem.label}" width="100%" height="100%" minHeight="0">
<mx:Label minHeight="0" width="100%" height="100%" label="bob" />
</mx:Box>
</mx:Repeater>
</mx:ViewStack>
With a large number of items in the stack (each having a large number of panels, databinding, etc), this gets extremely slow. The Repeater seems to trigger creation of all children regardless of the creationPolicy of the viewStack itself.
Is there a readymade solution to this efficiency problem? I can think of some ways to solve it with a custom component, but I'm wondering if there's an off the shelf solution for cases where the inner values really need to be dynamic (backed by an ArrayCollection) like this.
Assuming that all your stacked views are identical except for some specific data displayed in them a possible solution would be to ditch the viewstack and set up all your controls to bind to an array collection, then whatever control you would use to change your viewstack could instead update your array collection.
Trying using a List with an itemRenderer. Repeaters are notorious for terrible performance.
I have a LinkBar which is linked to a viewstack. However, as I change the fontsize of my LinkBar, when I run it, the font size does not change at all! I've tried changing the font using CSS and it doesnt change the font size! Any ideas? Here is the code:
<mx:Canvas x="0" y="0" width="30%" height="100%">
<mx:Label x="10" y="10" text="Help" fontSize="20"/>
<mx:LinkBar x="10" y="49" dataProvider="viewstack1"
direction="vertical" width="175" height="276"
selectedIndex="0"
fontSize="30">
</mx:LinkBar>
</mx:Canvas>
How can I change the font size?! This is driving me crazy.
Either you can change the fontSize in a CSS class, and add that class as the value for the "linkButtonStyleName" style, or you can iterate through all the LinkButtons that have been created in the LinkBar and set the style manually (e.g., in AS3 code).
That being said, fontSize is supposed to be inherited so I'm not sure why your code doesn't work. Just providing some options.
When I set a component to visible=false the component hides, but how do I get it to take no space (get the container it belongs to to resize??)
<mx:HBox width="100%" height="100%">
...
</mx:HBox>
<mx:HBox width="100%" id="boxAddComment" visible="false" >
<mx:TextArea id="txtComment"/>
<mx:Button label="Spara" click="addComment();"/>
</mx:HBox>
When boxAddComment is visible=false I want the first HBox to take 100% height.
use the includeInLayout property. e.g.
<mx:HBox width="100%" height="100%">
...
</mx:HBox>
<mx:HBox width="100%" id="boxAddComment" visible="false" includeInLayout="false" >
<mx:TextArea id="txtComment"/>
<mx:Button label="Spara" click="addComment();"/>
</mx:HBox>
Using includeInLayout ="true" or "false" will toggle the space that it takes in the flow of items being rendered in that section.
Important note: If you don't specify visible="false" when using includeInLayout = "false" then you will usually get something that is undesired which is that your item (boxAddComment) is still visible on the page but stuff below id="boxAddComment" will overlap it visually. So, in general, you probably want "includeInLayout" and "visible" to be in synch.
Ross Henderson's suggestion in binding includeInLayout with boxAddComment.visible works great with Flex 3.0 but I found that it's not working in Flex 3.6 (I saw a posting that it actually stops working since Flex 3.3).
Just fyi.