Are all 10-15 markers visible at one time? If not, you might want to
consider the 'recycle' method that is employed with item renderers.
Either that... or have a single MEGA WONKA sprite where each marker is
drawn at the appropriate location.
Rick Winscot
On Wed, Jul 23, 2008 at 12:42 PM, Alex Harui <[EMAIL PROTECTED]> wrote:
> 10 to 15 shouldn't be a problem. Make sure it is only that many (and you
> didn't create more and stack them on top of the others).
>
>
>
> Are you saying the addEventLIstener calls are affecting the cpu load?
>
>
>
>
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of ibo
> Sent: Wednesday, July 23, 2008 8:05 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] event listeners on Sprites - performance problem
>
>
>
> MIME-Version: 1.0
> Content-Type: multipart/alternative;
> boundary="0-617774704-1216825475=:34053"
>
> --0-617774704-1216825475=:34053
> Content-Type: text/plain; charset=us-ascii
>
> I created a component what I call bookmark bar where there are markers that
> you can click
> to jump/scroll to a particular portion of a list (given the index). Similar
> to Eclipse/Flexbuilder when you have
> errors and there are markers on the right side pane that lets you jump to
> the erroneous line. I am using
> this for a datagrid using Canvas as parent component.
>
> var uiComponent:UIComponent = new UIComponent();
> addChild(uiComponent);
>
> for (var i:int=0; i<_dataProvider.length; i++) {
> var bm:Bookmark = _dataProvider[i] as Bookmark;
>
> sprite = new MySprite(); // extends Sprite. Creates an instance Sprite for
> each marker
> sprite.graphics.lineStyle(3, bm.color, 1, false, LineScaleMode.NORMAL,
> CapsStyle.SQUARE);
> sprite.graphics.moveTo(x, y);
> sprite.graphics.lineTo(x + xOffset, y);
> ...
> sprite.addEventListener(MouseEvent.CLICK, scrollToLine);
> sprite.buttonMode = true;
> ...
> uiComponent.addChild(sprite);
> }
>
> It works as expected but I noticed it is heavy on CPU and affects the
> responsiveness of the
> UI. CPU spikes at 55% to 60% even if I only have a few markers (10 to 15).
> The lag is very noticeable because just hovering the mouse pointer over the
> list,
> the item highlighter, delay in rendering the display is very evident.
> It doesnt happen on my app when I turn it off.
>
> Am I doing this right? any workaround?
>
> Regards,
> Stephen
>
> --0-617774704-1216825475=:34053
> Content-Type: text/html; charset=us-ascii
>
> I created a component what I call bookmark
> bar where there are markers that you can clickto jump/scroll to a
> particular portion of a list (given the index). Similar to
> Eclipse/Flexbuilder when you haveerrors and there are markers on the
> right side pane that lets you jump to the erroneous line. I am using
> this for a datagrid using Canvas as parent
> component.
> var uiComponent:UIComponent = new
> UIComponent(); !
>
> addChild(uiComponent);
> for (var
> i:int=0; i<_dataProvider.length; i++)
> {
> var bm:Bookmark = _dataProvider[i] as
> Bookmark;
>
>
>
> sprite = new MySprite(); // extends Sprite. Creates an instance
> Sprite f! or each marker
>
> sprite.graphics.lineStyle(3, bm.color, 1, false,
> LineScaleMode.NORMAL, CapsStyle.SQUARE);
>
>
>
> sprite.graphics.moveTo(x, y);
>
> sprite.graphics.lineTo(x + xOffset,
> y);
> ...
>
>
>
> sprite.addEventListener(MouseEvent.CLICK, scrollToLine); gt;
> sprite.buttonMode =
> true;
> ...
>
> uiComponent.addChild(sprite);
>
>
> }It
> works as expected but I noticed it is heavy on CPU and affects the
> responsiveness of theUI. CPU spikes at 55% to 60% even if I only have a
> few markers (10 to 15).The lag is very noticeable because just hovering
> the mouse pointer over the list,the item highlighter, delay in rendering
> the display is very evident.It doesnt happen on my app when I turn it
> off.Am I doing this right? any
> workaround?Regards,Stephen
> --0-617774704-1216825475=:34053--
>
>