header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
nannu
Points:0
Posts:0
Answered

7/19/2010 1:43:03 AM

Title: popup mananger with setter function


hi all,


i have a footer with 4 links,whenever i click on on any link a popup with a box containing different content should be displayed.

how should i check which link is click and based on that relative box to be displayed


suppose 4 links are white,blue,green and yellow relative box with that color should be displayed


and this should be done using the setter function


plz help with sample code.

thanks



1
Veer
Points: 480
Posts:0
Accepted Answer
7/19/2010 2:21:40 AM



Hi,

Check this sample....
//////////////// Application ////////////////////


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
	
	<mx:Script>
		<![CDATA[
			import mx.managers.PopUpManager;
			import mx.events.FlexEvent;
			
			private function onClick(event:MouseEvent):void
			{
				var boxPopUp:Item = Item(PopUpManager.createPopUp(this,Item,true));
				boxPopUp.height = 400;
				boxPopUp.width = 400;
				// in switch case set your custom data as i set backgroundColor.
				switch(event.currentTarget.id)
				{
					case "lb1":
						boxPopUp.cusColor = "0xFF0000";
						break;
					case "lb2":
						boxPopUp.cusColor = "0x00FF00";
						break;
					case "lb3":
						boxPopUp.cusColor = "0x0000FF";
						break;
					case "lb4":
						boxPopUp.cusColor = "0x000000";
						break;
					default :
						break;
				}
				
				PopUpManager.centerPopUp(boxPopUp);
			}
			
		]]>
	</mx:Script>
	
	<mx:ControlBar>
		<mx:LinkButton label="Red" click="onClick(event)" id="lb1" />
		<mx:LinkButton label="Green" click="onClick(event)" id="lb2" />
		<mx:LinkButton label="Blue" click="onClick(event)" id="lb3" />
		<mx:LinkButton label="Black" click="onClick(event)" id="lb4" />
	</mx:ControlBar>
	
</mx:Application>



///////////////// Item Component /////////////////



<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" cornerRadius="7"
	height="100%" creationComplete="init123()" borderStyle="solid" 
	borderThickness="4" borderColor="0xFFFFFF">

	<mx:Script>
		<![CDATA[
			import mx.managers.PopUpManager;
	 
			private var isInit:Boolean = false;
			private var bgColor:String = "0xFFFFFF";
			
		 	private function init123():void{
		 		if(isInit){
		 			this.setStyle("backgroundColor",bgColor);
					isInit=	false;
				}
			}
			
			public function set cusColor(value:Object):void
			{
				bgColor = value as String;
				isInit=	true;
			}
			
			private function onClose(event:MouseEvent):void
			{
				PopUpManager.removePopUp( this );
			}
	]]>
	
	</mx:Script>
	
	<mx:Button horizontalCenter="0" verticalCenter="0" label="X" click="onClose(event)" />
	
</mx:Canvas>

I hope this may help you. Regards, Virat Patel

2
nannu
Points: 0
Posts:0
7/19/2010 3:39:30 AM



hi virat,


it is working fine, but in the item component 1st component is having the form data with states and other 3 boxes i have different data placed.


i am preparing the footer for a website in which 4 buttons are there faq,about us,contact us and feedback ,on click of each button a pop window should come

here is my code

footer

<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" direction="horizontal" width="100%">
<mx:Script>
	<![CDATA[
		import mx.managers.PopUpManager;
		
		private function handleClick(event:MouseEvent):void{
			var popUp:FeedbackPopup = FeedbackPopup(PopUpManager.createPopUp(this,FeedbackPopup,true));  
			popUp.width = 400;
			popUp.height = 400;
            switch(Label(event.currentTarget).text){
				case "Feedback":
				break;
				
				case "FAQ's":
				break;
				
				case "About Us":
				break;
				
				case "Contact Us":
				break;
			}
			PopUpManager.centerPopUp(popUp);
		}
	]]>
</mx:Script>
	<mx:Box width="50%" height="25" verticalAlign="middle" direction="horizontal">
		<mx:Label text="Feedback" click="handleClick(event)"/>
		<mx:Label text="|"/>
		<mx:Label text="FAQ's" click="handleClick(event)"/>
		<mx:Label text="|"/>
		<mx:Label text="About Us" click="handleClick(event)"/>
		<mx:Label text="|"/>
		<mx:Label text="Contact Us" click="handleClick(event)"/>
	</mx:Box>
</mx:Box>


pop up

<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initComp()">   
	<mx:states>
		<mx:State name="submitState">		
			<mx:SetProperty target="{fbLoggedForm}" name="includeInLayout" value="false"/>
			<mx:SetProperty target="{fbLoggedForm}" name="visible" value="false"/>
			<mx:SetProperty target="{submitMessage}" name="includeInLayout" value="true"/>
			<mx:SetProperty target="{submitMessage}" name="visible" value="true"/>			
		</mx:State>
	</mx:states>
	<mx:Script>
		<![CDATA[
			import mx.managers.PopUpManager;
					
			private function handleCloseClick():void {
	            PopUpManager.removePopUp(this);
	        }
	        
	        private function initComp():void{
	        }
	    ]]>
	</mx:Script>
	<!--feedback-->
		<mx:HBox width="100%" id="titleContainer">
				<mx:Label text="Feedback"/>
				<mx:Label text="Close" click="handleCloseClick()"/>
		</mx:HBox>	    
			
		<!--FeedBack Form-->
		<mx:Box  id="fbLoggedForm" width="100%" height="100%">
		 	<mx:Form width="100%">
				<mx:FormItem label="Title :">
	 				<mx:TextInput />
	 			</mx:FormItem>
	 			<mx:FormItem label="Description :">
	 				<mx:TextArea/>
	 			</mx:FormItem>
	 		</mx:Form>
	 		<mx:Spacer height="100%"/>
	 		<mx:HBox>			
				<mx:Button label="Submit"/>
				<mx:Button label="Cancel"/>
			</mx:HBox>
				
		<!--Submit Message-->	 		
				<mx:Text text="submitted" textAlign="center" width="250" height="100%" styleName="contentStyle" paddingTop="100" fontSize="14" />
				<mx:HBox width="100%" height="35">			
					<mx:Button label="Return"/>
					<mx:Button label="Submit more feedback"/>
				</mx:HBox>	
			
		<!--FAq's-->
			<mx:HBox id="faqtitle" width="100%">
				<mx:Label text="FAQ" />
				<mx:Label text="Close"/>					
		  	</mx:HBox>	    
			
			<mx:HBox  width="100%" height="100%">
		 		<mx:TextArea text="some text"/>
		 	</mx:HBox>
		
		 				
		<!--about us-->
		<mx:HBox id="abtustitle" width="100%">
				<mx:Label text="abt us" />
				<mx:Label text="Close"/>					
		  	</mx:HBox>	    
			
			<mx:HBox  width="100%" height="100%">
		 		<mx:TextArea text="some text"/>
		 	</mx:HBox>
		
		<!--contact us-->
		<mx:HBox id="cntustitle" width="100%">
				<mx:Label text="cnt us" />
				<mx:Label text="Close"/>					
		  	</mx:HBox>	    
			
			<mx:HBox  width="100%" height="100%">
		 		<mx:TextArea text="some text"/>
		 	</mx:HBox> 
</mx:Box>




Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 8+3 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions