[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 738
  • Last Modified:

auto-scroll a list to the most recently added item

Hi,

I am dynamically populating a List with log messages as they arise.  When the number of messages in the list exceeds the List container's size, a scroll bar appears. This is good.  What is not good is that the scroll bar does not automatically scroll down to show the newest message.  How can I achieve this behavior?

thanks

Kevin
0
caherciveen
Asked:
caherciveen
  • 5
  • 4
1 Solution
 
Jones911Commented:
Show code.
0
 
caherciveenAuthor Commented:
the list:
				<mx:List id="messageList"
					width="100%" 
					height="100%"
					mouseDownEffect="msgGlow"
					itemsChangeEffect="msgGlow"
					dataProvider="{msgListDP}"
					labelField="messageTxt"
					verticalScrollPosition="{maxVerticalScrollPosition}"
				 	themeColor="#BEA4C3" wordWrap="true" alternatingItemColors="[#F6F2F5,#F0EEF3]" editable="false">
					<mx:toolTip>Look here for important connectivity / authentication messages.</mx:toolTip>
                    <mx:itemRenderer>
                        <mx:Component>
                        	<mx:HBox addedEffect="msgGlow" backgroundAlpha=".1">
                        		
                      
                         	<mx:Text text="{data.messageTxt}" fontWeight="bold" alpha="1.0" creationComplete="DoIt()">
                         		<mx:Script>
                         			<![CDATA[
                         				private function DoIt():void
                         				{
											try
											{
												if (data.msgCode == "normMsg")
	            								{
	            									setStyle("color", 0x000000);
	            									setStyle("backgroundColor",0xFFFFFF);
	            								}
	            								else if (data.msgCode == "goodMsg")
	            								{
	            									setStyle("color", 0x00BB00);    
	            									setStyle("backgroundColor",0x33FF33);   									
	            								}
	            								else if (data.msgCode == "errMsg")
	            								{
	            									setStyle("color", 0xBB0000); 
	            									setStyle("backgroundColor",0xFF3333);      									
	            								}
 
	          								}
	          								catch(e:TypeError)
	          								{
	          									trace (e);
	          								}
                         				}
                          				override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void 
                         				{
            								super.updateDisplayList(unscaledWidth, unscaledHeight);
            								DoIt();
       									} 
                         			]]>
                         		</mx:Script>
                         	</mx:Text>      
                         	</mx:HBox>                 		
                        </mx:Component>
                    </mx:itemRenderer>
					
					
				</mx:List>

Open in new window

0
 
caherciveenAuthor Commented:
and how i append a message
msgListDP.push({messageTxt:msg, msgCode:code});

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
caherciveenAuthor Commented:
i figured it out...  I needed to change
       
            verticalScrollPosition="{maxVerticalScrollPosition}"

to

            verticalScrollPosition="{messageList.maxVerticalScrollPosition}"
0
 
zzynxSoftware engineerCommented:
>> i figured it out
Then please close this question by accepting your own solution as answer
0
 
zzynxSoftware engineerCommented:
You probably made a mistake...
0
 
caherciveenAuthor Commented:
Experts-exchange wouldn't let me ask a new question until this one was closed. by accepting my own solution, they were going to leave it open for debate for like 4 more days.  so, basically, to ask another ? quickly, I had to select you as the solution.  
0
 
zzynxSoftware engineerCommented:
>> Experts-exchange wouldn't let me ask a new question until this one was closed
Where did you read that rule?
0
 
caherciveenAuthor Commented:
it some new rule they implemented.   I have not encountered it until recently.  I was very annoyed and so just accepted your solution so I could move on.
0
 
zzynxSoftware engineerCommented:
And by the way could you have a look @ your open question: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Flex/Q_24713223.html ?
I think I provided you a useful answer.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now