Flex 4 transition: Glitch with simultaneous move and resize - apache-flex

I'm building a user interface and I have two panels which I need to move and resize. They have to look as a single panel. It works fine when I move or resize only one. But when one moves and the other resizes at the same time... an intermittent line appears between the two.
How can I avoid this?
Here is a working example of the problem:
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:components="components.*"
frameRate="30" height="400" width="200" >
<s:states>
<s:State name="minimized" />
<s:State name="maximized" />
</s:states>
<s:transitions>
<s:Transition>
<s:Parallel duration="4000" targets="{[one, two]}">
<s:Move target="{two}" />
<s:Resize target="{one}" />
</s:Parallel>
</s:Transition>
</s:transitions>
<s:Group id="one"
width="200"
height.minimized="20" height.maximized="200"
y="0">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="black" />
</s:fill>
</s:Rect>
</s:Group>
<s:Group id="two"
width="200"
height="200"
y.minimized="20" y.maximized="200">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="black" />
</s:fill>
</s:Rect>
</s:Group>
<s:Button click="currentState=(currentState=='minimized'? 'maximized' : 'minimized')" label="{currentState}" />
</s:WindowedApplication>
Thanks in advance!
Updated: Here's a version with VGroup:
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:components="components.*"
frameRate="30" height="400" width="400" >
<s:states>
<s:State name="minimized" />
<s:State name="maximized" />
</s:states>
<s:transitions>
<s:Transition>
<s:Parallel duration="4000" targets="{[one, two, three]}">
<s:Move target="{two}" />
<s:Resize target="{one, three}" />
</s:Parallel>
</s:Transition>
</s:transitions>
<s:Group id="one"
width="200"
height.minimized="20" height.maximized="200"
y="0">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="black" />
</s:fill>
</s:Rect>
</s:Group>
<s:Group id="two"
width="200"
height="200"
y.minimized="20" y.maximized="200">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="black" />
</s:fill>
</s:Rect>
</s:Group>
<s:VGroup gap="0" left="200">
<s:Group id="three"
width="200"
height.minimized="20" height.maximized="200"
y="0">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="black" />
</s:fill>
</s:Rect>
</s:Group>
<s:Group id="four"
width="200"
height="200">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="black" />
</s:fill>
</s:Rect>
</s:Group>
</s:VGroup>
<s:Button click="currentState=(currentState=='minimized'? 'maximized' : 'minimized')" label="{currentState}" />
</s:WindowedApplication>

Place both in the same VGroup and change the height of the first panel only.

Related

How to get clip content to work on mx TabNavigator?

I have a TabNavigator and before that a ViewStack with TabBar that would not clip it's contents. It over flows the border or appears under other components positioned further down the screen. Has anyone run into this before?
Here is my code:
<mx:VDividedBox width="300" height="100%">
<mx:TabNavigator id="firstViewStack"
borderStyle="solid"
width="100%"
height="100%"
clipContent="true">
<s:NavigatorContent id="content1"
label="ITEMS">
<views:Items height="550" width="100%" />
</s:NavigatorContent>
<s:NavigatorContent id="eventsContent" label="ITEMS 2">
<views:Items height="880" width="100%"/>
</s:NavigatorContent>
</mx:TabNavigator>
</mx:VDividedBox>
UPDATE
I've included a animated gif of me resizing the tab content. As you can see the mask appears to be sized to the content rather than the available area??? Notice the border of the tab navigator along the size is being overlapped when resizing.
I set the minimum height on all of the content to lower values and height to 100% on all the content so it is not as high but you can see the content is still not getting clipped.
I also tried with a VGroup rather than a VDividedBox and it doesn't matter.
Here is another code example:
<s:VGroup top="50" left="50" width="400">
<mx:TabNavigator width="100%" height="300">
<s:NavigatorContent label="TAB">
<s:Group width="100%" height="400">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="#ff0000"/>
</s:fill>
</s:Rect>
</s:Group>
</s:NavigatorContent>
<s:NavigatorContent label="TAB">
<s:Group width="100%" height="400">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="#0000ff"/>
</s:fill>
</s:Rect>
</s:Group>
</s:NavigatorContent>
</mx:TabNavigator>
<s:Button width="100%" label="HELLO WORLD"/>
<s:Button width="100%" label="HELLO WORLD"/>
</s:VGroup>
I have implemented 2 approaches - one with a Scroller and another with autosize.
Here is an example
Here is the code:
<?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"
minWidth="955" minHeight="600">
<s:HGroup width="100%" height="100%" left="50" top="50">
<!-- Using Scroller-->
<s:VGroup width="400">
<mx:TabNavigator width="100%" height="300">
<s:NavigatorContent label="TAB" width="100%" height="100%">
<s:Scroller width="100%" height="100%">
<s:Group>
<s:Group width="100%" height="400">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="#ff0000"/>
</s:fill>
</s:Rect>
</s:Group>
</s:Group>
</s:Scroller>
</s:NavigatorContent>
<s:NavigatorContent label="TAB" width="100%" height="100%">
<s:Scroller width="100%" height="100%">
<s:Group>
<s:Group width="100%" height="600">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="#0000ff"/>
</s:fill>
</s:Rect>
</s:Group>
</s:Group>
</s:Scroller>
</s:NavigatorContent>
</mx:TabNavigator>
<s:Button width="100%" label="HELLO WORLD"/>
<s:Button width="100%" label="HELLO WORLD"/>
</s:VGroup>
<s:Spacer width="60"/>
<!-- Using Autosize-->
<s:VGroup top="50" left="50" width="400">
<mx:TabNavigator width="100%" minHeight="300" resizeToContent="true" >
<s:NavigatorContent label="TAB" width="100%" height="100%">
<s:Group width="100%" height="400">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="#ff0000"/>
</s:fill>
</s:Rect>
</s:Group>
</s:NavigatorContent>
<s:NavigatorContent label="TAB" width="100%" height="100%">
<s:Group width="100%" height="500">
<s:Rect width="100%" height="100%">
<s:fill>
<s:SolidColor color="#0000ff"/>
</s:fill>
</s:Rect>
</s:Group>
</s:NavigatorContent>
</mx:TabNavigator>
<s:Button width="100%" label="HELLO WORLD"/>
<s:Button width="100%" label="HELLO WORLD"/>
</s:VGroup>
</s:HGroup>
</s:Application>

