如何在 Actionscript 3.0 中将一种矢量数据转换为另一种矢量数据
Class ShootGame implements IGame
{
}
//ShootGame Vector
var shootGames:Vector.<ShootGame> = new Vector.<ShootGame>();
for(i=0;i<20;i++)
{
shootGames.push(new ShootGame());
}
var igames:Vector.<IGame> = //What is the Simplest method to convert ShootGame to IGame Vector
//I am doing like
igames = new Vector.<IGame>();
for(i=0;i < shootGames.length;i++)
{
igames.push(shootGames[i]);
}
Class ShootGame implements IGame
{
}
//ShootGame Vector
var shootGames:Vector.<ShootGame> = new Vector.<ShootGame>();
for(i=0;i<20;i++)
{
shootGames.push(new ShootGame());
}
var igames:Vector.<IGame> = //What is the Simplest method to convert ShootGame to IGame Vector
//I am doing like
igames = new Vector.<IGame>();
for(i=0;i < shootGames.length;i++)
{
igames.push(shootGames[i]);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一种更方便的方法可以做到这一点。
请注意,当您使用“Vector.< IGame >(shootgames)”时,您并不是在进行类型转换,而是创建一个新的 Vector 实例并用“shootGames”矢量的内容填充它。
有关更多详细信息,请访问此处。
示例代码:
There is a more convenient way to do that.
Notice that when you use "Vector.< IGame >(shootgames)" you are not making a typecast, instead you are creating a new Vector instance and populating it with the content of the "shootGames" Vector.
For more detailed information, go here.
Sample code: