Groups | Blog | Home
all groups > flash actionscript > october 2007 >

flash actionscript : stageWidth after resize


KinseyFobes
10/17/2007 10:06:32 PM
When I resize the stage during execution stage.stageWidth changes as expected,
but the 0,0 coorinate seems to ove. When I trace out the stage.mouseX or
mouseY coordinates after maximizing the stage I get negative numbers for the
upper left hand corner, and the lower right gives numbers that are too low.
For instance my normal stageWidth is 550, but when I maximize I get 1020, but
the left side of my stage returns a position of -235 and the right side gives
785 (234 + 785 = 1020). Is there a way to reset the base coordinate, or am I
doing something wrong?

Kinsey
Rothrock
10/18/2007 3:02:07 AM
You know I haven't tried this in AS3 (which I gather from stage.stageWidth
instead of Stage.width) and even then I'm no expert on this, but?

Have you gone into your publish settings and change the HTML setting to left
top? Or there might be some way of setting that through the code in AS3?

Again, I'm not really clear on all this, having not yet done it in AS3. Just
some ideas?
clbeech
10/18/2007 4:04:26 AM
Say, I'm not up with AS3 yet either, but it occured to me ... isn't this what
the Stage is suppose to do? From your discription above, it seems as though
the Stage did not 'resize' which is just what it's suppose to do, stay the same
size and become 'placed' in the center of the window? You'd said that trace
the mouse coordinates gives negative values on the left and greater values on
the right than the width of the original Stage ... that's how it should be
right.

It seems like the actual 'size' of the Stage should on be changed when
implementing the onResize method. Not sure but it seems ...

just some thoughts :)
KinseyFobes
10/18/2007 3:01:26 PM
Actually I'm not in html at this point. I'm testing the movie in the Flash
environment and using the Flash Player. The stage DOES resize because the
stageWidth property changes.

The problem is as I move objects around the screen I keep them visible by
limiting their movement to between 0,0 and the stageWidth. the 0,0 point isn't
the top left then all of the other calculations are off and my objects are all
shifted down and to the right, going off of the stage.
clbeech
10/18/2007 3:18:09 PM
Interesting, this must be a AS3 thing. The way I understand it (and I've only
just begun to do my reading) is that the Stage is now treated as a
DisplayObject or something like that, so then it's interesting that it resizes
to the whole visible area, kind of handy really. Maybe you could use an
onResize handler to control the 'Stage' size limiting it the size you want and
centering it with the display area?

Again, just thoughts :P
Rothrock
10/18/2007 3:58:35 PM
I'm pretty sure I've always experienced this in the testing environment and/or
if you plan on publishing to a projector.

Yes the stage does resize, clbeech, the onResize handler just allows you to
add code that responds to the event. The event happens and the handler responds.

KinseyFobes, if the final target for this is a website then you will have to
test in that environment to make sure it is working. if you plan on directly
using a swf or projector you will have to do some math.
GWD
10/18/2007 4:14:03 PM
Whenever I've done stuff in as2 I think I used
Stage.align="TL" and
Stage.scaleMode="noScale"

These properties still appear to exist for the stage from a quick glance at
the as3 docs.
I've never experienced exactly what you describe, but I'd perhaps the "TL"
part might be important.


clbeech
10/18/2007 4:32:00 PM
very good, and it's not that I don't buy into that RR, but this does seem to go
to the OPs point. It seems odd that items fixed to a position relative tot he
original Stage size as set in the Authoring tool, do not change position
relative to the 'new' stage size, and mouse coordinates do in fact show
negative and positive values that are related to the size of the original stage.

So how can it be that the actual 'size' of the Stage changes, yet items
positioned to it remain. is there something similar to what's going on in AS3,
happening in the background of AS2?

Here is a quick example of what I'm saying here, that things remain positioned
correctly in relation to the 'original' Stage size and values, but when
maximized change thier 'real' cooridnates, but don't register the new system to
the mouse.

I dunno if that makes sense, here's a test file:
http://www.beechstudios.com/stageTest.zip
KinseyFobes
10/18/2007 5:16:25 PM
GWD was VERY close! I had already been using
stage.scaleMode=StageScaleMode.NO_SCALE; but I hadn't used the stage.align
property. After including stage.align=StageAlign.TOP_LEFT; everything resolved
itself.


Thanks for everyones responses

GWD
10/18/2007 5:27:48 PM
Good to hear.
Actually
StageAlign.TOP_LEFT == "TL" and StageScaleMode.NO_SCALE=="noScale"
KinseyFobes
10/18/2007 5:33:55 PM
clbeech
10/18/2007 6:10:28 PM
AddThis Social Bookmark Button