# AS3 to AS2

**URL:** <https://forum.kirupa.com/t/as3-to-as2/289802>\
**Category:** flash\
**Created:** [June 4, 2009, 9:35pm UTC](https://forum.kirupa.com/t/as3-to-as2/289802 "2009-06-04T21:35:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alphaville](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@alphaville](https://forum.kirupa.com/u/alphaville)\
**Post date:** [June 4, 2009, 9:35pm UTC](https://forum.kirupa.com/t/as3-to-as2/289802/1 "2009-06-04T21:35:53Z")

</div>

I have a very basic knowledge on actionscripting. This is the code (adjusting the background image) i have found in one of the tutorials on net.

Since I am only able to work in AS1, AS2, I hope to have AS2 equilavent of this code.

I will appreciate a lot if it is possible.

Thanks

the code is:

import flash.display.Sprite;  
import flash.display.StageAlign;  
import flash.display.StageScaleMode;  
import flash.events.Event;

stage.scaleMode = StageScaleMode.NO\_SCALE;  
stage.align = StageAlign.TOP\_LEFT;  
stage.addEventListener(Event.RESIZE, resizeHandler);

//function to handle background image resize.  
function setBackground() {  
var reg2 = stage.stageWidth / 2;  
var reg1 = stage.stageHeight / 2;  
bg\_mc.x = reg2;  
bg\_mc.y = reg1;  
bg\_mc.width = stage.stageWidth;  
bg\_mc.height = stage.stageHeight;  
bg\_mc.scaleX \<= bg\_mc.scaleY ? (bg\_mc.scaleX = bg\_mc.scaleY) : (bg\_mc.scaleY = bg\_mc.scaleX);  
base\_mc.width = stage.stageWidth;  
}  
setBackground();  
//set intitial position  
function setPos() {  
message\_mc.x = stage.stageWidth / 2;  
message\_mc.y = stage.stageHeight / 2;  
base\_mc.x=0;  
base\_mc.y=stage.stageHeight-70;  
controls\_mc.x=0;  
controls\_mc.y=stage.stageHeight-70;  
logo\_mc.x=stage.stageWidth-300;  
logo\_mc.y=0;  
}  
setPos();  
//set position when stage resizes  
function resizeHandler(event:Event):void {  
setBackground();  
setPos();
