发布网友 发布时间:2022-04-24 13:34
共3个回答
热心网友 时间:2023-10-14 15:39
后边的是8位。看清楚不是7位。颜色的设置有两种,一种是6位的16进制表示,格式为
0xRRGGBB 这里的 R代表 red红色,G是绿色 green,b是blue
还有一种8位表示方法,是带一个A参数的 即 0xAARRGGBB 这里的A是指alpha,透明度。
如果你需要换颜色,那么就按照上边讲的,6位的 都换了,而8位的 只换后六位
热心网友 时间:2023-10-14 15:40
栏里,ctrl+enter看效果
var ball:Sprite;
var angle:Number = 0;
var speed:Number = 0;
var tf_angle:TextField;
var tf_speed:TextField;
var lab_angle:TextField;
var lab_speed:TextField;
var bt_changeArgs:SimpleButton;
var bt_reset:SimpleButton;
drawBall();
drawUI();
this.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
function drawBall():void {
ball = new Sprite();
with (ball.graphics) {
beginFill(0x000000);
drawCircle(0,0,10);
endFill();
}
ball.x = stage.stageWidth / 2;
ball.y = stage.stageHeight / 2;
this.addChild(ball);
}
function drawUI():void {
lab_angle = new TextField();
lab_angle.x = 10;
lab_angle.y = 10;
lab_angle.text = "角度";
lab_angle.selectable = false;
lab_angle.width = 40;
lab_angle.height = 20;
this.addChild(lab_angle);
tf_angle = new TextField();
tf_angle.x = 50;
tf_angle.y = 10;
tf_angle.border = true;
tf_angle.width = 50;
tf_angle.height = 20;
tf_angle.type = TextFieldType.INPUT;
tf_angle.text = "0";
this.addChild(tf_angle);
lab_speed = new TextField();
lab_speed.x = 10;
lab_speed.y = 50;
lab_speed.text = "速度";
lab_speed.selectable = false;
lab_speed.width = 40;
lab_speed.height = 20;
this.addChild(lab_speed);
tf_speed = new TextField();
tf_speed.x = 50;
tf_speed.y = 50;
tf_speed.border = true;
tf_speed.width = 50;
tf_speed.height = 20;
tf_speed.type = TextFieldType.INPUT;
tf_speed.text = "0";
this.addChild(tf_speed);
bt_changeArgs = new SimpleButton(getSprite(1,1),getSprite(1,2),getSprite(1,3),getSprite(1,4));
bt_changeArgs.x = 50;
bt_changeArgs.y = 90;
bt_changeArgs.addEventListener(MouseEvent.CLICK,changeArgs);
this.addChild(bt_changeArgs);
bt_reset = new SimpleButton(getSprite(2,1),getSprite(2,2),getSprite(2,3),getSprite(2,4));
bt_reset.x = 50;
bt_reset.y = 130;
bt_reset.addEventListener(MouseEvent.CLICK,resetBall);
this.addChild(bt_reset);
}
function changeArgs(e:MouseEvent):void {
angle = Number(tf_angle.text);
speed = Number(tf_speed.text);
}
function resetBall(e:MouseEvent):void{
angle = Number(tf_angle.text);
speed = Number(tf_speed.text);
ball.x = stage.stageWidth / 2;
ball.y = stage.stageHeight / 2;
}
function enterFrameHandler(e:Event):void {
ball.x += speed * Math.cos(angle * Math.PI / 180);
ball.y+=speed*Math.sin(angle*Math.PI/180);
}
function getSprite(type:int,state:int):Sprite {
var sprite:Sprite = new Sprite();
var lab:TextField = new TextField();
switch(type){
case 1:
lab.text="点击这里改变参数";
break;
case 2:
lab.text="点击这里复原小球";
break;
}
switch (state) {
case 1 :
sprite.graphics.beginFill(0x666666);
lab.textColor=0xFFFFFF;
break;
case 2 :
sprite.graphics.beginFill(0xCCCCCC);
lab.textColor=0xFFFFFF;
break;
case 3 :
sprite.graphics.beginFill(0xFFFFFF);
lab.textColor=0x000000;
break;
case 4 :
sprite.graphics.beginFill(0x666666);
break;
}
sprite.graphics.drawRect(0,0,100,20);
sprite.addChild(lab);
return sprite;
}
热心网友 时间:2023-10-14 15:40
16743426 = 0xFF7C02, 依然是六位。六位的十六进制用十进制表示,所以成了七位。代码中数字前面有0x表示是十六进制表示,没有的Flash默认是十进制表示。