问题
I want to convert the following code to ActionScript (mxml works fine):
<mx:Panel title="Some Title" width="400" height="300">
<s:Scroller width="100%" height="100%"/>
<mx:ColumnChart id="myChart" attribute="..." />
This doesn't work straight forward:
setupChart(); //setup myChart
var scroll:Scroller = new Scroller();
scroll.percentWidth = 100;
scroll.percentHeight = 100;
scroll.viewport = myChart;
回答1:
adding a group first works for me
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;
来源:https://stackoverflow.com/questions/2287431/flex4-how-to-add-a-child-to-spark-scroller-in-as