Показать сообщение отдельно
Старый 15.10.2011, 00:13
sstotenkopf вне форума Посмотреть профиль Отправить личное сообщение для sstotenkopf Найти все сообщения от sstotenkopf
  № 1  
Ответить с цитированием
sstotenkopf
 
Аватар для sstotenkopf

Регистрация: Aug 2010
Адрес: Саратов
Сообщений: 185
По умолчанию Не могу обратиться к элементу datagroup

пытаюсь возвратить значение после нажатия на элемент, с помощью e.target.selectedItem.data.id, не работает... может это делается по-другому?

вот код:

test.mxml

Код:
<?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:Script>
		<![CDATA[
			import flash.events.*;
			
			import mx.controls.Alert;
			
			[Bindable]
			
			public var arr:Array = [
				{label:"David", sn:"harisson", id:"784394", on:"1"}, 
				{label:"Collen", sn:"johnson", id:"908364", on:"1"}, 
				{label:"Sharon", sn:"marshal", id:"373467"}, 
				{label:"Ronnie", sn:"cartman", id:"76384"},
				{label:"Sydney", sn:"Bristow", id:"34334", on:"1"}, 
				{label:"Brad", sn:"Shrayer", id:"27683"}, 
				{label:"Fred", sn:"Kennersy", id:"34566"}, 
				{label:"Marc", sn:"Larren", id:"87623", on:"1"}]
			
			protected function clk(e:MouseEvent):void {
				textid = e.target.selectedItem;
			}
				
		]]>
	</fx:Script>
	<fx:Declarations>
		<mx:ArrayCollection id="arrColl" source="{arr}" />
	</fx:Declarations>
	
	<s:Panel x="77" y="55" width="656" height="411" title="Друзья" backgroundColor="#D9FEF8">
		<s:DataGroup dataProvider="{arrColl}"
					 width="634" height="323"
					 clipAndEnableScrolling="false" itemRenderer="components.mir" x="10" y="44" id="boxer" mouseDown="clk(event)">
			<s:filters>
				<s:DropShadowFilter id="myShadow" 
									alpha="1" 
									distance="7"
									angle="40" 
									blurX="11"
									blurY="11"
									color="333333" 
									quality="3" 
									strength="1" 
									/>
			</s:filters>
			<s:layout>
				<s:TileLayout verticalGap="10" horizontalGap="10"
								  useVirtualLayout="true"/>
				
			</s:layout>
		</s:DataGroup>
		<s:TextInput x="10" y="14" id="textid"/>
	</s:Panel>
</s:Application>

component.mir.mxml

Код:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
				xmlns:s="library://ns.adobe.com/flex/spark"
				xmlns:mx="library://ns.adobe.com/flex/mx"
				>
	
	<s:BorderContainer width="150"
					   height="50"
					   borderVisible="false"
					   cornerRadius="5"
					   buttonMode="true"
					   rollOver="onm(event)"
					   rollOut="onm1(event)"
					   id ="box1"
					   >
		<fx:Script>
			<![CDATA[
				import mx.controls.Alert;
				protected function onm(e:MouseEvent):void {
					e.currentTarget.alpha = 0.5;
					
				}
				protected function onm1(e:MouseEvent):void {
					e.currentTarget.alpha = 1;	
				}
				
			]]>
		</fx:Script>
		<mx:Image width="50"
				  height="50"
				  source="http://cs4166.vkontakte.ru/u21222676/e_bad819b0.jpg"/>
		<s:Label fontWeight="bold"
				 text="{data.label}" paddingLeft="60" paddingTop="10"/>
		<s:Label fontWeight="bold" id="sn"
				 text="{data.sn}" paddingLeft="60" paddingTop="25"/>
		<s:BorderContainer width="5" height="5" cornerRadius="20" x="140" y="5" id="onliner" borderVisible="false">		
		</s:BorderContainer>
			
		</s:BorderContainer> 
		
</s:ItemRenderer>