我们知道在Flex项目中,嵌入外部图片,可以使用
- [Embed("tt.png",scaleGridTop="20", scaleGridBottom="40", scaleGridLeft="20", scaleGridRight="40")]
- [Embed("tt.png")]
- public static var Img:Class ;
- public function ttt(){
- stage.scaleMode="noScale";
- var obj:DisplayObject = new Img() as DisplayObject ;
- obj.width=obj.height=300;
- trace( obj is Bitmap);
- }
但是如果加上scaleGridTop的话,就会出错,因为它现在已经成了Sprite,而不是Bitmap了。
- [Embed("tt.png",scaleGridTop="20", scaleGridBottom="40", scaleGridLeft="20", scaleGridRight="40")]
- public var Img:Class ;
-
- public function ttt()
- {
- stage.scaleMode="noScale";
-
- var obj:DisplayObject = new Img() as DisplayObject;
- obj.width=obj.height=300;
- trace( obj is Bitmap , obj is Sprite);
- }
理解Flex项目中Embed参数对Bitmap与Sprite的影响

本文深入探讨了在Flex项目中使用Embed参数时,如何正确区分并应用Bitmap与Sprite对象,通过实例代码揭示了在加入特定参数后,对象类型从Bitmap转变为Sprite的原理与影响。
228

被折叠的 条评论
为什么被折叠?



