首页» FLEX »flex-for循环语句

flex-for循环语句

立即注册PayPal并开始接受信用卡付款。
转载请保持文章完整性!
本文链接地址:http://blog.desizen.com/4lone/231.html
主页:joel's blog

中for循环的实例,其中用到了一些知识点,具体的可以参考代码,再次强烈建议大家学习as3之前先看一下孙鑫的 java无难事.其实as3和java语言是非常的类似的.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	 creationComplete="init()">
 
	<mx:Script>
		<![CDATA[
		//此程序在ie6和firefox下运行结果不同,这个是根据浏览器的特性决定的
			internal function init():void{
				var num:int = 0;
				var i:int = 0;
				do{//循环
					num = num+i;
					i++;
				}while(i<100);			
 
				//trace(num);//只能是在控制台里面输出,并且在调试的时候输出,而且必须装有debug版本的flash player,打印出的是String
				txt.text=txt.text+"\n"+num.toString();//想要保留原有数据而增加数据,只需加一个"\n"换行
 
				var student:Object = new Object();
				student.name = "小王";
				student.age = 20;
				student.type = "本科";
 
				for (var prop:String in student) {//我在java里面没有接触到,但是jscript里面好像有,说是增强型for循环,遍历所有的名称,故声明为String
					//trace (prop+":"+student[prop]);
					txt.text=txt.text+"\n"+prop+":"+student[prop].toString();//这里通过观察可以发现,prop相当于一个Object数组的索引了
				}
 
				for each(var value:* in student) {//这种for循环遍历的是所有属性的值
					//trace (value);
					txt.text=txt.text+"\n"+value.toString();
				}
 
			}
		]]>
	</mx:Script>
	<mx:TextArea x="67" y="25" width="514" height="299" id="txt" fontSize="12" editable="true" enabled="true"/>
</mx:Application>

标签:,

与"flex-for循环语句"相关的文章:

没有评论 »

还没有评论呢。

留下评论

emoticons

Feedback Form