Flex Skin button, keep icon

I am trying to skin buttons in Flex, but after I skinned a button the icon that I had linked in it disappeared. I know I can add the icon into the skin, but that would mean I have to create lots of different skins.
Any EASY way to fix this?
mxml file:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:ns1="*"
xmlns:packageservice="services.packageservice.*"
title="My Dish"
fontSize.Beef="10" textAlign.Beef="center">
<fx:Script>
<![CDATA[
import com.adobe.serializers.utility.TypeUtility;
import mx.events.FlexEvent;
protected function list_creationCompleteHandler(event:FlexEvent):void
{
my_get_beef_dishResult.token = packageService.my_get_beef_dish();
}
protected function list2_creationCompleteHandler(event:FlexEvent):void
{
my_get_pork_dishResult.token = packageService.my_get_pork_dish();
}
protected function list3_creationCompleteHandler(event:FlexEvent):void
{
my_get_chicken_dishResult.token = packageService.my_get_chicken_dish();
}
protected function list4_creationCompleteHandler(event:FlexEvent):void
{
my_get_fish_dishResult.token = packageService.my_get_fish_dish();
}
protected function list5_creationCompleteHandler(event:FlexEvent):void
{
my_get_vegetables_dishResult.token = packageService.my_get_vegetables_dish();
}
]]>
</fx:Script>
<s:states>
<s:State name="Beef"/>
<s:State name="Pork"/>
<s:State name="Chicken"/>
<s:State name="Fish"/>
<s:State name="Vegetables"/>
<s:State name="Other"/>
</s:states>
<s:navigationContent>
<s:Button label="Back" click="navigator.popView();"/>
</s:navigationContent>
<fx:Declarations>
<s:CallResponder id="my_get_beef_dishResult"/>
<packageservice:PackageService id="packageService"/>
<s:CallResponder id="my_get_pork_dishResult"/>
<s:CallResponder id="my_get_chicken_dishResult"/>
<s:CallResponder id="my_get_fish_dishResult"/>
<s:CallResponder id="my_get_vegetables_dishResult"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:VGroup x="0" y="0" width="245" height="364" contentBackgroundColor="#E6E6E6">
<s:List id="MyDishOther" includeIn="Other" width="245" height="364" contentBackgroundColor="#E6E6E6"></s:List>
<s:List id="list" includeIn="Beef" width="245" height="365"
creationComplete="list_creationCompleteHandler(event)" labelField="name">
<s:AsyncListView list="{my_get_beef_dishResult.lastResult}"/>
</s:List>
<s:List id="list2" includeIn="Pork" width="245" height="365"
creationComplete="list2_creationCompleteHandler(event)" labelField="name">
<s:AsyncListView list="{my_get_pork_dishResult.lastResult}"/>
</s:List>
<s:List id="list3" includeIn="Chicken" width="245" height="365"
creationComplete="list3_creationCompleteHandler(event)" labelField="name">
<s:AsyncListView list="{my_get_chicken_dishResult.lastResult}"/>
</s:List>
<s:List id="list4" includeIn="Fish" width="245" height="365"
creationComplete="list4_creationCompleteHandler(event)" labelField="name">
<s:AsyncListView list="{my_get_fish_dishResult.lastResult}"/>
</s:List>
<s:List id="list5" includeIn="Vegetables" width="245" height="365"
creationComplete="list5_creationCompleteHandler(event)" labelField="name">
<s:AsyncListView list="{my_get_vegetables_dishResult.lastResult}"/>
</s:List>
</s:VGroup>
...
<s:Button includeIn="Beef" width="70" icon="assets/beef.png" skinClass="components.Stab"/>
<s:Button includeIn="Beef" width="60" click="currentState='Chicken'" icon="assets/chicken.png"/>
<s:Button includeIn="Beef" width="60" click="currentState='Fish'" icon="assets/fish(1).png"/>
<s:Button includeIn="Beef" width="60" click="currentState='Pork'" icon="assets/porktest(1).png"/>
<s:Button includeIn="Beef" width="60" icon="assets/t_vegetables.png" click="currentState='Vegetables'"/>
.....
</s:VGroup>
</s:View>
SkinClass:
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" alpha.disabled=".5">
<!-- states -->
<s:states>
<s:State name="up" />
<s:State name="over" />
<s:State name="down" />
<s:State name="disabled" />
</s:states>
<!-- layer 2: fill -->
<s:Rect left="1" right="1" top="1" bottom="1" radiusX="2" radiusY="2">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFFFFFF"
color.over="0xBBBDBD"
color.down="0xAAAAAA"
alpha="0.85" />
<s:GradientEntry color="0xD8D8D8"
color.over="0x9FA0A1"
color.down="0x929496"
alpha="0.85" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<!-- layer 2: border -->
<s:Rect left="0" right="0" top="0" bottom="0" width="60" height="45" radiusX="2" radiusY="2">
<s:stroke>
<s:LinearGradientStroke rotation="90" weight="1">
<s:GradientEntry color="0x000000"
alpha="0.5625"
alpha.down="0.6375" />
<s:GradientEntry color="0x000000"
alpha="0.75"
alpha.down="0.85" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect>
</s:Skin>
As I could guess the problem is that your skin is not inherited from SparkButtonSkin.
Icon functionality is implemented in it and default button skin inherited SparkButtonSkin.

