views:

3129

answers:

3
+3  A: 

You wouldn't have this problem if instead of centering the zoomable canvas, you'd show it at coords in the top left part of its parent.

Alternatively you could calculate the needed coordinates, based on the size of its parent, and not let them drop below 0.

Here's code that will help:

private function calculateCoordinates() : void
{
    var x : Number = (canvas.width - layout_cnv.width) / 2;
    x = x < 0 ? 0 : x;
    var y : Number = (canvas.height - layout_cnv.height) / 2;
    y = y < 0 ? 0 : y;
    layout_cnv.move(x, y);
}

All you have to do is add this method to your application and

this.callLater(calculateCoordinates);

at the end of your changeZoom and adjustDefaultZoom methods. Also remove align properties from layout_cnv.

bug-a-lot
WOW thats brilliant !!Thanks a lot :-)It really works..i was not getting the idea how to restrict the layout canvas to move in the negative part of the main canvas and now i am able to do it..!!Its really a wonderful.Cheers !!!
Piyush Giri
Im currently using a zoom effect with duration=0, originX=0 and originY=0. Then I can scroll to the left and top no problem
Brian Bishop
A: 

Took a while to figure this one out. Seems that since you are using verticalCenter and horizontal center the canvas is being drawn outside of the viewable area. When running right-click and select 'show redraw regions' then you can clearly see that the canvas is outside of the area.

Once you remove the verticalCenter and horizontal center it seemed to be working (seeing all of the canvas while scrolling.)

On another note I don't see why you want two canvas in the same panel with nothing between them. Maybe this was just for your example.

Good luck

AndrewB
Thanks for the help Andrew but Since i was required to zoom and restrict the layout canvas to the center of the main canvas so it was done like that, now i am able to do it.You can refer the solution showed up just above by "Bug a lot"..Its really a helpful solution.Thanks
Piyush Giri
A: 

//Declare a variable [Bindable] public var myborderColor: ColorPicker = new ColorPicker();

private function init():void { myborderColor:.selectedColor = Color.WHITE ;

… …. in other function change the color myborderColor:.selectedColor = Color.RED ;

… mx:TextInput id=”myText” backgroundColor=”{numcasoborderColor.selectedColor}” …

Reiner