Flex入门笔记

Test_01.mxml

<?xmlversion="1.0"encoding="utf-8"?>

<viewer:BaseWidgetxmlns:fx="http://ns.adobe.com/mxml/2009"
				xmlns:s="library://ns.adobe.com/flex/spark"
				xmlns:mx="library://ns.adobe.com/flex/mx"
				xmlns:viewer="com.esri.viewer.*"
				xmlns:components="com.esri.viewer.components.*"
				widgetConfigLoaded="init()">
	<fx:Script>
		<![CDATA[
			[Bindable]
			//有了上面这句,text="{helloContent}"才能起作用
			//thisfunctioncalledwhenthewidget'sconfigurationisloaded
			privatevarhelloContent:String;
			
			privatefunctioninit():void
			{
				if(configXML)//checkingforvalidcontentintheconfigurationfile
				{
					//读取配置文件
					lbl.text=configXML.content||getDefaultString("helloContent");
					helloContent="你好你好!!!";
//					lbl.text="Success~~~~~~~~~~";
//					lbl.text=getDefaultString("helloContent");
				}
			}
			
			protectedfunctionlabel1_clickHandler(event:MouseEvent):void
			{
				//TODOAuto-generatedmethodstub
				if(txt.text==""){
					txt.text="Godblessyou!!";
				}else{
					txt.text="";
				}
			}
			
		]]>
	</fx:Script>
	<viewer:WidgetTemplateid="helloWorld"
						width="557"height="419">
		<viewer:layout>
			<!--
			<s:VerticalLayouthorizontalAlign="center"verticalAlign="middle"/>
			-->
			<s:VerticalLayouthorizontalAlign="left"verticalAlign="middle"/>
			
		</viewer:layout>
		
		<s:Labelid="lbl"
				width="100%"
				fontSize="18"
				fontStyle="italic"
				fontWeight="bold"/>
		<s:Labeltext="{helloContent}"/>
		<s:Labelid="txt"
				width="100%"
				fontSize="18"
				fontStyle="italic"
				fontWeight="bold"
				click="label1_clickHandler(event)"/>
	</viewer:WidgetTemplate>
</viewer:BaseWidget>

Test_01.xml

<configuration>
<content>HelloWorld!Successfullyworks!!!~~~@@@</content>
</configuration>

运行效果

wKiom1PZnSCzx7yjAAImLdHLp-g980.jpg



垂直布局与Button

	<viewer:WidgetTemplateid="test_02"width="300"height="200">
		<s:Group>
			<s:layout>
				<s:VerticalLayout/>
			</s:layout>
			
			<s:Buttonlabel="1"/>
			<s:Buttonlabel="2"/>
			<s:Buttonlabel="3"/>
		</s:Group>
	</viewer:WidgetTemplate>

wKioL1PZrOeQP7XAAAEF1H3dhdY998.jpg

<s:Buttonlabel="1"/><!--Button大写表示Button是实例,label小写表示label是属性-->
<s:Button>
<s:label>3</s:label>
</s:Button><!--与上面的写法等价-->


滚动内容

		<s:Scrollerheight="65">
			<s:Group>
				<s:layout>
					<s:VerticalLayout/>
				</s:layout>
				
				<s:Buttonlabel="1"/>
				<s:Buttonlabel="2"/>
				<s:Buttonlabel="3"/>
			</s:Group>
		</s:Scroller>

wKioL1PZrqHwh-dCAACaZ0V-cwc439.jpg

本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/1533063

你可能感兴趣的:(flex入门)