Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Conditional Statement in Repeater Control

Posted on 2008-06-12
4
Medium Priority
?
1,795 Views
Last Modified: 2012-05-05
Can someone post an example of embedding a conditional statement in a repeater? For example in the sample below if the currentItem is 3 change the button color to blue.



<?xml version="1.0"?>
<!-- Simple example to demonstrate the Repeater class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
 
<mx:Script>
<![CDATA[
 
import mx.controls.Alert;
 
[Bindable]
private var dp:Array = [1, 2, 3, 4, 5, 6, 7, 8, 9]; 
 
]]>
</mx:Script>
 
<mx:Panel title="Repeater Example" width="75%" height="75%" 
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
 
<mx:Text width="100%" color="blue" 
text="Use the Repeater class to create 9 Button controls in a 3 by 3 Tile container."/>
 
<mx:Tile direction="horizontal" borderStyle="inset" 
horizontalGap="10" verticalGap="15"
paddingLeft="10" paddingTop="10" paddingBottom="10" paddingRight="10">
 
<mx:Repeater id="rp" dataProvider="{dp}">
<mx:Button height="49" width="50" id="Button1"
label="{String(rp.currentItem)}"
click="Alert.show(String(event.currentTarget.getRepeaterItem()) + ' pressed')"/>
</mx:Repeater> 
</mx:Tile>
 
</mx:Panel> 
</mx:Application>

Open in new window

0
Comment
Question by:_CODER_
[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
  • 3
4 Comments
 

Author Comment

by:_CODER_
ID: 21777614
bumping up the points... Just need an example please.
0
 

Author Comment

by:_CODER_
ID: 21780848
raising points again... anyone?
0
 
LVL 19

Accepted Solution

by:
Gary Benade earned 2000 total points
ID: 21791447

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
	<mx:Script>
		<![CDATA[
			import mx.core.Repeater;
			
		import mx.controls.Alert;
		 
		[Bindable] private var dp:Array = [1, 2, 3, 4, 5, 6, 7, 8, 9]; 
 
		private function getColor( o:Object):uint
		{
			if( o == '3')
				return 0X0000FF;
			return 0x00FF00;			
		}		 		 
		]]>
	</mx:Script>
 
	<mx:Panel title="Repeater Example" width="75%" height="75%" 
	paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">	 
	<mx:Text width="100%" color="blue" 
	text="Use the Repeater class to create 9 Button controls in a 3 by 3 Tile container."/>	 
	<mx:Tile direction="horizontal" borderStyle="inset" 
	horizontalGap="10" verticalGap="15"
	paddingLeft="10" paddingTop="10" paddingBottom="10" paddingRight="10">	
	<mx:Repeater id="rp" dataProvider="{dp}">
	<mx:Button height="49" width="50" id="Button1" color="{getColor(rp.currentItem)}"
	label="{String(rp.currentItem)}"
	click="Alert.show(String(event.currentTarget.getRepeaterItem()) + ' pressed')"/>
	</mx:Repeater> 
	</mx:Tile>	 
	</mx:Panel> 
</mx:Application>

Open in new window

0
 

Author Closing Comment

by:_CODER_
ID: 31466798
Thank you!
0

Featured Post

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

636 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