How to get clip content to work on mx TabNavigator? - apache-flex

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>

Related

Allowing pop-up's and downloads with flex

I'm building an flex app that is basically a wrapper for a few websites. One of them is a google docs website, and I'm trying to get flex to allow downloads or popups or something that will allow me to do it. I've tried a whole bunch of solutions online and none of them have worked out. Here's the code so far:
<?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"
width="100%" height="100%"
creationComplete="onCreationComplete()">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<fx:Style source="style.css"/>
<fx:Script>
<![CDATA[
include "CustomHTMLLoader.as";
private function onCreationComplete():void
{
// ... other stuff ...
var custom:object;
custom.htmlHost = new MyHTMLHost();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:BorderContainer width="100%" height="100%" backgroundColor="#87BED0" styleName="container">
<s:Panel x="188" y="17" width="826" height="112" borderAlpha="0.15" chromeColor="#0C5A74"
color="#FFFFFF" cornerRadius="20" dropShadowVisible="false" enabled="true"
title="Customer Service Control Panel">
<s:controlBarContent/>
<s:Button id="home" x="13" y="10" height="44" label="Phones"
click="myViewStack.selectedChild=Home;" enabled="true"
icon="#Embed('assets/iconmonstr-mobile-phone-6-icon-32.png')"/>
<s:Button id="liveagent" x="131" y="10" height="44" label="Live Agent"
click="myViewStack.selectedChild=live_agent;"
icon="#Embed('assets/iconmonstr-speech-bubble-11-icon-32.png')"/>
<s:Button id="bigcommerce" x="260" y="10" width="158" height="44" label="Big Commerce"
click="myViewStack.selectedChild=bigcommerce_home;"
icon="#Embed('assets/iconmonstr-coin-6-icon-48.png')"/>
<s:Button id="faq" x="436" y="10" width="88" height="44" label="FAQ"
click="myViewStack.selectedChild=freqaskquestions;" fontFamily="Arial"
icon="#Embed('assets/iconmonstr-help-4-icon-32.png')"/>
<s:Button id="call" x="540" y="10" width="131" height="44" label="Google Docs"
click="myViewStack.selectedChild=call_notes;"
icon="#Embed('assets/iconmonstr-text-file-4-icon-32.png')"/>
<s:Button id="hoot" x="684" y="10" width="122" height="44" label="HootSuite"
click="myViewStack.selectedChild=hoot_suite;"
icon="#Embed('assets/iconmonstr-facebook-icon-32.png')"/>
</s:Panel>
<mx:ViewStack id="myViewStack" x="0" y="140" width="100%" height="100%" borderStyle="solid">
<s:NavigatorContent id="Home">
<s:BorderContainer width="100%" height="100%">
<mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
horizontalScrollPolicy="off"
location="http://mbvphone.mtbakervapor.org/vbx/messages/inbox"
/>
</s:BorderContainer>
</s:NavigatorContent>
<s:NavigatorContent id="bigcommerce_home">
<s:BorderContainer width="100%" height="100%">
<mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
horizontalScrollPolicy="off"
location="http://www.mtbakervapor.com/admin"
/>
</s:BorderContainer>
</s:NavigatorContent>
<s:NavigatorContent id="live_agent">
<s:BorderContainer width="100%" height="100%">
<mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
horizontalScrollPolicy="off"
location="http://mbvphone.mtbakervapor.org/liveagent/agent/#login"
/>
</s:BorderContainer>
</s:NavigatorContent>
<s:NavigatorContent id="freqaskquestions">
<s:BorderContainer width="100%" height="100%">
<mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
horizontalScrollPolicy="off"
location="http://mbvphone.mtbakervapor.org/liveagent/"
/>
</s:BorderContainer>
</s:NavigatorContent>
<s:NavigatorContent id="call_notes">
<s:BorderContainer width="100%" height="100%">
<mx:HTML id="html" x="0" y="0" width="100%" height="100%" borderVisible="false"
horizontalScrollPolicy="off"
location="https://drive.google.com/a/mtbakervapor.com/"
htmlHost="{new CustomHost()}"
/>
</s:BorderContainer>
</s:NavigatorContent>
<s:NavigatorContent id="hoot_suite">
<s:BorderContainer width="100%" height="100%">
<mx:HTML x="0" y="0" width="100%" height="100%" borderVisible="false"
horizontalScrollPolicy="off"
location="https://hootsuite.com/login"
/>
</s:BorderContainer>
</s:NavigatorContent>
</mx:ViewStack>
<s:Image x="0" y="0" width="180" height="140" scaleMode="letterbox" smooth="false"
source="assets/mbvlogo_black.png"/>
</s:BorderContainer>
</s:WindowedApplication>
and the custom class code:
package
{
import flash.html.HTMLHost;
import flash.html.HTMLWindowCreateOptions;
import flash.html.HTMLLoader;
public class MyHTMLHost extends HTMLHost
{
public function MyHTMLHost(defaultBehaviors:Boolean=true)
{
super(defaultBehaviors);
}
override public function createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader
{
// all JS calls and HREFs to open a new window should use the existing window
return HTMLLoader.createRootWindow();
}
}
}
any help would be appreciated.

Flex 4.5 TabNavigator cornerRadius not working

I'm having the hardest time finding a way to simply add rounded tabs to a TabNavigator control.
I have seen examples which seem to be really simple but they don't seem to work in Flex 4.5. Here is some sample 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">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Style source="style.css"/>
<mx:TabNavigator x="93" y="90" width="571" height="293" tabStyleName="tabstyle">
<s:NavigatorContent width="100%" height="100%" label="Tab 1">
</s:NavigatorContent>
</mx:TabNavigator>
</s:Application>
and the css:
/* CSS file */
#namespace s "library://ns.adobe.com/flex/spark";
#namespace mx "library://ns.adobe.com/flex/mx";
.tabstyle
{
corner-radius: 10;
}
I have also tried cornerRadius: 10;
Any ideas why this does not work? Any easy to follow solution (I'm a beginner).
Thanks.
You could create a skin for your app/tab navigator, use the 'create copy of' option in Flash Builder, and in the Rect section, set the radiusX, radiusY values. Then use that skin for the component
This is the best and easiest workaround I know for this problem. It seems Adobe never solved this bug.
<s:VGroup width="100%" height="100%" gap="0" >
<s:Group width="100%">
<s:TabBar left="4" dataProvider="{tabNav}" cornerRadius="4" />
</s:Group>
<s:BorderContainer width="100%" height="100%" cornerRadius="4">
<mx:ViewStack id="tabNav" paddingBottom="10" width="100%" height="100%" >
<s:NavigatorContent label="Form" width="100%" height="100%">
...
</s:NavigatorContent>
<mx:Canvas id="treeNode" label="TreeNodeComponent" width="100%" height="100%">
...
</mx:Canvas>
<mx:Canvas id="melding" label="Melding" width="100%" height="100%" visible="{authorisation.moduleHasUserAutorization('melding')}" includeInLayout="{melding.visible}">
...
</mx:Canvas>
</mx:ViewStack>
</s:BorderContainer>
</s:VGroup>
It's the equivalent of this but with rounded corners in the tabs (and body):
<mx:TabNavigator id="tabNav" paddingBottom="10" width="100%" height="100%" >
<s:NavigatorContent label="Form" width="100%" height="100%">
...
</s:NavigatorContent>
<mx:Canvas id="treeNode" label="TreeNodeComponent" width="100%" height="100%">
...
</mx:Canvas>
<mx:Canvas id="melding" label="Melding" width="100%" height="100%" visible="{authorisation.moduleHasUserAutorization('melding')}" includeInLayout="{melding.visible}">
...
</mx:Canvas>
</mx:TabNavigator>
Try this!
<mx:TabNavigator id="tabNavigator" tabOffset="20" cornerRadius="10" height="100%" width="100%">
This is the sample code you can copy and run
<s:NavigatorContent id="search" label="Search" width="100%" height="100%" fontWeight="bold"
>
<s:layout>
<s:VerticalLayout horizontalAlign="center"
paddingTop="5" paddingLeft="5"
paddingRight="5" paddingBottom="5" />
</s:layout>
<s:Label text="Search Panel" />
<s:HGroup >
<s:TextInput id="Searchtxt" width="200" />
<mx:Button label="search" click="Searchtxt.text=''" />
</s:HGroup>
</s:NavigatorContent>
<s:NavigatorContent id="custInfo" label="Customer Info" backgroundColor="0xDCDCDC"
width="100%" height="100%" fontWeight="bold" >
<s:layout>
<s:VerticalLayout horizontalAlign="center"
paddingTop="5" paddingLeft="5"
paddingRight="5" paddingBottom="5" />
</s:layout>
<s:Label text="Customer Info" />
<s:HGroup>
<s:Label text="Email Address"/>
<s:TextInput id="email" width="200"/>
<s:Button label="Submit" click="email.text='';" />
</s:HGroup>
</s:NavigatorContent>
<s:NavigatorContent id="accountInfo" label="Account Info" backgroundColor="0xDCDCDC" width="100%" height="100%" fontWeight="bold" >
<s:layout>
<s:VerticalLayout horizontalAlign="center"
paddingTop="5" paddingLeft="5"
paddingRight="5" paddingBottom="5" />
</s:layout>
<s:Label text="Account Info" />
<s:HGroup>
<s:Button label="Purchases" />
<s:Button label="Sales" />
<s:Button label="Reports" />
</s:HGroup>
</s:NavigatorContent>
</mx:ViewStack>

Flex 4 transition: Glitch with simultaneous move and resize

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.

Nested scroller not working

A sample app where the scroller does not show up. Is there any sane way of using a scroller in a constrain based layout?
<?xml version="1.0" encoding="utf-8"?>
<s:HGroup left="0" right="0" top="0" bottom="0">
<s:Scroller left="0" right="0" top="0" bottom="0">
<s:VGroup>
<s:BorderContainer borderColor="0" width="500" height="500"/>
<s:BorderContainer borderColor="0" width="500" height="500"/>
<s:BorderContainer borderColor="0" width="500" height="500"/>
</s:VGroup>
</s:Scroller>
</s:HGroup>
Found the solution after "brute forcing" every possible combination of left/right/widt/height etc
<?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"
width="500" height="400"
>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:HGroup left="0" right="0" top="0" bottom="0" >
<s:Scroller width="100%" height="100%">
<s:VGroup >
<s:BorderContainer borderColor="0" width="500" height="500"/>
<s:BorderContainer borderColor="0" width="500" height="500"/>
<s:BorderContainer borderColor="0" width="500" height="500"/>
</s:VGroup>
</s:Scroller>
</s:HGroup>
</s:WindowedApplication>

horizontalCenter parameter discarded in flex 4 vgroup

No matter what value I put in the horizontalCenter property of the "Browse" button, it just follows the horizontalAlign property of the VGroup. Why is that ?
Thanks
<s:Group width="100%" height="100%" left="0" right="0" top="0" bottom="0">
<s:Panel id="mainPanel" title="File uploader" width="75%" height="75%" horizontalCenter="0" verticalCenter="0">
<s:controlBarContent> <s:Label text="foo"/> </s:controlBarContent>
<mx:HDividedBox width="100%" height="100%">
<s:VGroup width="25%" height="100%" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10">
<s:TextArea width="100%" height="100%" />
<s:Button label="Browse" horizontalCenter="30"/>
</s:VGroup>
<s:TextArea width="100%" height="100%" />
</mx:HDividedBox>
</s:Panel>
</s:Group>
The VGroup in Flex 4 uses spark.layouts.VerticalLayout which doesn't take into account horizontalCenter/verticalCenter :/. I don't like that myself.
But since your VGroup's child TextArea is 100% width/height, you can use the VerticalLayout/VGroup horizontalAlign property: horizontalAlign="center". That works:
<s:Group width="100%" height="100%" left="0" right="0" top="0" bottom="0">
<s:Panel id="mainPanel" title="File uploader" width="75%" height="75%" horizontalCenter="0" verticalCenter="0">
<s:controlBarContent>
<s:Label text="foo"/>
</s:controlBarContent>
<mx:HDividedBox width="100%" height="100%">
<s:VGroup width="25%" height="100%" paddingLeft="10" horizontalAlign="center" paddingRight="10" paddingTop="10" paddingBottom="10">
<s:TextArea width="100%" height="100%" />
<s:Button label="Browse" horizontalCenter="30"/>
</s:VGroup>
<s:TextArea width="100%" height="100%" />
</mx:HDividedBox>
</s:Panel>
</s:Group>

Resources