I didn't run it, but I think you're off a level.  Normally you either
do:

 

var p:Point=box.localToGlobal(new Point(box.width,box.height))



or

 

var p:Point=box.parent.localToGlobal(new
Point(box.x+box.width,box.y+box.height))



because 'local' is local to box or box.parent.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Schmitty
Sent: Wednesday, November 07, 2007 3:31 PM
To: [email protected]
Subject: Re: [flexcoders] ScrollEvent.SCROLL -- what comes after?

 

Am I using/understanding updateComplete correctly? If you run this
sample file, scroll with the mousewheel or the scrollbars it will
trace the scroll and updateComplete values. But if you hit the debug
button it shows things arent the same. Sometimes within a few pixels
othertimes up to 24 pixel difference

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="absolute">
<mx:Script>
<![CDATA[ 
private function update():void {
trace("update green");
var p:Point=box.localToGlobal(new
Point(box.x+box.width,box.y+box.height))
trace(p); // lower right corner of box
canvas.graphics.clear();
canvas.graphics.lineStyle(2,0x00ff00);
canvas.graphics.drawCircle(p.x,p.y,4);
}

private function debug():void {
trace("debug blue");
var p:Point=box.localToGlobal(new
Point(box.x+box.width,box.y+box.height))
trace(p); // lower right corner of box
canvas.graphics.lineStyle(2,0x0000ff);
canvas.graphics.drawCircle(p.x,p.y,4);
}
]]>
</mx:Script>

<mx:Canvas width="500" height="500" updateComplete="update()">

<!-- object we want to track -->
<mx:Canvas id="box" backgroundColor="0xff0000" backgroundAlpha="0.5"
width="200" height="200"/>

<!-- some large object to cause scrollbars -->
<mx:Canvas width="800" height="800" backgroundColor="0xff0000"
backgroundAlpha="0.1"/>

</mx:Canvas>

<mx:Button label="debug" click="debug()" x="550"/>

<!-- just something on top of everything else to see the graphics -->
<mx:Canvas id="canvas"/>

</mx:Application>

On Nov 7, 2007 2:13 PM, Alex Harui <[EMAIL PROTECTED]
<mailto:aharui%40adobe.com> > wrote:
>
>
>
>
>
>
>
>
>
> updateComplete
>
>
>
> ________________________________
>
>
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of Rick Schmitty
> Sent: Wednesday, November 07, 2007 1:42 PM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] ScrollEvent.SCROLL -- what comes after?
>
>
>
>
>
>
>
> From the docs it says "At the time when this event is dispatched, the
> scrollbar has been updated to the new position, but the container's
> child objects have not been shifted to reflect the new scroll
> position." What should I be listening for when the container's child
> object have finished shifting?
>
> Thanks in advance!
>
> 

 

Reply via email to