moglie
08-01-2008, 07:37 AM
Take this example from the help files. How would I go about making the totalEntries variable an argument so I could keep this class "generic" and go about setting the totalEntries variable in the Flash file on frame 1?
package {
import fl.controls.TileList;
import fl.data.DataProvider;
import flash.display.Sprite;
import flash.events.Event;
public class MakeTileList extends Sprite {
public function MakeTileList() {
var dp:DataProvider = new DataProvider();
var totalEntries:uint = 5;
var i:uint;
for (i=0; i<totalEntries; i++) {
dp.addItem( { label:"star"+i, source:"slide" +i, scaleContent:false} );
}
var myTileList:TileList = new TileList();
myTileList.allowMultipleSelection = true;
myTileList.columnWidth = 125;
myTileList.rowHeight = 150;
myTileList.dataProvider = dp;
myTileList.columnCount = 3;
myTileList.rowCount = 1;
myTileList.move(10,10);
addChild(myTileList);
}
}
}
package {
import fl.controls.TileList;
import fl.data.DataProvider;
import flash.display.Sprite;
import flash.events.Event;
public class MakeTileList extends Sprite {
public function MakeTileList() {
var dp:DataProvider = new DataProvider();
var totalEntries:uint = 5;
var i:uint;
for (i=0; i<totalEntries; i++) {
dp.addItem( { label:"star"+i, source:"slide" +i, scaleContent:false} );
}
var myTileList:TileList = new TileList();
myTileList.allowMultipleSelection = true;
myTileList.columnWidth = 125;
myTileList.rowHeight = 150;
myTileList.dataProvider = dp;
myTileList.columnCount = 3;
myTileList.rowCount = 1;
myTileList.move(10,10);
addChild(myTileList);
}
}
}