如何创建具有背景颜色的滚动组?

时间:2010-11-05 19:28:56

标签: flex colors background scroller

我正在使用Flash Builder 4 Premium。我的应用程序有一个标题栏,我不想滚动,下面的组应该滚动。这是我想要滚动的组:

<s:Scroller id="scrlMemberManager" includeIn="MemberManager" y="79" width="100%" height="100%" creationComplete="memberManagerInit()">
    <s:Group id="grpMemberManager">
        <s:Rect top="0" left="0" width="100%" height="100%">
            <s:fill>
                <s:SolidColor color="#bdbec0" />
            </s:fill>
        </s:Rect>
        <s:Panel id="pnlCenterMembers" width="597" height="444" x="10" y="5" title="Center Members">
            <s:Panel x="7" y="9" width="259" height="388" title="Create Member" dropShadowVisible="false">
                <s:TextInput x="71" y="11" width="164" id="txtCenterNewMemName" creationComplete="setUpTabKey(txtCenterNewMemName, null, txtCenterNewMemEmail)"/>
                <s:Label x="6" y="18" text="Name" width="60" textAlign="right"/>
                <s:TextInput x="71" y="41" width="164" id="txtCenterNewMemEmail" creationComplete="setUpTabKey(txtCenterNewMemEmail, txtCenterNewMemName, cboCenterNewMemGroup)"/>
                <s:Label x="6" y="48" text="Email" width="60" textAlign="right"/>
                <s:ComboBox x="71" y="71" width="164" id="cboCenterNewMemGroup" creationComplete="{ newMemGroup_creationCompleteHandler(event);  setUpTabKey(cboCenterNewMemGroup, txtCenterNewMemEmail, null); }" textAlign="center" dataProvider="{getCenterGroupNamesResult.lastResult}" />
                <s:Button x="165" y="101" label="Create" click="createUser('Center')" id="btnCenterCreateNewMem"/>
                <s:Label x="6" y="78" text="Group" width="60" textAlign="right"/>
            </s:Panel>
            <s:Panel x="274" y="10" width="314" height="388" title="Member List" dropShadowVisible="false" id="pnlCenterMemberList">
                <mx:DataGrid x="10" y="10" width="294" height="275" id="grdCenterMemberList" dataProvider="{getCenterMembersResult.lastResult}" allowMultipleSelection ="true" dragEnabled="false">
                    <mx:columns>
                        <mx:DataGridColumn headerText="Member Name" dataField="username"/>
                    </mx:columns>
                </mx:DataGrid>
                <s:Button x="10" y="295" label="Add To / Rem From Group" width="140" id="btnCenterAssignToGroup" click="assignMemberToGroup('Center')" fontSize="9"/>
                <s:Button x="10" y="324" label="Change Password" width="140" id="btnCenterChangePassword" click="changePassword('Center')" visible="false"/>
                <s:Button y="295" label="Delete" width="140" id="btnCenterDeleteMember" click="deleteMember_clickHandler(event)" right="9"/>
            </s:Panel>
        </s:Panel>
        <s:Panel id="pnlOnlineMembers" width="597" height="444" x="627" y="5" title="Our Online Members">
            <s:Button y="-26" id="btnSwitchOnlineMembers" label="Show All Online Members" width="170" right="7" click="switchOnlineMembers()"/>
            <s:Panel x="7" y="9" width="259" height="388" title="Create Member" dropShadowVisible="false">
                <s:Label x="6" y="18" text="Name" width="60" textAlign="right"/>
                <s:Label x="6" y="48" text="Password" width="60" textAlign="right"/>
                <s:Label x="6" y="108" text="Email" width="60" textAlign="right"/>
                <s:Label x="6" y="138" text="Group" width="60" textAlign="right"/>
                <s:Label x="6" y="71" text="Confirm Password" width="60" textAlign="right"/>
                <s:TextInput x="71" y="11" width="164" id="txtOnlineNewMemName" creationComplete="setUpTabKey(txtOnlineNewMemName, null, txtOnlineNewMemPassword1);"/>
                <s:TextInput x="71" y="41" width="164" id="txtOnlineNewMemPassword1" displayAsPassword="true" creationComplete="setUpTabKey(txtOnlineNewMemPassword1, txtOnlineNewMemName, txtOnlineNewMemPassword2);"/>
                <s:TextInput x="71" y="71" width="164" id="txtOnlineNewMemPassword2" displayAsPassword="true" creationComplete="setUpTabKey(txtOnlineNewMemPassword2, txtOnlineNewMemPassword1, txtOnlineNewMemEmail);"/>
                <s:TextInput x="71" y="101" id="txtOnlineNewMemEmail" width="164" creationComplete="setUpTabKey(txtOnlineNewMemEmail, txtOnlineNewMemPassword2, cboOnlineNewMemGroup);"/>
                <s:ComboBox x="71" y="131" width="164" textAlign="center" id="cboOnlineNewMemGroup" dataProvider="{getCenterGroupNamesResult.lastResult}" creationComplete="setUpTabKey(cboOnlineNewMemGroup, txtOnlineNewMemEmail, null);" />
                <s:Button x="165" y="160" label="Create" id="btnOnlineCreateNewMem" click="createUser('Online')"/>
            </s:Panel>
            <s:Panel x="274" y="10" width="314" height="388" title="Member List" dropShadowVisible="false">
                <mx:DataGrid x="10" y="10" width="294" height="275" id="grdOnlineMemberList" dataProvider="{onlineMembersArray}" allowMultipleSelection="true">
                    <mx:columns>
                        <mx:DataGridColumn headerText="Member Name" dataField="username"/>
                    </mx:columns>
                </mx:DataGrid>
                <s:Button x="10" y="295" label="Add To / Rem From Group" width="140" id="btnOnlineAssignToGroup" click="assignMemberToGroup('Online')" fontSize="9"/>
                <s:Button x="10" y="324" label="Change Password" width="140" id="btnOnlineChangePassword" click="changePassword('Online')" visible="false"/>
                <s:Button x="163" y="295" label="Add To Our Center" width="140" id="btnOnlineAssignToCenter" click="assignMemberToCenter()" visible="false"/>
                <s:Button x="163" y="295" label="Remove From Center" width="140" id="btnOnlineRemoveFromCenter" click="removeMemberFromCenter()"/>
            </s:Panel>
        </s:Panel>
        <s:Button right="10" bottom="10" label="Admin Manager" id="btnAdminManager" visible="false" click="{ goToAdminManager(); }" creationComplete="{if (currentUserRights[center] == 'OWNER' || currentUserRights[center] == 'SUPERUSER') btnAdminManager.visible = true;}"/>
    </s:Group>
