Accessing data from a List item on mouse over

July 30, 2008 at 5:37 pm (Flex) (, )

Below is a short example in Flex on how to access data from a list item on mouse over. I’m using the rowIndex property of itemRollOver event to access the index at which the mouse is currently positioned.

<?xml version=”1.0″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>

	<mx:Script>
		<![CDATA[
		    import mx.events.ListEvent;

		    var oceans:Array = ["Pacific", "Atlantic", "Indian", "Artic", "Southern"];

		    public function displayItem(event:ListEvent):void {
		    displayTxt.text = displayList.dataProvider[event.rowIndex];
		    }
		]]>
	</mx:Script>

	<mx:List id="displayList"
		dataProvider="{oceans}"
		itemRollOver="displayItem(event)" />

	<mx:TextArea id="displayTxt"/>

</mx:Application>

Permalink 1 Comment

Commenting code in Flex Builder

July 25, 2008 at 12:39 pm (Flex) (, )

Flex Builder provides useful keyboboard shortcuts to comment code. Below are the different ways you can do it.

ActionScript(AS) Code: To toggle

  • Single Line Comment (// Lorem Ipsum)

Select single / multiple lines of code and hit Control+/ (Windows) or Command+/ (Mac OS).

  • Multiple Lines Comment (/* Lorem Ipsum */)

Select single / multiple lines of code and hit Control+Shift+C (Windows) or Command+Shift+C (Mac OS).

MXML Code: To add

  • XML Comment (<!– Lorem Ipsum –> )

Select single / multiple lines of code and hit Control+Shift+C (Windows) or Command+Shift+C (Mac OS).

  • CDATA Block (<![CDATA[
    Lorem Ipsum
    ]]>
    )

Select single / multiple lines of code and hit Control+Shift+D (Windows) or Command+Shift+D (Mac OS).

Permalink Leave a Comment