flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "rodolpho@essencialcode.com.br" <rodol...@essencialcode.com.br>
Subject Re: MultiDPIBitmapSource multiple use
Date Fri, 26 May 2017 18:23:27 GMT
See if this may help you:

Code:
public class ImageClassManager
{
	public static function getDPI(): void 
	{
		var dpi: Number = Capabilities.screenDPI;
					
		if ((dpi > 0)&&(dpi < 240))
			return 160;

		if ((dpi >= 240)&&(dpi < 320))
			return 240;


		if ((dpi >= 320)&&(dpi < 480))
			return 320;

		if ((dpi >= 480)&&(dpi < 640))
			return 480;

		if (dpi >= 640)
		 return 640;
	}

			
	public static function getImageSource(imageName: String):String 
	{
		var path: String = "";
		
		switch (ImageClassManager.getDPI())
		{
			case 160: path = "assets/images/160/" + imageName;
				break;
			
			case 240: path = "assets/images/240/" + imageName;
				break;
			
			case 320: path = "assets/images/320/" + imageName;
				break;
			
			case 480: path = "assets/images/480/" + imageName;
				break;
			
			case 640: path = "assets/images/480/" + imageName;
				break;
			
			default: 

		}
		return path;
	}
}



And use...

image.source = ImageClassManager.getImageSource("myImage.png");



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/MultiDPIBitmapSource-multiple-use-tp15275p15276.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Mime
View raw message