Flex4:如何添加子项以在AS中激活Scroller

时间:2010-02-18 09:14:18

标签: flex actionscript-3 flex4

我想将以下代码转换为ActionScript(mxml可以正常工作):

<mx:Panel title="Some Title" width="400" height="300">
  <s:Scroller width="100%" height="100%"/>
    <mx:ColumnChart id="myChart" attribute="..." />

这不能直接使用:

setupChart(); //setup myChart

var scroll:Scroller = new Scroller();
scroll.percentWidth = 100;
scroll.percentHeight = 100;
scroll.viewport = myChart;

1 个答案:

答案 0 :(得分:4)

添加小组首先适合我

setupChart();

var grp:Group = new Group();
grp.percentWidth = 100;
grp.percentHeight = 100;
grp.addElement( myChart );

var scroll:Scroller = new Scroller();
scroll.percentWidth = 100;
scroll.viewport = grp;