Flex 4.6 XML搜索、匹配示例

2011-05-20 Flex

效果见图

初始化界面

输入“设置”,进行搜索、匹配后界面

下面是代码 <?xml version=”1.0” encoding=”utf-8”?> <![CDATA[ import mx.events.FlexEvent; import mx.utils.StringUtil; import spark.events.TextOperationEvent;

		public var rawList:XML = 
			<apps name="应用程序" >
			  <item name="关于"
			  		icon="plugins/about_002/assets/icons/about_48.png" 
			  		iconSmall="plugins/about_002/assets/icons/about_24.png" 
			  		moduleUrl="plugins/about_002/Ahout_002.swf"
			  		version="1.0"  date="2013-5-13"  author="way" type="plugin"
			  		description="关于能源管理中心的一个说明" />

			 <item name="程序管理" 
			  		icon="plugins/appManager_001/assets/icons/apps_48.png" 
			  		iconSmall="plugins/appManager_001/assets/icons/apps_24.png"
			  		moduleUrl="plugins/appManager_001/AppManager_001.swf"
			  		version="1.0"  date="2013-3-5"  author="way" type="plugin"  resizable="false"
			  		description="对系统应用,及用户自定义应用进行管理"
			  		shortCutCreated="true"/>

			  <item name="导航设置" 
			  		icon="plugins/navigatorSetting_001/assets/icons/gears_48.png" 
			  		iconSmall="plugins/navigatorSetting_001/assets/icons/gears_24.png" 
			  		moduleUrl="plugins/navigatorSetting_001/NavigatorSetting_001.swf"
			  		version="1.0"  date="2013-3-13" author="way" type="plugin" resizable="false"
					description="对导航进行设置"/>
			  <item name="主题设置" 
			  		icon="plugins/themeSetting_001/assets/icons/icon_48.png" 
			  		iconSmall="plugins/themeSetting_001/assets/icons/icon_24.png" 
			  		moduleUrl="plugins/themeSetting_001/ThemeSetting_001.swf"
			  		version="1.0"  date="2013-3-5" author="way" type="plugin" resizable="false"
			  		description="对系统的主题、样式进行设置"/>
		    </apps>
			;     

		[Bindable]
		public var rawListShow:XML = null;  //搜索过滤后的数据

		protected function init(event:FlexEvent):void
		{
			getData();
		}

		protected function textinput1_changeHandler(event:TextOperationEvent):void
		{
			getData();
		}

		//初始化数据
		private function getData():void{
			if(StringUtil.trim(textInput.text) == ""){
				rawListShow = rawList ;

			}else{
				createNewXml(textInput.text,rawList);
			}

			/* 打开或关闭指定项目下的所有树项目。如果设置 dataProvider 之后立即调用 expandChildrenOf(),
			则您可能看不到正确的行为。您应该等待对组件进行验证或调用 validateNow() 方法 */
			tree1.validateNow();

			expandtree();
		}

		//搜索过滤后,生产新的xml
		private function createNewXml(searchString:String, xml:XML):void{
			rawListShow =<apps  name="应用程序" />;

			for(var i:int = 0; i<xml.children().length(); i++)
			{
				var itemXml:XML = xml.child("item")[i];
				if(isInStr(searchString,[email protected]())){   
					rawListShow.appendChild(itemXml);
				}
			}
		}

		//判断search_str是否在str内 
		public function isInStr(search_str:String , str:String):Boolean{    
			var num:int= str.indexOf(search_str);
			if(num>-1){
				return true;
			}else{
				return false;
			}
		}

		//展开树
		private function expandtree():void {
			for each(var item:XML in this.tree1.dataProvider)
			this.tree1.expandChildrenOf(item,true);
		}

	]]>
</fx:Script>
<fx:Declarations>
	<!-- 该例子由waylau.com提供-->
</fx:Declarations>
<s:TextInput prompt="请输入要搜索的字段"  x="10" y="10" 
			 change="textinput1_changeHandler(event)" id="textInput"/>
<mx:Tree id="tree1" dataProvider="{rawListShow}" 
		 labelField="@name" width="200" height="300" x="10" y="40">
