Actionscript 3 AS3 Flex将图像嵌入到Sprite
以下两者之间的区别是什么:Actionscript 3 AS3 Flex将图像嵌入到Sprite,actionscript-3,flash,apache-flex,actionscript,Actionscript 3,Flash,Apache Flex,Actionscript,以下两者之间的区别是什么: [Embed(source = "../assets/graphic.png")] const GRAPHIC:Class; var graphic:Bitmap = new GRAPHIC(); addChild(graphic); 以及: 我应该使用哪一个?为什么?第一个是一个变量指针,指向GRAPHIC类的实例化副本。第二个是隐式声明 如果需要对对象执行进一步的操作,可以使用指针。例如 graphic.name = "myGraphic"; graphic.a
[Embed(source = "../assets/graphic.png")]
const GRAPHIC:Class;
var graphic:Bitmap = new GRAPHIC();
addChild(graphic);
以及:
我应该使用哪一个?为什么?第一个是一个变量指针,指向
GRAPHIC
类的实例化副本。第二个是隐式声明
如果需要对对象执行进一步的操作,可以使用指针。例如
graphic.name = "myGraphic";
graphic.alpha = 0.5;
someFunction(graphic);
var settings:Object = {
"x":20,
"alpha":0.5
}
setProperties(foo, settings);
// Instead, you can do it in one line, with an implicit declaration.
setProperties(foo, {"x":20, "alpha":0.5});
设置属性并将其作为参数传递给其他函数是指针的好例子。如果不需要这样做,可以使用隐式声明。你可以在其他有意义的地方这样做。例如
graphic.name = "myGraphic";
graphic.alpha = 0.5;
someFunction(graphic);
var settings:Object = {
"x":20,
"alpha":0.5
}
setProperties(foo, settings);
// Instead, you can do it in one line, with an implicit declaration.
setProperties(foo, {"x":20, "alpha":0.5});