[Flashcoders] using scrollRect and the width / height properties in AS3 F9 - weirdness
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(0x99,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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] using scrollRect and the width / height properties in AS3 F9 - weirdness
I don't get your problem. What is this code about? It has no scrollbar??!! If you want to refresh the stage faster (using a timer) just add t.updateAfterEvent(); On Tue, Apr 1, 2008 at 8:26 PM, John Axel Eriksson [EMAIL PROTECTED] wrote: 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(0x99,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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Pedro D.K. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] using scrollRect and the width / height properties in AS3 F9 - weirdness
This code is about the width and height properties not getting changed until some time in the future (perhaps one frame ahead or a few ms ahead) when setting a scrollRect. This causes all kinds of problems. The code was very very simple, just to show that the values are not immediately changed when setting a scrollRect... I would like to know why that is and what possible benefits there could be? The code only shows that setting a scrollRect does NOT immediately change a DisplayObject's width and height props. /John 2008/4/1, Pedro Kostelec [EMAIL PROTECTED]: I don't get your problem. What is this code about? It has no scrollbar??!! If you want to refresh the stage faster (using a timer) just add t.updateAfterEvent(); On Tue, Apr 1, 2008 at 8:26 PM, John Axel Eriksson [EMAIL PROTECTED] wrote: 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(0x99,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 Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Pedro D.K. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders