• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4615
  • Last Modified:

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

0
CHINOS
Asked:
CHINOS
  • 4
  • 3
1 Solution
 
Eaddy BarnesITCommented:
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

0
 
CHINOSAuthor Commented:
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.  
0
 
Eaddy BarnesITCommented:
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.

0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

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

Thanks so much for your help!!
0
 
Eaddy BarnesITCommented:

// 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/2;
//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
 
this.stage.addEventListener(Event.RESIZE, resizeStageHandler);
function resizeStageHandler(event:Event):void {
 trace("working");
 
        // 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.stageWidth;
        back.height = stage.stageHeight;
        info1.x = stage.stageWidth/2;
        info1.y = stage.stageHeight/2;
        info2.x = stage.stageWidth/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

0
 
Eaddy BarnesITCommented:
that should work
0
 
CHINOSAuthor Commented:
Thank you soooo much!!!  I love it!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now