【游客模式】——注册会员,加入11RIA 闪客社区吧!一起见证Flash的再次辉煌……
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 TKCB 于 2018-2-6 17:06 编辑
转载:9RIA游戏开发者社区(天地会)
作者:沐枫(原天地会大神)
【基础小知识】系列教程(总目录)——沐枫大神出品
1.自定义Button
[Actionscript3] 纯文本查看 复制代码 import flash.events.MouseEvent;
mc.buttonMode = true;
mc.mouseChildren = false;
mc.addEventListener(MouseEvent.MOUSE_OVER,onOverHandler);
mc.addEventListener(MouseEvent.MOUSE_DOWN,onDownHandler);
mc.addEventListener(MouseEvent.CLICK,onClickHandler);
function onOutHandler(e:MouseEvent):void
{
mc.gotoAndStop(1);
mc.txt.text = "移出";
mc.addEventListener(MouseEvent.MOUSE_OVER,onOverHandler);
mc.removeEventListener(MouseEvent.MOUSE_OUT,onOutHandler);
}
function onOverHandler(e:MouseEvent):void
{
mc.gotoAndStop(2);
mc.txt.text = "移入";
mc.removeEventListener(MouseEvent.MOUSE_OVER,onOverHandler);
mc.addEventListener(MouseEvent.MOUSE_OUT,onOutHandler);
}
function onDownHandler(e:MouseEvent):void
{
mc.gotoAndStop(4);
mc.txt.text = "按下";
mc.addEventListener(MouseEvent.MOUSE_UP,onUpHandler);
mc.removeEventListener(MouseEvent.MOUSE_DOWN,onDownHandler);
}
function onClickHandler(e:MouseEvent):void
{
mc.gotoAndStop(1);
mc.txt.text = "点击";
mc.addEventListener(MouseEvent.MOUSE_UP,onUpHandler);
mc.removeEventListener(MouseEvent.CLICK,onClickHandler);
}
function onUpHandler(e:MouseEvent):void
{
mc.removeEventListener(MouseEvent.MOUSE_UP,onUpHandler);
mc.addEventListener(MouseEvent.MOUSE_DOWN,onDownHandler);
mc.addEventListener(MouseEvent.CLICK,onClickHandler);
}
2.判断文本里是否为纯数字
[Actionscript3] 纯文本查看 复制代码 var str:String=txt.text;
if(isNaN(Number(str))==false)
{
trace("为纯数字");
}
else
{
trace("不为纯数字");
}
3.进制转换
[Actionscript3] 纯文本查看 复制代码 var a:uint=10;
trace(a.toString(16));//10转16
var b:uint=a;
trace(b.toString(10));//16转10
4.字符串转换为数值
[Actionscript3] 纯文本查看 复制代码 var str:String="20.3";
trace(int(str)+10);
trace(parseInt(str));//转为整数
trace(parseFloat(str)+20);
var a:uint=20
trace(a.toString(2));//可带小数
下载:
源文件.rar
(20.33 KB, 下载次数: 4)
|