Flex item renderer - change alpha when clicked

I want to change the alpha of Rect when list item is clicked but I could not solve that. And I don't know how exactly do this as I'm doing it on Rectangle inside item renderer, is there any suggestion?
CODE:
<s:List id="list" labelField="name" dataProvider="{items}" top="20" bottom="20" left="20" right="20"
contentBackgroundAlpha="0"
change="list_changeHandler(event)">
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer width="100%" height="200" autoDrawBackground="false" contentBackgroundAlpha="0">
<s:Group width="100%" height="100%">
<s:Rect id="rect" left="0" right="0" top="0" bottom="0" alpha="0.3">
<s:fill>
<s:SolidColor color="#FFFFFF"
/>
</s:fill>
</s:Rect>
<s:Image source="{data.icon}" top="30" horizontalCenter="0"/>
<s:Label text="{data.name}" top="100" horizontalCenter="0" color="#101010" fontWeight="bold" fontSize="16"/>
<s:Label text="{data.line1}" top="130" horizontalCenter="0" color="#343434" fontSize="14"/>
<s:Label text="{data.line2}" top="150" horizontalCenter="0" color="#343434" fontSize="14"/>
</s:Group>
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
<s:layout>
<s:TileLayout requestedColumnCount="3" requestedColumnCount.landscape="4" columnAlign="justifyUsingWidth"/>
</s:layout>
</s:List>
You can use the ItemRenderer's states for this. Add these states to your ItemRenderer:
<s:states>
<s:State name="normal" />
<s:State name="hovered" />
<s:State name="selected" />
</s:states>
<s:Rect left="0" right="0" top="0" bottom="0">
<s:fill>
<s:SolidColor color.normal="0x0000ff"
color.hovered="0x00ff00"
color.selected="0xff0000" />
</s:fill>
</s:Rect>
With this code your renderer will be blue by default; it will turn green when you hover over it; and red when you select it. The same can of course be done with the alpha value.

How create smooth transitions for drop down list in flex for desktop applications?

