Hi All,
In mxml,the code is
<mx:Canvas id="FoodCanvas" top="100" width="100%" height="100%"
horizontalCenter="0" visible="false" includeInLayout="false"
verticalScrollPolicy="off">
<mx:VBox left="100" right="50" id="foodmenulist">
<mx:HBox>
<mx:Text id="lblfoodcat" width="50" height="30" selectable="false"
color="#66ffff" fontSize="16"
useHandCursor="true" buttonMode="true" />
<mx:Text id="lblfood" width="200" height="30"
text="{data.foodname}" color="#66ffff" click="lbldet_click(event)"
selectable="false"
useHandCursor="true" mouseChildren="false" buttonMode="true"
/>
<mx:Text id="lbldesc" width="375" height="30"
text=" {data.des}" selectable="false" color="#66ffff"
click="lbldet_click(event)" useHandCursor="true" mouseChildren="false"
buttonMode="true"/>
<mx:Text id="lblprice" width="75" selectable="false"
text="{data.price}" color="#66ffff" click="lbldet_click(event)"
useHandCursor="true" mouseChildren="false"
buttonMode="true"/>
<mx:Spacer width="100%" />
<mx:Button height="26" width="28" click="lblfood_click(event)"
icon="@Embed('assets/wine.png')"
left="10" buttonMode="true" useHandCursor="true"/>
</mx:HBox>
</mx:Repeater>
</mx:VBox>
<!--
===================================================
Button Bar for Page Navigation
===================================================
-->
<mx:ToggleButtonBar id="pageNav" bottom="25" right="100"
itemClick="navigatePage(event)" dataProvider="{nav}"/>
<!--
===================================================
VBox Shows the Wines based on Food Menu Selected.
Clicking on a Wine will Show the Details of Wine.
Clicking on the Back Button will show the Food Menu Again.
===================================================
-->
<mx:VBox id="foodmenuSublistNames" left="200" top="150"
visible="false" width="300" height="300">
<mx:Text text="Wines Associated for this Food " color="#FFFFFF"
selectable="false"/>
<mx:Repeater id="rep1">
<mx:Label id="lblfoodlist" width="100%"
useHandCursor="true" mouseChildren="false"
buttonMode="true"
left="10" text="{rep1.currentItem.txtwn}"
click="lblwine_click(event)"/>
</mx:Repeater>
<mx:ControlBar horizontalAlign="center" width="100%">
<mx:Button label="Back to Menu" click="btnFodBackClick()"
icon="@Embed('assets/wine.png')"
buttonDown="true" useHandCursor="true "/>
</mx:ControlBar>
</mx:VBox>
<!--
===================================================
Panel Popup is displayed when the user clicks on
a either Food Name , Description , Price.
Clicking on the Popup will disable it.
===================================================
-->
<mx:Panel id="foodPop" includeInLayout="false" visible="false"
x="300" y="200"
showEffect="bounce" horizontalAlign="left" verticalAlign="top"
color="#FFFFFF" backgroundColor="#000000"
horizontalScrollPolicy="off"
verticalScrollPolicy="off" click="foodPop.visible=false;">
<mx:Text id="txtfood" width="300" selectable="false"
includeInLayout="false" visible="false" color="#FFFFFF"/>
</mx:Panel>
</mx:Canvas>
for this in actionscript,
private function createMenu(arrfoodmenu:ArrayCollection):void
{
// menu = new ArrayCollection();
for each(var foodItem:Object in arrfoodmenu )
{
var index:int =
parseInt(String(foodItem.foodcat).substring(3,String(foodItem.foodcat).length));
addMenuItem(index - 1,foodItem);
}
}
private function addMenuItem(index:int,item:Object):void
{
if(index > foodData.length - 1 )
{
var obj:Object = new Object();
obj.label = "Category " + (index + 1
).toString();
var children:Array = new Array();
obj.children = children;
children.push(item);
foodData.addItem(obj);
}
else
{
(foodData.getItemAt(index).children as
Array).push(item);
}
}
var currentSelectedPage:Number =0;
private function navigatePage(event:ItemClickEvent):void
{
foodmenuSublistNames.visible=false;
foodmenulist.visible=true;
foodPop.visible=false;
refreshDataProvider(event.item.data);
currentSelectedPage = event.index;
var lb:String = event.item.label.toString();
if( lb.indexOf("<") > -1 || lb.indexOf(">") > -1 )
{
createNavBar(Math.ceil(arrfoodmenu.length/pageSize),event.item.data);
if( event.item.data == 0 )
{
pageNav.selectedIndex = 0;
}
else
{
pageNav.selectedIndex = 2;
}
}
}
private function refreshDataProvider(start:uint):void
{
foodData = new ArrayCollection( arrfoodmenu.source.slice((start
* pageSize),(start * pageSize) + pageSize) );
}
var foodNameIndex:int = -1;
private function lblfood_click(ev:MouseEvent):void
{
//Alert.show(arrfoodmenu[0].Photo[0].itemURL.toString());
//Alert.show(arrfoodmenu.Photo.itemURL.toString());
//Alert.show(ev.currentTarget.repeaterIndex.toString());
foodNameIndex = ev.currentTarget.repeaterIndex;
//Alert.show(i.toString());
foodmenulist.visible = false;
foodPop.visible=false;
foodmenuSublistNames.visible = true;
pageNav.visible = true;
rep1.dataProvider =
arrfoodmenu[((currentSelectedPage)*pageSize)+foodNameIndex].Photo;
}
private var popupWindow:TitleWindow;
private function lbldet_click(event:Event):void
{
PopUpManager.removePopUp(popupWindow);
popupWindow = TitleWindow(PopUpManager.createPopUp(this,
PopupWindow2, false));
var str:String = new String;
str = "Food Name : " +
lblfood[event.currentTarget.repeaterIndex].text+'\n'+
"Description : " +
lbldesc[event.currentTarget.repeaterIndex].text +'\n'+
"Price : " +
lblprice[event.currentTarget.repeaterIndex].text;
//PopUpManager.createPopUp(this,PopupWindow2,true);
popupWindow.width = 350;
popupWindow.height = 350;
popupWindow.data = str;
}
/* private function lbldet_click(ev:MouseEvent):void
{
foodPop.width=0;
foodPop.height=0;
txtfood.text='';
//var i:int = ev.currentTarget.repeaterIndex;
//Alert.show(ev.currentTarget.text);
//Alert.show(ev.currentTarget.toString());
var str:String = new String;
str = "Food Name : " +
lblfood[ev.currentTarget.repeaterIndex].text+'\n'+
"Description : " +
lbldesc[ev.currentTarget.repeaterIndex].text +'\n'+
"Price : " +
lblprice[ev.currentTarget.repeaterIndex].text;
txtfood.text=str;
foodPop.width=txtfood.width+50;
foodPop.height=txtfood.height+50;
//foodPop.maxHeight=400;
foodPop.visible=true;
txtfood.visible=true;
//Alert.show(str);
} */
private function lblwine_click(ev:MouseEvent):void
{
backFlag=0;
//Alert.show(ev.currentTarget.toString());
//Alert.show(ev.target.toString());
var photoNameIndex:int = ev.currentTarget.repeaterIndex;
candesc.visible = true;
FoodCanvas.visible = false;
carousel.currentSelectedImgGallery =
arrfoodmenu[foodNameIndex].Photo;
carousel.currentSelectedImgGalleryIndex = photoNameIndex;
descimg.source =
arrfoodmenu[foodNameIndex].Photo[photoNameIndex].itemURL;
//txtHistory.text =
arrfoodmenu[foodNameIndex].Photo[photoNameIndex].txthis;
}
private function btnFodBackClick():void
{
foodmenulist.visible = true;
foodmenuSublistNames.visible = false;
pageNav.visible = true;
}
The question is-------------
what shud i give in place of ev.currentTarget.repeaterIndex(previously it
was repeater,thats why it was given like this) to get the
foodname,desc,price in a popup window when i click on Text(which has a
link).
pls modify the code accordingly.
iam not getting data(foodname,desc,price) when i click on text link(for ex
when i click on foodname--->i shud get foodname,desc,price
" desc -----> "
like that.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---