Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-16-2009, 04:48 AM   #1
newmember
Registered User
 
Join Date: May 2009
Posts: 2
Post help me about creating menu...

I want to write a menu, it 'll load data from xml, it 's same menu of window (file,edit,view,...) when we touched mc it 'll drop down a one list, help me

Code:
package 
{
	//import fl.controls.Button;

	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import gs.*; 
	import gs.easing.*;

	/**
	 * ...
	 * @author ...
	 */
	public class menu extends Sprite {
		
		private var xml:XML;
		private var button:MovieClip;
		private var file:MovieClip;
		private var tk:MovieClip;
		public function menu() {
			loadxml();
		
			buttonfile();

			}

			private function loadxml():void
			{
			var loader:URLLoader = new URLLoader(new URLRequest("menu.xml"));	
			loader.addEventListener(Event.COMPLETE, getxml, false,0,true);
			}
			
			private function getxml(e:Event):void
			{
				xml = new XML(e.target.data);
				trace(xml.file[0].a);// trace
			}
		
			
			private function buttonfile():void
			{
			file = new akim();
		//	file.label = "Click here"; 
			file.x = 20;
			file.y = 50; 
			addChild(file);
			file.addEventListener(MouseEvent.CLICK, thanhphan, false, 0, true);
			
			}
			

			private function thanhphan(e:Event):void
		{
				
			var i:uint;
			var rrr:Array = new Array();
			
			for (i = 0; i < xml.menucon[0].a.length(); i++)
			{
				file.visible = false;
				button = new akim();
				button.x = 120;
				button.y = 80;
				addChild(button);
				rrr.push(button);
				button.label = xml.menucon[0].a[i] ;
				button.x += 120*i;
				button.y = 50;
			//	button.name = xml.menucon[0].a[i]; //trace name			
			
			button.addEventListener(MouseEvent.CLICK, onTraceName, false, 0, true);
					
			}
				this.addEventListener(MouseEvent.ROLL_OVER, menuso, false, 0, true);	
				
			}

			private function menuso(e:MouseEvent):void 
			{
			var i:uint;
			
			var _arr:Array = new Array();
			for (i = 0; i < xml.menucon[0].a.length(); i++)
			{
				
			//	tk = new btt();
				//creatbutton();
				tk = new akim();	
				this.addChild(tk);
				tk.x = 20;
				tk.y = 90;
				_arr.push(tk);
				tk.label = xml.file[0].a[i];
				tk.x = 120;
				tk.y += 40 * i;
				tk.name = xml.file[0].a[i];			
			tk.addEventListener(MouseEvent.CLICK, onTraceName, false, 0, true);
			}
			_arr.addEventListener(MouseEvent.ROLL_OUT,hidemenu,false,0,true);
			}
				private function onTraceName(e:MouseEvent):void
				{
					trace(e.target.name);
				}
			
				private function hidemenu(e:MouseEvent):void
				{
					var _arr:Array = new Array();
					var i:uint;
						for(i=0;i<xml.menucon[0].a.length();i++)
				{
					_arr[i].visible=false;
					stage.removeEventListener(MouseEvent.ROLL_OUT, hidemenu);
				}
				}
				
}
}
newmember is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:29 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.