I have a DropDownList and an itemRenderer for it on related skin. My itemRenderer's items are SWFLoader object which show the swf files in my DropDownList.
Height of each row must be 27px, So I decreased the height and width of my SWFLoader object to make them fit in each row, and also set these atts:
verticalCenter="2" verticalAlign="middle"
to align them in each row. But as contents of my SWFLoader have different width/height, I have problem of item's mouse hovering which overlap each other. I also set these for my SWFLoader, but still no changes:
mouseEnabled="false" mouseChildren="false"
Here is a brief of my code:
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true"
height="27" width="100%">
<fx:Script>
<![CDATA[
override public function set data(value:Object):void{
super.data = value;
// rest of codes
}
]]>
</fx:Script>
<s:SWFLoader left="5" right="5"
height="65"
verticalCenter="2" verticalAlign="middle"
mouseEnabled="false" mouseChildren="false"
source="{data}" smoothBitmapContent="true" />
Any advice?!
The problem was that the SWFLoader was catching the mouse events. So I just placed it in a Canvas and set mouseChildren="false" for ItemRenderer.
Also set scroll policies of Canvas to 0:
horizontalScrollPolicy="off" verticalScrollPolicy="off"
Now the SWFLoader does not catch the mouse events and hovering items in dropDownList do not overlap each others.
P.S: Thanks one of my colleagues to help me about :)
Related
I have a list component with a (row oriented) tile layout in a group that sits in the main Application.
I want the list to be centred vertically when there are not enough items in to fill the application window height, so verticalCenter="0".
However, when there are more items than can fit vertically on screen, the list expands beyond the application window height and the scrollbar doesn't kick in.
I can remedy this if setting the list height to 100%, but that means it's not vertically centred when it contains less items.
The ideal solution would be maxHeight="100%", but of course maxHeight doesn't work with percentages. How would I go about achieving this behaviour?
Thanks,
Tim
Edit: Please see the code below:
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
applicationComplete="applicationCompleteHandler(event)"
width="800" height="600"
showStatusBar="false">
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
import mx.events.FlexEvent;
protected function applicationCompleteHandler(event:FlexEvent):void
{
var arrayList:ArrayList = new ArrayList;
for (var i:int = 1; i <= 50; i ++)
{
arrayList.addItem(String(i));
}
list.dataProvider = arrayList;
}
]]>
</fx:Script>
<s:List id="list"
itemRenderer="itemRenderer"
useVirtualLayout="false"
horizontalCenter="0" verticalCenter="0"
borderVisible="false">
<s:layout>
<s:TileLayout orientation="rows"
requestedColumnCount="4"
columnWidth="150" rowHeight="150"/>
</s:layout>
</s:List>
</s:WindowedApplication>
This is my item renderer:
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true">
<s:Rect width="100%" height="100%">
<s:stroke>
<s:SolidColorStroke color="0"/>
</s:stroke>
</s:Rect>
<s:Label text="{data}"
horizontalCenter="0" verticalCenter="0" fontSize="50"/>
</s:ItemRenderer>
If the for loop is changed to only 10 iterations, the list is centred vertically on the screen. Otherwise the list expands beyond the screen, centred vertically and no scrollbar appears.
Using clipAndEnableScrolling hasn't made any difference. I've also tried putting the list inside a group with 100% width & height, but I'm getting more or less the same behaviour except the list is flush to the top when it is taller than the container.
You can try something like this:
<s:List id="list" maxHeight="{list.height}" height="100%" />
You could also change the maxHeight value whenever it's parent container changes sizes.
To get a complete answer, I think you're going to have to show some code about how things are set up.
Here's how to automatically set the maxHeight value whenever the parent container changes size (as JeffryHouser suggest above):
<s:Group id="boostListParent" width="100%" height="80%">
<s:List id="boostList" width="100%" maxHeight="{boostListParent.height}" height="100%" itemRenderer="views.BoostTierItemRenderer"/>
</s:Group>
I'm trying to set the hand cursor on an HBox. I've tried buttonMode and useHandCursor but have had no luck. This example displays the busy cursor. Can anyone tell me how to make it display the flashPlayer's hand cursor?
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="com.dn2k.components.*" >
<fx:Script>
<![CDATA[
private var cursorID:int;
//cursorManager
protected function box_mouseOverHandler(event:MouseEvent):void
{
cursorManager.setBusyCursor()
}
]]>
</fx:Script>
<mx:HBox id="box" useHandCursor="true" buttonMode="true" mouseChildren="false" backgroundColor="0xcc0000" mouseOver="box_mouseOverHandler(event)">
<s:Label text="Hiya sexy..."/>
</mx:HBox>
This code shows it perfectly while mouse is over container:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<mx:HBox backgroundColor="0xcc0000" buttonMode="true" id="box" mouseChildren="false" useHandCursor="true">
<s:Label text="Hiya sexy..." />
</mx:HBox>
</s:Application>
If you want to set hand cursor in Label you must set mouseChildren=”false” and below is the revised code
<mx:HBox backgroundColor="0xcc0000" buttonMode="true" id="box" useHandCursor="true">
<s:Label text="Hiya sexy..." buttonMode="true" mouseChildren="false" useHandCursor="true" />
</mx:HBox>
Hope this works for you.
What Jeff said. Also you can use CursorManager.setCursor(). You'll have to embed a graphic for the cursor though.
You can also use the newer Mouse class which provides a higher frame rate native cursor.
<mx:HBox rollOver="Mouse.cursor = MouseCursor.BUTTON"
backgroundColor="0" backgroundAlpha="0"
rollOut="Mouse.cursor = MouseCursor.AUTO"/>
The background color and background alpha are used to draw out graphics that are used as the hit area. In empty Spark containers there is a mouseEnabledWhereTransparent property that I don't think existed in mx containers. Here is documentation on it:
When true, this property ensures that the entire bounds of the Group
respond to mouse events such as click and roll over. This property
only goes in to effect if mouse, touch, or flash player gesture events
are added to this instance. In addition, it assumes that the calls to
addEventListener()/removeEventListener() are not superfluous.
Having said that it seems that this works without setting the mouseEnabledWhereTransparent property:
<s:Group id="testingHitGroup" left="10" top="10"
rollOver="cursorObject_rollOver(event)" width="100" height="100"/>
I'm coding a image viewer application for tablets using Adobe Flex 4.5. Basically, I have a list with a custom item renderer that renders the images in the list. I have set up the image size to be the width/height of the tablet device in portrait (600x1024). This way, only one image can be seen at one time. The problem is that when the device orients to landscape, this design obviously screws up. My question is how can I get it to change the width/height of my images automatically when the orientation changes such that only one image is shown at a time? Or, is there a better way of approaching this?
This is my list:
<s:List width="600" height="1024"
id="imageList" dataProvider="{data}" itemRenderer="{inlineRenderer}" click="imageList_clickHandler(event)"
verticalScrollPolicy="off" useVirtualLayout="true">
<s:layout>
<s:HorizontalLayout columnWidth="600"/>
</s:layout>
</s:List>
This is the item renderer:
<s:Scroller width="600" height="1024">
<s:Group>
<s:Image source="{data.imageurl}" width="600" height="1024"
contentLoader="{FlexGlobals.topLevelApplication.imageCache}"/>
</s:Group> </s:Scroller>
Here is an example of how to create an image only item renderer that handles orientation changes automatically:
<s:List id="list" width="100%" height="100%">
<s:dataProvider>
<s:ArrayList>
<fx:String>http://www.google.com/images/logos/ps_logo2.png</fx:String>
<fx:String>http://www.google.com/images/logos/ps_logo2.png</fx:String>
<fx:String>http://www.google.com/images/logos/ps_logo2.png</fx:String>
<fx:String>http://www.google.com/images/logos/ps_logo2.png</fx:String>
<fx:String>http://www.google.com/images/logos/ps_logo2.png</fx:String>
</s:ArrayList>
</s:dataProvider>
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer width="{outerDocument.list.width}"
height="{outerDocument.list.height}">
<fx:Script>
<![CDATA[
import spark.core.ContentCache;
[Bindable]
public static var imageCache:ContentCache = new ContentCache();
override public function set data(value:Object):void {
super.data = value;
bitmapImage.source = data;
}
]]>
</fx:Script>
<s:BitmapImage id="bitmapImage" contentLoader="{imageCache}" width="100%" height="100%" />
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
This renderer should perform pretty well even tho it is written in MXML because it follows some simple optimization rules (see http://flexponential.com/2011/04/20/flex-performance-tips-tricks/), but you'll want to test it in your application to make sure it feels ok.
In general Adobe recommends writing item renderers in ActionScript by extending LabelItemRenderer or IconItemRenderer for best performance. If the renderer above isn't fast enough for you then you might want to check out https://bugs.adobe.com/jira/browse/SDK-30043 for a discussion on the current problem and workaround to doing this with IconItemRenderer.
I'm creating a spark list in my flex mobile application and i want to do like a list on the iphone with a corner radius.
Unfortunately there is no cornerRadius or simply radius in list styles.
I call a list in a view:
<s:List id="language" width="100%" height="70" borderVisible="true"
change="navigator.pushView(LanguageView)" dataProvider="{languageCell}"
itemRenderer="skins.CustomCellStyle1"/>
Then I call itemRenderer:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
width="100%" height="70">
<s:HGroup width="100%" verticalCenter="0" paddingLeft="15" paddingRight="15">
<s:Label text="{data.label}"/>
<s:Spacer width="100%"/>
<s:Label text="{data.content}"
textAlign="right"
color="0x046380" paddingRight="5"/>
<s:BitmapImage id="icon"
source="{data.mark}"
verticalCenter="0"/>
</s:HGroup>
</s:ItemRenderer>
So how can I use corner radius on my cells?
http://viconflex.blogspot.com/2008/05/sometimes-cornerradius-just-isnt-enough.html
Two tips for coders new to Flex... if you want to have rounded corners in mx.containers like VBox, HBox, Canvas, etc, set the borderStyle to solid and the borderThickness to 0, and then set your cornerRadius to whatever you want. If the borderStyle is left at none (default), the cornerRadius attribute seems broken and ineffective.
The second tip, if you want rounded corners at the top and bottom of your Panel, there's a property called roundedBottomCorners which defaults to false. When set to true, you will see rounding both top and bottom.
I'm pretty sure my dynamic mxml layout must give me two scrollbars (horizontal and vertical) but it only shows vertical one.
Am I missing something or is it a bug?
<?xml version="1.0" encoding="utf-8"?>
<s:Application 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="100%" height="100%" xmlns:local="*">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var myData:ArrayCollection = new ArrayCollection([
{name:"Jane"},
{name:"Sonny"},
{name:"Alicia"}
]);
]]>
</fx:Script>
<s:Scroller width="100%" height="100%">
<s:VGroup>
<s:Group minHeight="600" minWidth="800" height="100%" width="100%">
<mx:HDividedBox id="div1" width="100%" height="100%" autoLayout="true" liveDragging="true">
<mx:DataGrid width="100%" height="100%" dataProvider="{myData}"/>
<mx:DataGrid width="100%" height="100%" dataProvider="{myData}"/>
</mx:HDividedBox>
</s:Group>
</s:VGroup>
</s:Scroller>
</s:Application>
Remove the VGroup inside the Scroller or change it to Group!
Seems that the horizontal scrollbar is not shown when using VGroup as first child
You haven't set horizontalScrollPolicy and verticalScrollPolicy for the Scroller and hence they have their value set to the auto. The behavior in this case is to display the scrollbars only if necessary.
The scroll bars are displayed according to the vertical and horizontal scroll bar policy, which can be auto, on, or off. The auto policy means that the scroll bar will be visible and included in the layout when the viewport's content is larger than the viewport itself.
Try with
<s:Scroller width="100%" height="100%" horizontalScrollPolicy="on">