ssc

接了一个ssc的小项目,却因为对方的不作答而半途而废。我写了一天的代码算是废了。

主程序

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"
width="" height="" xmlns:cc="*"> <mx:Script>
<![CDATA[
import com.adobe.serialization.json.JSON;
import mx.controls.Alert;
import mx.formatters.DateFormatter; [Bindable]
public var t1:int;
[Bindable]
public var t2:int;
[Bindable]
public var t3:int;
[Bindable]
public var t4:int; [Bindable]
public var now:Date; [Bindable]
public var balls:Array = []; public static var INTERVAL:int = *; public static var BALL_COUNT:int = ; public var count:int; public function init():void { now = new Date();
var timer:Timer = new Timer();
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start(); var ss:String = JSON.encode(null);
//getBalls(); var obj:Object = {};
obj.a = ;
obj.b = "asdf";
Alert.show(obj+"");
var xx:XML = <asfasf/>
xx.appendChild(obj);
Alert.show(xx.toXMLString()); } public function getBalls():void {
var center:Point = new Point(ballbox.width/, ballbox.height/-);
var radis:Number = ballbox.width/ - ;
trace(radis + " / " + ballbox.width/);
for(var i:int=;i<=BALL_COUNT;i++) {
balls[i] = (int)(Math.random()*);
trace(balls[i]); var btn:Button = new Button();
btn.width = ;
btn.height = ;
btn.setStyle("cornerRadius", );
btn.label = balls[i]+"";
btn.x = radis*Math.sin(*i/(BALL_COUNT-)) + center.x;
btn.y = radis*Math.cos(*i/(BALL_COUNT-)) + center.y;
ballbox.addChild(btn); trace("" + btn.x + " / " + btn.y);
} } public function onTimer(e:TimerEvent):void {
count ++;
if(count == INTERVAL) {
count = ;
t1 = ;
t2 = ;
t1 = ;
t2 = ;
// lottery
Alert.show("开奖了!");
}
var left:int = INTERVAL - count;
var minutes:int = left/;
var seconds:int = left%;
if(minutes>=) {
t1 = ;
t2 = ;
} else {
t1 = ;
t2 = minutes;
}
if(seconds>=) {
t3 = seconds/;
t4 = seconds%;
} else {
t3 = ;
t4 = seconds;
} } ]]>
</mx:Script>
<mx:Panel title="欢迎光临本店" width="100%" height="100%">
<mx:Button color="red" label=""/>
<mx:HBox horizontalAlign="right" width="100%">
<mx:Text text="距离本期销售截止,还有"/>
<mx:Button id="n1" label="{t1}" fontSize="" fontWeight="bold"/>
<mx:Button id="n2" label="{t2}" fontSize="" fontWeight="bold"/>
<mx:Text text="分"/>
<mx:Button id="n3" label="{t3}" fontSize="" fontWeight="bold"/>
<mx:Button id="n4" label="{t4}" fontSize="" fontWeight="bold"/>
<mx:Text text="秒"/>
</mx:HBox> <mx:Canvas id="ballbox" height="100%" width="100%">
</mx:Canvas> </mx:Panel>
<mx:HBox x="" y="" horizontalGap="">
<cc:RollableBall2 cW="" cH=""/>
<cc:RollableBall2 cW="" cH=""/>
<cc:RollableBall2 cW="" cH=""/>
<cc:RollableBall2 cW="" cH=""/>
<cc:RollableBall2 cW="" cH=""/>
</mx:HBox> <mx:HBox x="" y="" horizontalGap="">
<cc:RollableBall3 cW="" cH=""/>
<cc:RollableBall3 cW="" cH=""/>
<cc:RollableBall3 cW="" cH=""/>
<cc:RollableBall3 cW="" cH=""/>
<cc:RollableBall3 cW="" cH=""/>
</mx:HBox>
</mx:Application>

