[备忘] 用Embed生成Image

其实Bitmap对象可以直接加到UIComponent中, 但是相对Image, 它没有transformX之类的属性, 所以不能用Tween.

而Embed生成的是Bitmap, 需要根据Bitmap再生成一个mx.controls.Image对象.

非常简单的问题, 我费了一上午才搞好. 原因在于初始Image对象时没有设置Image对象的高度和宽度, 所以总是显示不出来.

代码:

package com.smithfox.components 
{
	import flash.display.Bitmap;
	import mx.controls.Image;
	import mx.core.UIComponent;
	
	public class Gauge1 extends UIComponent
	{
		[Embed(source="gauge_needle.png")]
		private var ImgClass:Class;
		
		override protected function createChildren():void 
		{
			super.createChildren();
			
			var bitmap:Bitmap = new ImgClass();
			bitmap.smoothing = true;
			
			var image:Image = new Image();
                        
                        //下面两句不加, 图象显示不出来. 浪费了我一上午时间
			image.width = bitmap.width;
			image.height = bitmap.height;

			image.source = bitmap;
			this.addChild(image);
		}
		
	}

}

sdfsdf

smithfox | Tuesday 11 January 2011 at 4:13 pm | | UI        | Used tags: , , , ,

three comments

Louis Vuitton iPhone 6 Plus Cases

After some reports that suggested Force Touch would only come to the display of the larger iPhone this year, new claims from Economic Daily News say that both will get the technology after all. That’s according to a supply chain source, who says that Apple had originally planned to limit Force Touch to the 5.5in iPhone before settling on the final decision to implement it in both.

Louis Vuitton iPhone 6 Plus Cases, (URL) - 04-06-’15 12:44
Cheap Chanel Handbags

This pricing structure allows Chanel, a brand with loyal customers from all over the world, to streamline its business approach without sacrificing its reputation as a luxury brand.

Cheap Chanel Handbags, (URL) - 06-07-’15 18:09
Cheap Yeezy Boost

Presented in black and white, respectively, both sneakers feature an original upper design courtesy of Yamamoto, who furnished each pair in premium goat leather and installed a zip component at the back.

Cheap Yeezy Boost, (URL) - 01-06-’16 14:44
(optional field)
(optional field)
为阻止垃圾广告, 请在提交评论前, 回答一个简单问题(Please answer an simple question)
Remember personal info?
Notify
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.