PDA

View Full Version : Changing the height of a viewstack dynamically?


loki421
07-10-2009, 08:56 PM
Hi all,

I have a viewstack that holds multiple components, most of which have list controls at different heights. I want to be able to resize the height of the viewstack based on the height of the contained list controls so that the lists themselves don't scroll, kinda like an HTML page would if you where looping over a database, the page would resize accordingly.

Anyway, here's what i've got

<mx:ViewStack id="viewstack1" width="100%" >
<views.component1 width="100%" />
<views.component2 width="100%" />
<views.component3 width="100%" />
</mx:ViewStack>


Example of function in component

<mx:Script>
<![CDATA[
private function getHeight(event:Event):void{
var height:Number = new Number;
height = (listTesting.height + 300);
Application.application.viewstack1.height = height;
}

]]>
</mx:Script>

<mx:List dataProvider="{myData}"
id="listTesting"
itemRenderer="views.listTestingView"
themeColor="#FFFFFF"
borderStyle="none"
paddingRight="10"
columnWidth="590" top="30"
variableRowHeight="true"
rowCount="{listTesting.dataProvider.length}"
editable="true" width="590" x="0"
creationComplete="getHeight(event)"/>


Now that works fine, until i try to navigate to another 'page' or index, then the whole app crashes :confused:

It's like it works fine for the first time it's fired, but once you navigate to the next component (where a simular function is fired on CreationComplete of that list), it just falls over, nothing responds.

Any ideas what's going wrong here? Is my AS3 a little wrong? :p

Just can't figure out what could be causing the crash....

Hope someone out there can help :D

nikos101
07-16-2009, 11:33 AM
You need to give your object in the HTML a height of 100% and the flex application tag a height of 100%.

jzmaoqyxm
07-20-2009, 06:54 AM
Decoration Engineering Co., Ltd. Hangzhou Meiqi杭州装修公司 (http://www.hzmqw.com/) provide quality decoration Hangzhou, Hangzhou decoration services, professional provide decoration store in Hangzhou, Hangzhou-store decoration, Hangzhou second-hand housing decoration, office decoration, Hangzhou, Hangzhou office decoration services, we have the professional services of Hangzhou decoration 杭州装饰公司 (http://www.hzmqw.com/)decoration team

loki421
07-21-2009, 12:21 PM
yeah i've tried that but it just doesn't work, any other ideas? :p