按钮控件

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="{this.cW}" height="{this.cH}" creationComplete="init()"
horizontalScrollPolicy="off" verticalScrollPolicy="off" fontSize="{this.cW/3}" fontWeight="bold" fontThickness="{this.cW/20}"
borderThickness="" borderColor="blue" borderStyle="outset"> <mx:Script>
<![CDATA[
import flash.utils.setTimeout;
import mx.controls.Button; public var TOTAL_INTERVAL:int = *; public var interval:int = ; public static var ROLL_COUNT:int = ; public var count:int = ; public var ecliipsedTime:int = ; public var y1:int = ;
public var y2:int = -; public var btn1:Button = new Button();
public var btn2:Button = new Button(); [Bindable]
public var cW:int;
[Bindable]
public var cH:int; public function init():void {
btn1.label = (int)(Math.random()*);
btn1.width = cW;
btn1.height = cH;
//btn1.setStyle("fontSize", 20);
btn2.label = (int)(Math.random()*);
btn2.width = cW;
btn2.height = cH;
btn2.y = -cH;
//btn2.setStyle("fontSize", 20);
this.addChild(btn1);
this.addChild(btn2);
start();
} public function start():void {
var delay:int = (int)(Math.random()*);
var t:Timer = new Timer(delay, );
t.addEventListener(TimerEvent.TIMER, doStart);
t.start();
} public function doStart(e:TimerEvent):void { goTimer();
} public function goTimer():void { flash.utils.setTimeout(function():void{
//Alert.show("sleep test ok");
onTimer();
},interval,null);
} public function newBtn():Button {
return null;
} // 开始滚动的时候要慢, 快要停止id时候也要慢!
public function onTimer():void {
ecliipsedTime += interval;
count ++; if(count>=ROLL_COUNT*/) {
interval += Math.random()*;
} // if(count>=ROLL_COUNT*9/10) {
// interval += 100;
// }
// if(count>=ROLL_COUNT*29/30) {
// interval += 200;
// }
// if(count>=ROLL_COUNT*49/50) {
// interval += 500;
// } // if(TOTAL_INTERVAL-ecliipsedTime<=1) {
// interval += 20;
// } if(count>ROLL_COUNT) {
return;
} y1 += ;
if(y1>=cH) {
y1 = -;
btn1.label = (int)(Math.random()*);
}
btn1.y = y1; y2 += ;
if(y2>=cH) {
y2 = -;
btn2.label = (int)(Math.random()*);
}
btn2.y = y2; goTimer();
} ]]>
</mx:Script>
</mx:Canvas>

按钮控件

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="{this.cW}" height="{this.cH*3}" creationComplete="init()"
horizontalScrollPolicy="off" verticalScrollPolicy="off" fontSize="{this.cW/3}" fontWeight="normal" fontThickness="{this.cW/20}"
borderThickness="" borderColor="blue" borderStyle="outset"> <mx:Script>
<![CDATA[
import flash.utils.setTimeout;
import mx.controls.Button; public var TOTAL_INTERVAL:int = *; public var interval:int = ; public static var ROLL_COUNT:int = ; public var count:int = ; public var ecliipsedTime:int = ; public var y1:int;
public var y2:int;
public var y3:int;
public var y4:int; public var btn1:Button = new Button();
public var btn2:Button = new Button();
public var btn3:Button = new Button();
public var btn4:Button = new Button(); [Bindable]
public var cW:int;// button 宽度
[Bindable]
public var cH:int;// button 高度 public function init():void { y1 = ;
y2 = cH*;
y3 = cH*;
y4 = -cH; btn1.label = (int)(Math.random()*);
btn1.width = cW;
btn1.height = cH;
btn1.y = y1;
//btn1.setStyle("fontSize", 20);
this.addChild(btn1);
btn2.label = (int)(Math.random()*);
btn2.width = cW;
btn2.height = cH;
btn2.y = y2;
this.addChild(btn2);
btn3.label = (int)(Math.random()*);
btn3.width = cW;
btn3.height = cH;
btn3.y = y3;
this.addChild(btn3);
btn4.label = (int)(Math.random()*);
btn4.width = cW;
btn4.height = cH;
btn4.y = y4;
this.addChild(btn4); start();
} public function start():void {
var delay:int = (int)(Math.random()*);
var t:Timer = new Timer(delay, );
t.addEventListener(TimerEvent.TIMER, doStart);
t.start();
} public function doStart(e:TimerEvent):void { goTimer();
} public function goTimer():void { flash.utils.setTimeout(function():void{
//Alert.show("sleep test ok");
onTimer();
},interval,null);
} public function newBtn():Button {
return null;
} public function onTimer():void {
ecliipsedTime += interval;
count ++; // if(count>=ROLL_COUNT*9/10) {
// interval += Math.random()*100;
// } // if(count>=ROLL_COUNT*9/10) {
// interval += 100;
// }
// if(count>=ROLL_COUNT*29/30) {
// interval += 200;
// }
// if(count>=ROLL_COUNT*49/50) {
// interval += 500;
// } // if(TOTAL_INTERVAL-ecliipsedTime<=1) {
// interval += 20;
// } if(count>ROLL_COUNT) {
btn2.setStyle("fontWight", "bold");
btn2.setStyle("fontSize", this.cW/);
btn2.setStyle("color", "red");
btn2.setStyle("fontThickness", this.cW/); btn2.invalidateProperties();
btn2.invalidateSize();
btn2.invalidateDisplayList();
return;
} y1 += ;
if(y1>=cH*) {
y1 = -cH;
btn1.label = (int)(Math.random()*);
}
btn1.y = y1; y2 += ;
if(y2>=cH*) {
y2 = -cH;
btn2.label = (int)(Math.random()*);
}
btn2.y = y2; y3 += ;
if(y3>=cH*) {
y3 = -cH;
btn3.label = (int)(Math.random()*);
}
btn3.y = y3; y4 += ;
if(y4>=cH*) {
y4 = -cH;
btn4.label = (int)(Math.random()*);
}
btn4.y = y4; goTimer();
} ]]>
</mx:Script>
</mx:Canvas>
上一篇:Java面试题集合(比较实用)


下一篇:C语言中动态内存分配的本质是什么?