Hi.
I'm building a simple scrollbar and a scrollcontent class. I'm using
these in dialogs among other things.
These dialogs draw a frame around their content based on the contents
width and height + a margin (to
describe it simply). I've not had any problems with this until I
started using my scroll classes and, to be more
precise, using scrollRects.
What I've found out is that when a scrollRect is set on a
DisplayObject, the width and height properties on that
DisplayObject do not reflect the scrollRects values until some time in
the future (perhaps next frame) - I've tested
using a timer which traces out the width and height values at
different times.
My problem is that this messes up the whole displayList hierarchy and
the only way to get my dialogs to draw right
is to set some arbitrary timer to fire an event which updates the
dialog and spefically the frame around the content at
some time in the future (50-100 ms seems to work, but perhaps a
shorter period could work as well). This is completely
INSANE in my opinion and it doesn't even fix all problems for me.
Why do scrollRects work like that? I can't see ANY benefit to it, only
trouble. Could anyone help out or explain why this
works the way it does?
Try it yourselves:
import flash.display.*;
import flash.geom.*;
import flash.events.TimerEvent;
import flash.utils.Timer;
var sp1:Sprite=new Sprite();
sp1.graphics.beginFill(0x992222,1.0);
sp1.graphics.drawRect(0,0,100,100);
var sp2:Sprite=new Sprite();
sp2.scrollRect=new Rectangle(0,0,20,20);
sp2.addChild(sp1);
addChild(sp2);
function traceValues(te:TimerEvent=null){
trace('container width: '+sp2.width);
trace('child width: '+sp1.width);
}
traceValues();
var t:Timer=new Timer(100, 1);
t.addEventListener(TimerEvent.TIMER, traceValues);
t.start();
stop();
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders