此代码的 AS3 循环代码是什么?
What is the AS3 loop code for this code?
它是我代码的一部分:
private var page_1:Page_1 = new Page_1();
private var page_2:Page_2 = new Page_2();
.
.
.
private var page_99:Page_99 = new Page_99();
private var page_100:Page_100 = new Page_100();
是否可以通过循环来实现?
p.s:对不起我的英语不好:(
所以不能创建私有成员,但如果你可以用数组或向量替换它,你可以这样做:
private var m_pages: Array = [];
for ( var i = 1; i <= 100; ++i )
{
var symbolClass:Class =getDefinitionByName("Page_" + i) as Class;
var page = new symbolClass();
m_pages.push( page );
}
它是我代码的一部分:
private var page_1:Page_1 = new Page_1();
private var page_2:Page_2 = new Page_2();
.
.
.
private var page_99:Page_99 = new Page_99();
private var page_100:Page_100 = new Page_100();
是否可以通过循环来实现? p.s:对不起我的英语不好:(
所以不能创建私有成员,但如果你可以用数组或向量替换它,你可以这样做:
private var m_pages: Array = [];
for ( var i = 1; i <= 100; ++i )
{
var symbolClass:Class =getDefinitionByName("Page_" + i) as Class;
var page = new symbolClass();
m_pages.push( page );
}