?
Solved

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

Posted on 2011-02-26
3
Medium Priority
?
833 Views
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"
      playerList.adobject(s)
 }
0
Comment
Question by:yahoolane
[X]
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
3 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 34989971
Try this:
protected function button1_clickHandler(event:MouseEvent):void
{
     var s: String = "Player 1";
     playerList.addItem({label:s});
}

Open in new window


Warm Regards
Deepanjan Das
0
 
LVL 1

Author Comment

by:yahoolane
ID: 34990075
Deep

No addItem for S:List

I am using Flex 4

Lane

0
 
LVL 17

Accepted Solution

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

Open in new window



Warm Regards
Deepanjan Das
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

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…
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 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