热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

子串,定时器和LED灯,as3-Substrings,timerandLEDlights,as3

HowwouldIsyncmytimerwithmyLEDlights?Idontunderstandhowtotosetupthestringsandco

How would I sync my timer with my LED lights? I don't understand how to to set up the strings and conditions, so that they are unique to each number space.

如何将我的计时器与LED灯同步?我不明白如何设置字符串和条件,因此它们对每个数字空间都是唯一的。

Need a condition and values for each blinker

需要每个闪光灯的条件和值

var condition:Number = 5;
if(cOndition==5){
blink.visible = !blink.visible;
//blink_.visible = !box.visible;
//blink__.visible = !box.visible;
}
}

alt text http://www.ashcraftband.com/myspace/videodnd/logic.jpg

替代文字http://www.ashcraftband.com/myspace/videodnd/logic.jpg

Complete code

//MY TIMER
var timer:Timer = new Timer(100);
//INTEGER VALUES
var count:int = 0;
var fcount:int = 0; 
var oldcount:int = 0;
//FORMATTING STRING
function formatCount(i:int):String { 
var fraction:int = i % 100; 
var whole:int = i / 100;  
return ("00" + whole).substr(-2, 2) + "." + (fraction <10 ? "0" + fraction : fraction); 
} 
//START TIMER
timer.start();
timer.addEventListener(TimerEvent.TIMER, condition);
//ANIMATION
function condition(event:TimerEvent):void{
count++;
fcount=int(count)
var toText:String = formatCount(fcount);
dec.text = toText.substr(4, 1);
decimal.text = toText.substr(3, 1);
ones.text = toText.substr(1, 1);
//LED LIGHTS
var condition:Number = 5;
if(cOndition==5){
blink.visible = !blink.visible;
//blink_.visible = !box.visible;
//blink__.visible = !box.visible;
}
}

1 个解决方案

#1


0  

This works
If else allows triggering tweens at different times. You'll there's a pause at zero every time. This needs to fix this, but the rest is ok.

这有效如果else允许在不同时间触发补间。你每次都会暂停零。这需要解决这个问题,但其余的都可以。

Recast substrings as numbers

重新生成子串作为数字

//RECASTING THE STRINGS
var subThing:String = toText.substr(4, 1);
var numberThing:Number = parseInt(subThing);
trace(numberThing + " dec");
var subThing_:String = toText.substr(3, 1);
var numberThing_:Number = parseInt(subThing_);
trace(numberThing_ + " decimal");
var subThing__:String = toText.substr(1, 1);
var numberThing__:Number = parseInt(subThing__);
trace(numberThing__ + " ones");

If Else

import fl.transitions.Tween;
import fl.transitions.easing.*;
//LED LIGHTS
if(numberThing> 0){
numberThing++;
var AlphaTween:Tween = new Tween(blink, "alpha", Strong.easeOut, 0, 2, 3, true);//0,1,1
}
else if (numberThing_> 0){
numberThing_++;
var AlphaTween_:Tween = new Tween(blink_, "alpha", Strong.easeOut, 0, 2, 3, true);//0,1,1
}
else if (numberThing__> 0){
numberThing__++;
var AlphaTween_:Tween = new Tween(blink__, "alpha", Strong.easeOut, 0, 2, 3, true);//0,1,1
}


推荐阅读
author-avatar
愤然尔立_980
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有