</s:Scroller>

乍一看似乎一切正常,但是如果你让屏幕足够小到你必须滚动的地方,那么背景颜色不会填满整个滚动条,只会在开始滚动之前显示最初显示的部分,所以你得到的东西看起来像这样:

Background does not scroll

我不确定解决这个问题的最佳方法是什么,但我想我可以调整背景颜色Rect以匹配滚动条宽度...如果我能找出滚动条宽度是什么。并且通过滚动条宽度,我的意思是它包含的内容的宽度,而不是其视口的宽度(希望我的术语是正确的)。有没有办法找到这个宽度,还是有更好的方法来做到这一点?设置每个面板的宽度,但窗口的大小可能会超出内容的宽度,所以我想确保背景填充用户的窗口(当然不包括标题栏),无论它们的大小如何窗口是。

2 个答案:

答案 0 :(得分:1)

我刚想出了一个解决方法。

我将背景颜色Rect移动到Scroller上方,并将其位置设置为与Scroller相同。现在,它位于页面上具有相同尺寸的滚动条后面,因此当您滚动组时,Rect不会滚动,您仍然可以看到背景颜色,因为滚动条和组背景是透明的。

答案 1 :(得分:0)

我使用的解决方案是将滚动条放在边框容器中。你可以将borderColor设置为任何东西,这样你就可以让它消失(如果你不想让卷轴放在容器内的视觉外观;在我的情况下,我使用黑色轮廓,因为我想要容器的边框到出现)。例如:

<s:BorderContainer width="340" height="100%" borderWeight="1" borderStyle="solid" borderColor="0x000000">
    <s:backgroundFill> 
        <s:SolidColor color="0xDDDDDD" alpha="1"/> 
             </s:backgroundFill>
    <s:Scroller width="100%" height="100%">                 
        ...
    </s:Scroller>
</s:BorderContainer>