</mx:Tree>

<s:Label text="更多例子 请关注  waylau.com" x="10" y="360"/>
</s:Application>

简单实现浏览国外著名网站的方法,不用梯子,修改本机的 hosts

2011-04-28 Web

修改本机的 hosts 文件

一般的

hosts文件在不同操作系统(甚至不同Windows版本)的位置都不大一样: Windows NT/2000/XP/Vista/7/8(即微软NT系列操作系统):默认位置为%SystemRoot%\system32\drivers\etc\,但也可以改变。动态目录由注册表键\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath决定。 Windows 95/98/Me:%WinDir%
Linux及其他类Unix操作系统:/etc Mac OS 9及更早的系统:System Folder: Preferences或System folder(文件格式可能与Windows和Linux所对应的文件不同) Mac OS X:/private/etc(使用BSD风格的hosts文件) OS/2及eComStation:”bootdrive”:\mptn\etc
Android:/system/etc/hosts Symbian第1/2版手机:C:\system\data\hosts Symbian第3版手机:C:\private\10000882\hosts,只能使用兼容AllFiles的文件浏览器访问,大部分都不行[1]。 iOS(iPhone):/etc iOS(iPad):/private/etc webOS:/etc

文件中添加要访问的IP 和 域名即可

127.0.0.1 localhost
127.0.0.1 activate.adobe.com
74.125.224.231 drive.google.com
203.208.46.206 m.youtube.com
203.208.46.206 s.ytimg.com
203.208.46.206 www.youtube.com

hosts文件也可以用于其它情况,例如可以将已知的广告服务器重定向到无广告的机器(通常是本地的IP地址:127.0.0.1)上来过滤广告。同时也可以通过不下载网络广告,从而减少带宽。使用hosts文件还可以减少对DNS服务器的访问来加快访问速度并减少带宽消耗。 hosts文件的另一个重要用途就是用于拦截一些恶意网站的请求,从而防止访问欺诈网站或感染一些病毒或恶意软件。但同时,这个文件也可能被病毒或恶意软件所利用来阻止用户更新杀毒软件或访问特定网站。

文章参考:http://zh.wikipedia.org/wiki/Hosts%E6%96%87%E4%BB%B6

更多参数看考:http://code.google.com/p/smarthosts/

http://code.google.com/p/huhamhire-hosts/



Flex addChild与addElement的区别

2011-01-01 Flex

  • addChild()接受的是一个DisplayObject对象,addElement()接受的是一个IVisualElement对象,IVisualElement是在Flex 4组件中开始应用的,所以Flex 3当中的组件没有实现IVisualElement接口,再所以Flex 3当中的容器用的是addChild()。
  • 而Flex 4中的spark组件已经实现了IVisualElement接口,所以可以用addElement(),在Flex 4中使用Flex 3的组件和其它没有实现IVisualElement接口的组件时,可以使用addElement(UIComponent(flex_3_comp)),就相当于用UIComponent来做一下包装。
  • 在Flex 4容器中,其实内建了一个Group类型的contentGroup用来存放容器中的元素,而正是Group类定义了addElement(),所以Flex 4容器不用addChild(),而是用addElement()
  • 如果是spark(如s:Group)容器,用addElement。如果是hola(如mx:Hbox)容器,就用addChild。

参考:http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf62b90-7fe9.html


校园网信息网络安全问题以及对策综述

2010-05-31 Security

摘要: 21世纪,计算机网络技术飞速发展,网络改变了人们的生活方式、学习方式,也为学校信息化建设注入了新的生机活力。但同时由于网络的自身开放性、互联性和共享性的特点,也为校园网的安全带来的威胁和挑战。校园网不可避免地受到病毒、黑客、恶意程序和其它的安全威胁和攻击,造成校园网数据丢失、系统被改、网络瘫痪等。本文分析了校园网的现状特点和存在的主要问题,提出了应对校园网威胁的安全策略。

关键词: 计算机网络;校园网;威胁;防范




Way Lau

Software Engineer and Full Stack Developer, now work and live in Shenzhen, China. Detail

Donate

See the list of Donors.