Link to home
Start Free TrialLog in
Avatar of CHINOS
CHINOS

asked on

Scale, Align / Position, Full Screen w1th Flash AS3

Hello,

I'm fairly new to Action Script and Flash and I just bought this file to help me align and scale everything in my own website but its code is all in AS2.  

I am trying to convert the following AS2 code to AS3 for my website.  
// Aligns everything to the top left side
Stage.align = "TL";
// Disables the movie from scaling
Stage.scaleMode = "noScale";
// Start values
 
 
back._width = Stage.width;
//Bacground width is equal to Stage width
back._height = Stage.height;
//Bacground heigth is equal to Stage height
info1._x = Stage.width/2;
//info1 _x location is Stage width divided by 2
info1._y = Stage.height/2;
//info1 _y location is Stage height divided by 2
info2._x = Stage.width/2;
//info2 _x location is Stage width divided by 2
info2._y = (info1._y - (info1._height/2))/2;
/*info2 _y location is info1's location minus (info2 height divided by 2) and all 
this divided by 2*/
info3._x = info1._x + (info1._width/2) + 20 + info3._width/2;
//I left this for you to write heir (sort of like practise/homework)
info3._y = info1._y + (info1._height/2) - info3._height/2;
//I left this for you to write heir (sort of like practise/homework)
info4._y = Stage.height - Stage.height/3;
//info4 _y location is Stage height - 1/3 of stage height
/*The reason the is NO info4 _x location is because we have put info4 10px from the 
edge, and since we aligned this all to Top LEFT it does not need a code */
 
 
// End of Start values
 
 
// Listens to if the browser if resized
sizeListener = new Object();
sizeListener.onResize = function() {
/* Code that will RUN when the browser is resized (basically just copy the 
code above)*/
 
 
back._width = Stage.width;
back._height = Stage.height;
info1._x = Stage.width/2;
info1._y = Stage.height/2;
info2._x = Stage.width/2;
info2._y = (info1._y - (info1._height/2))/2;
info3._x = info1._x + (info1._width/2) + 20 + info3._width/2;
info3._y = info1._y + (info1._height/2) - info3._height/2;
info4._y = Stage.height - Stage.height/3;
 
 
};
Stage.addListener(sizeListener);
// End of code

Open in new window

Avatar of Eaddy Barnes
Eaddy Barnes
Flag of United States of America image

try it this way.


GE

// Aligns everything to the top left side
//Stage.align = "TL";
this.stage.align = StageAlign.TOP_LEFT;
// Disables the movie from scaling
//Stage.scaleMode = "noScale";
this.stage.scaleMode = StageScaleMode.NO_SCALE;
// Start values
 
 
back.width = stage.stageWidth;
//Bacground width is equal to Stage width
back.height = stage.stageHeight;
//Bacground heigth is equal to Stage height
info1.x = stage.stageWidth/2;
//info1 _x location is Stage width divided by 2
info1.y = stage.stageHeight/2;
//info1 _y location is Stage height divided by 2
info2.x = stage.stageWidth/2;
//info2 _x location is Stage width divided by 2
info2.y = (info1.y - (info1.height/2))/2;
/*info2 _y location is info1's location minus (info2 height divided by 2) and all 
this divided by 2*/
info3.x = info1.x + (info1.width/2) + 20 + info3.width/2;
//I left this for you to write heir (sort of like practise/homework)
info3.y = info1.y + (info1.height/2) - info3.height/2;
//I left this for you to write heir (sort of like practise/homework)
info4.y = stage.stageHeight - stage.stageHeight/3;
//info4 _y location is Stage height - 1/3 of stage height
/*The reason the is NO info4 _x location is because we have put info4 10px from the 
edge, and since we aligned this all to Top LEFT it does not need a code */
 
 
// End of Start values
 
stage.addEventListener(Event.RESIZE, resizeStageHandler);
function resizeStageHandler(event:Event):void {
 
 
	// Listens to if the browser if resized
 
	/* Code that will RUN when the browser is resized (basically just copy the 
	code above)*/
 
 
	back.width = stage.width;
	back.height = stage.height;
	info1.x = stage.width/2;
	info1.y = stage.height/2;
	info2.x = stage.width/2;
	info2.y = (info1.y - (info1.height/2))/2;
	info3.x = info1.x + (info1.width/2) + 20 + info3.width/2;
	info3.y = info1.y + (info1.height/2) - info3.height/2;
	info4.y = stage.stageHeight - stage.stageHeight/3;
 
 
}
 
// End of code

Open in new window

Avatar of CHINOS
CHINOS

ASKER

Ok,

While this code did run in AS3 it didn't help me get the effect I'm looking for.  

This is what the code did in AS2
http://www.flashden.net/files/11492/preview.swf

I am trying to achieve the same effect in AS3.  This is what it looks like with the converted code above
http://www.docaroundtheclock.org/timtab/as3test/sa.html

the box on the left is info4
the box on the right is info3
the box on the top is info 2
the box in the middle is info1
and the background is a movie clip called 'back'

If you like I can post/email the file but I purchased it so I'm not sure if I should post the file here.  
change this data on line 35

stage.addEventListener(Event.RESIZE, resizeStageHandler);

to this

this.stage.addEventListener(Event.RESIZE, resizeStageHandler);

GE

speraspearpro@yahoo.com
if it does not work so i can have a look at it.

Avatar of CHINOS

ASKER

Ok, I'll email it to you right away, that didn't work.

Thanks so much for your help!!
ASKER CERTIFIED SOLUTION
Avatar of Eaddy Barnes
Eaddy Barnes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that should work
Avatar of CHINOS

ASKER

Thank you soooo much!!!  I love it!