Call: (209) 560-6611

How to make your flash as3 game app scale in all devices

Date: November 6, 2014 Author: ang Category: Tutorials Tags: , , , , , , Comments: 0

Here is a class that scales to fit all devices. In the 'resizeHandler' method, you can use 'stage.stageWidth' or 'stage.stageHeight' to calculate proper scaling according to the device screen size.

 Javascript |  copy code |? 
01
package  {
02
 
03
import flash.display.MovieClip;
04
import flash.events.Event;
05
import flash.display.StageAlign; //for air android resizing
06
import flash.display.StageScaleMode; //for air android resizing
07
import flash.system.Capabilities; //used to get screen dimensions
08
 
09
public class fusion0 extends MovieClip {
10
 
11
	public function fusion0() {
12
		// constructor code
13
		stage.scaleMode = StageScaleMode.NO_SCALE;//for air android resizing
14
		stage.align = StageAlign.TOP_LEFT;//for air android resizing
15
		stage.addEventListener(Event.RESIZE, resizeHandler);//for air android resizing
16
		stage.dispatchEvent(new Event(Event.RESIZE));//for air android resizing
17
		}
18
 
19
function resizeHandler(event:Event=null):void
20
		{
21
		/* scale code ... */
22
 
23
		}
24
 
25
	}
26
 
27
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Before you post, please prove you are sentient.

What is 5 * 3?

Before you post, please prove you are sentient.

What color is the sky on a sunny day?