Centering Dynamically Drawn Progress Bar on Stage


hi,

 

i trying add progress bar linked timer countup 60 seconds (for elearning lesson). found progress bar sample in as3 (http://ammarz.org/stuff/timedprogressbar.zip) , adapt larger stage (1024 x 768).

 

since project deployed air on android devices, center progress bar on stage. have tried many variations of

 

xyzprogressbar.x = stage.width/2-progressbar.width/2

xyzprogressbar.y = stage.height/2-progressbar.height/2

 

with no success.

 

the following based on above sample as3 hard codes progress bar center stage 1024 x 768 stage:

 

var dimentions:rectangle = new rectangle(362,374,300,20);

drawprogressbar(_drawingcanvas.graphics,dimentions,5,0,0x990000,0xff9900,0x000000);

 

but doesn't solve problem of centering progress bar resized playback on different device screens.

 

can take (adapted sample fla: http://elearningprojects.com/progressbar.zip), suggest way center bar in as3 (without hard coding specific x=362,y=374 dimensions above)?

 

thank help.

 

regards,

the stage dimensional properties stage.stagewidth , stage.stageheight.



More discussions in ActionScript 3


adobe

Comments