April 1st, 2007, 06:26 AM
Positioning Buttons Always At The Bottom Of Stage
I have a group of 6 buttons which on my stage sit in the center and are 20 pixels from the bottom, I am trying to create a bit of a liquid layout, and the browser is going to be able to resized by the user. I want always for the buttons to stay at the bottom in the center of the browser 20 pixels from the bottom no matter wether it is resized too... any ideas?
April 2nd, 2007, 07:25 AM
button1._y = (Stage.height - 20) - (button1._height/2);
:: My blip.fm tunes :: Web Design Feeds :: Web Dev Feeds :: CheatSheets :: PHP :: MySQL :: 13 Moon FB App.
"All matter is merely energy condensed to a slow vibration. We are all one consciousness experiencing itself - subjectively. There is no such thing as death, life is only a dream. We are the imaginations of ourselves."
- Bill Hicks
"Truth is hidden in the subtle nature of the heart of everything, although it is invisible. One cannot see it from inside and neither from the surface. One can only live and experience it."
- Heart Sutra
April 3rd, 2007, 02:47 PM
Just so you know, "Stage.whatever" is often problematic if you use it within the first couple frames of the movie. The movie needs a little time to "sense" its own dimensions I guess.
April 3rd, 2007, 03:28 PM
that's why you would use the stages onResize event handler:
Now whenever the Stage is resized that function will get called and the buttons will be repositioned. One thing to note is that in IE the function only gets called when the browser resizing has finished i.e. once you've released the mouse. In FF it gets constantly called as the browser is resized.
// keyframe 1 of _root
Stage.scaleMode = "noScale";
// The following can go anywhere i.e. doesn't have to be in _root
button1._y = (Stage.height - 20) - (button1._height * 0.5);
// I always just call it once at the start to ensure everything gets positioned correctly initially
Quis custodiet ipsos custodes?