I have a drop down list for selecting the titles for a person, I want to employ smooth drop down when i select the drop down menu, i am new to flex, can some please help me.
Thanks and Regards,
Ravi.
You will have to use a resize transition in the place of the fade transition in the following code:
<s:DropDownList id="dropDownList"
dataProvider="{arrList}"
requiresSelection="true"
skinClass="skins.CustomDropDownListSkin"
horizontalCenter="0"
top="20" />
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/04/28/setting-a-fade-transition-on-a-spark-dropdownlist-component-in-flex-gumbo/ -->
<s:SparkSkin name="CustomDropDownListSkin"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
alpha.disabled="0.5">
<s:states>
<s:State name="normal" />
<s:State name="open" />
<s:State name="disabled" />
</s:states>
<s:transitions>
<s:Transition fromState="normal" toState="open">
<s:Fade target="{popup}" duration="3000" />
</s:Transition>
</s:transitions>
<!-- host component -->
<fx:Metadata>
<![CDATA[
[HostComponent("spark.components.DropDownList")]
]]>
</fx:Metadata>
<!--- Defines the appearance of the DropDownList component's drop down area. -->
<s:PopUp id="popup"
open.normal="false" open.open="true"
includeIn="open"
left="0" right="0" top="0" bottom="0"
visible.open="true" visible.normal="false"
placement="below">
<s:Group id="dropDown"
maxHeight="134" minHeight="22"
visible.open="true" visible.normal="false">
<!-- border -->
<s:Rect left="0" right="0" top="0" bottom="0">
<s:stroke>
<s:SolidColorStroke color="0x686868" weight="1"/>
</s:stroke>
</s:Rect>
<!--- fill --->
<s:Rect id="background" left="1" right="1" top="1" bottom="1" >
<s:fill>
<s:SolidColor id="bgFill" color="0xFFFFFF" />
</s:fill>
</s:Rect>
<s:Scroller left="1" top="1" right="1" bottom="1" >
<s:DataGroup id="dataGroup" itemRenderer="spark.skins.default.DefaultItemRenderer">
<s:layout>
<s:VerticalLayout gap="0" horizontalAlign="contentJustify"/>
</s:layout>
</s:DataGroup>
</s:Scroller>
<s:filters>
<s:DropShadowFilter blurX="20" blurY="20" distance="5" angle="90" alpha="0.6" />
</s:filters>
</s:Group>
</s:PopUp>
<s:Button id="button" left="0" right="0" top="0" bottom="0" focusEnabled="false"
skinClass="spark.skins.default.DropDownListButtonSkin" />
<s:SimpleText id="labelElement" verticalAlign="middle"
left="7" right="30" top="2" bottom="2" verticalCenter="1" />
</s:SparkSkin>

Flex4 add scrollbar to application

I am trying to create a login page with minHeight=600 and minWidth=800. If a user resizes to smaller resolution, only then add scrollbars. I followed tutorial.
Code:
Main.xml
<?xml version="1.0"?>
<!-- containers\application\AppSparkScroll.mxml -->
<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"
minWidth="800" minHeight="600"
width="100%" height="100%"
backgroundColor="#292929"
skinClass="skins.CustomApplicationSkin">
<s:Panel title="Login" id="loginPanel" verticalCenter="0" horizontalCenter="0">
<mx:Form>
<mx:FormItem label="Username" width="100%">
<s:TextInput width="100%" id="username" />
</mx:FormItem>
<mx:FormItem label="Password" width="100%">
<s:TextInput width="100%" displayAsPassword="true" id="password" />
</mx:FormItem>
<mx:FormItem>
<s:Button label="Login" id="loginButton" />
</mx:FormItem>
</mx:Form>
</s:Panel>
skins.CustomApplicationSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
<!-- containers\application\mySkins\MyAppSkin.mxml -->
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Metadata>
[HostComponent("spark.components.Application")]
</fx:Metadata>
<s:states>
<s:State name="normal" />
<s:State name="disabled" />
</s:states>
<!-- fill -->
<s:Rect id="backgroundRect" left="0" right="0" top="0" bottom="0">
<s:fill>
<s:SolidColor color="0xFFFFFF" />
</s:fill>
</s:Rect>
<s:Scroller height="100%" width="100%">
<s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" />
</s:Scroller>
</s:Skin>
Same issue to me, I followed the same tutorial either. Could see the scrollers if I add the horizontalScrollPolicy="on" verticalScrollPolicy="on" to the scroller, but they just don't work even if the browser size is smaller than the content size.
In index.html file, within style declaration, paste following code,
html, body {height:100%; width:100%; min-width:800px; min-height:600px; overflow:auto; position:absolute;}
i hope it should works.Scroll bar should appear if screen size less than 800X600.

Resources