flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Ent <p...@adobe.com>
Subject Re: R: Improve spark List performance
Date Tue, 03 Sep 2013 13:40:49 GMT
Each time the itemRenderer's data is set, you are wiping out all of the
button in the TileGroup and re-creating them. That's a source of your slow
scrolling performance.

As nice-and-easy as your approach is, it is better to add some more code
complexity and re-use those buttons.

Here's one example: you could, for each itemRenderer, have a cache of
previously created buttons, which would be empty the first time the
itemRenderer was used. If you need 10 buttons but have less than 10 (e.g.,
0 the first time), "use" the buttons (explained below) you have previously
created and create the remaining, being sure to also put references to
them into your cache.

If you have more buttons in your cache than you need, "use" the amount you
need and "deactivate" the ones you don't. That is, if you have 20 buttons
in the cache but only need 8, you'll deactivate the remaining 12.

So "use" means to set a button's visible and includeInLayout properties to
true. "Deactivate" means to set a button's visible and includeInLayout
properties to false.

I think an approach like this would have better performance for you. If
you can avoid setting includeInLayout, it will be even better since all
you will be doing is hiding/showing the buttons, but the itemRenederers
might not look right if you also don't remove them from the layout.

Peter Ent
Flex SDK Team
Adobe Systems

On 9/3/13 9:29 AM, "Federico De Maddalena" <f.demaddalena@patente.it>

>Hi Ben
>I'm developing a mobile project, not desktop!
>Images in use are very small.
>Usevirtuallayout is set on true.
>The code is here: 
>	<fx:Script>
>		<![CDATA[
>			import spark.components.Button;
>			import spark.core.ContentCache;
>			import events.SchedaEvent;
>			static public const s_imageCache:ContentCache=new ContentCache();
>			override public function set data(value:Object):void
>			{
>				super.data=value;
>				lezione.text=value.titolo;
>				img.source="img/lez/"+value.lezione+"g.png";
>				schede.removeAllElements();
>				for(var i:int=0; i<value.schede.length; i++)
>				{
>					var button:Button=new Button();
>					button.label=String(i+1);
>					button.id=value.schede[i];
>					button.height=40;
>					button.width=40;
>					button.addEventListener(MouseEvent.CLICK, handleMouseClick);
>					schede.addElement(button);
>				}	
>			}
>			private function handleMouseClick(event:MouseEvent):void
>			{
>				sendEvent(parseInt(event.currentTarget.id));
>			}
>			private function sendEvent(id:int):void
>			{
>				var e:SchedaEvent=new SchedaEvent(SchedaEvent.LOAD_SCHEDA);
>				e.Id=id;
>				this.owner.dispatchEvent(e);
>			}
>		]]>
>	</fx:Script>
>	<s:HGroup width="100%" height="100%" paddingTop="3">
>		<s:VGroup height="100%" width="20%" verticalAlign="top"
>			<s:Image width="80%" height="80%" id="img"
>		</s:VGroup>
>		<s:VGroup height="100%" width="70%">
>			<s:Label width="100%" height="20%" id="lezione"/>
>			<s:TileGroup width="100%" height="80%" id="schede"/>
>		</s:VGroup>
>	</s:HGroup> 
>-----Messaggio originale-----
>Da: Ben Smeets [mailto:ben@okapion.com]
>Inviato: martedì 3 settembre 2013 15.22
>A: users@flex.apache.org
>Oggetto: Re: Improve spark List performance
>How many rows in the list? (i.c.w. useVirtualLayout)
>The setup you mention shouldn't be a problem I think (unless the image
>you talk about is 200MB a pop), but depends on the implementation
>(details). E.g., if the buttons are created every scroll, instead of
>reused, that might be a cause.
>Any code you can share, can help (me at least) to track down the culprit.
>Not a guru here though, so maybe others will know off the top of their
>heads :)
>P.S. We are talking desktop app here right? Mobile is a different beast
>all together (for me).
>On 3 sep. 2013, at 15:16, Federico De Maddalena
><f.demaddalena@patente.it> wrote:
>> Hi! I'm working on a mobile project.
>> I created a spark List, which item renderer is an extension of
>> ItemRenderer. Each of my item renderer contains one spark Image, one
>> Label and a number of small buttons which varies from 3 to 20.
>> Now, scrolling the list is terribly slow. There are ways to improve
>> scroll speed? I spent a lot of time but without success.
>> Regards
>> federico

View raw message