Flex 4 S:List how to add text items with code

Posted on 2011-02-26
Last Modified: 2012-05-11
<s:List id="playerList" x="675" y="20" width="44" height="206" ></s:List>

I want to add List of the Players in my game in code.

something like I
protected function button1_clickHandler(event:MouseEvent):void
          var s: String = "Player 1"
Question by:yahoolane
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 17

Expert Comment

ID: 34989971
Try this:
protected function button1_clickHandler(event:MouseEvent):void
     var s: String = "Player 1";

Open in new window

Warm Regards
Deepanjan Das

Author Comment

ID: 34990075

No addItem for S:List

I am using Flex 4


LVL 17

Accepted Solution

deepanjandas earned 180 total points
ID: 34990134
Sorry Lane,
I just missed out. Try this:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="" 
			   xmlns:mx="library://" minWidth="955" minHeight="600">
		<!-- Place non-visual elements (e.g., services, value objects) here -->
			import mx.collections.ArrayCollection;
			private var playersList:ArrayCollection = new ArrayCollection();
			private function button1_clickHandler(event:MouseEvent):void
				var s: String = "Player 1";
		<s:Button click="button1_clickHandler(event);" label="ADD"/>
		<s:List id="playerList" x="100" y="100" dataProvider="{playersList}" width="100" height="206" ></s:List>

Open in new window

Warm Regards
Deepanjan Das

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Refresh Image 2 30 956
Transfer of mobile action script package to mobile mxml code 9 433
Flash AS3 & random animation 7 859
Custom Component 1 262
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question