Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-23-2009, 07:13 PM   #1
djeyewater
Registered User
 
Join Date: May 2009
Posts: 10
Default How to fire an event when List selection changes?

I have a list and when an item in the list is selected, I need to fire a function.

At the moment I have a list like this:
Code:
<mx:List id="WebsitesUsed"
	dataProvider="[]"
	height="100"
	width="300"
	allowMultipleSelection="false"
	dragEnabled="true"
	dropEnabled="true"
	dragMoveEnabled="true"
 />
(The dataProvider gets filled by the user)

I've attached an event listener to the list like so:
ActionScript Code:
WebsitesUsed.addEventListener(ListEvent.ITEM_FOCUS_IN, showWebsitesImageURL);

And then at the moment the function that I want to fire just looks like this:
ActionScript Code:
private function showWebsitesImageURL(event:ListEvent):void {     try{         Alert.show(WebsitesUsed.selectedItems[0].label);     }     catch(e:Error)     {Alert.show(e.message);} }

But I don't get an alert when selecting the list items. It worked when I listened for a ListEvent.ITEM_CLICK instead of ListEvent.ITEM_FOCUS_IN, but the ListEvent.ITEM_CLICK doesn't work for when changing the list selection with the keyboard. I also want to do the same thing for any ListEvent.ITEM_FOCUS_OUT events on the list (so I can access the previously selected item).

Can anyone help me with this?

Thanks

Dave
djeyewater is offline   Reply With Quote
Old 05-25-2009, 11:47 AM   #2
djeyewater
Registered User
 
Join Date: May 2009
Posts: 10
Default

I haven't worked out how to use ListEvent.ITEM_FOCUS_IN or ListEvent.ITEM_FOCUS_OUT, but for my purposes ListEvent.CHANGE will just about work.

When I was originally googling for ListEvent, the page that came up was the Flex 2 reference, which doesn't include the ListEvent.CHANGE event, which is why I didn't think of using it.

Dave
djeyewater is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a Display list reparenting event? frank grimes ActionScript 2.0 1 10-27-2007 09:23 AM
flvplayback does not fire complete event, sometimes tapic Components 2 10-16-2007 10:50 AM
List Selection Box Kallisto ActionScript 1.0 (and below) 2 10-13-2001 12:13 AM
Event handling with Listeners - learning from Java robertpenner ActionScript 1.0 (and below) 2 08-08-2001 11:36 PM


All times are GMT. The time now is 09:19 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.