tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/544-centering-views-allocation-of-stage-controlRobotlegs: Discussion 2018-10-18T16:35:27Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/72911042011-05-17T19:24:43Z2011-05-17T19:24:43ZCentering Views : Allocation of Stage Control<div><p>Hi Thomas,</p>
<p>my advice is to dispatch an event like ON_STAGE_RESIZE or
something like that and pass it to your views through the
mediators. It is a good idea also to create a basic view class,
that contains the logic for centering, and extend it. If you use
this approach you will keep the logic on one place and you can
attach another actions when the stage is resized</p></div>krasimirtag:robotlegs.tenderapp.com,2009-10-18:Comment/72911042011-05-17T19:35:32Z2011-05-17T19:35:32ZCentering Views : Allocation of Stage Control<div><p>I think functionality like this squarely belongs into the
view-layer.<br>
Why don't you implement a generic centering behavior that you can
then<br>
attach to all views that require it? Something along the lines
of</p>
<p>//constructor definition only, the actual implementation
shouldn't be hard to work out:<br>
function CenteringBehavior(target : DisplayObject, targetContainer
:<br>
DisplayObjectContainer);</p>
<p>//applied like this: _centeringBehavior = new
CenteringBehavior(this, stage); //where, of<br>
course, any other container can be substituted for "stage"</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/72911042011-05-17T19:39:22Z2011-05-17T19:39:22ZCentering Views : Allocation of Stage Control<div><p>Yes of course the Views can extend a base Class. Not sure why I
didn't even see that, I forgot totally that in RL my Views are not
by default Subclassing anything but a Display container.</p>
<p>I think I'll go down that route. Not much extra code for each
mediator, just the listener for the ON_STAGE_RESIZE</p>
<p>However that said, is there a case for having a ContextView that
does things to Views, is that a viable alternative in these
cases.</p>
<p>That will conclude my questions for today, thanks for all the
replies</p>
<p>Thomas</p></div>thomas.thorstensson