2,275
社区成员
发帖
与我相关
我的任务
分享
var tempname:int;
for (var w:int=0; w<4; w++)
{
for (var i:int =0; i<5; i++)
{
tempname++;
var temp:mys = new mys();
temp.x = i * 80 + 100;
temp.y = w * 70 + 100;
addChild(temp);
temp.text = "<font size='18'>Hello" + tempname.toString() + "</font>";
}
}
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.geom.ColorTransform;
public class mys extends Sprite
{
private var str:String;
private var txt:TextField;
private var moviePlay:Boolean;
private var BG:Sprite = new Sprite();
private var color:uint = 0xff0000;
private var color2:uint = 0xff9900;
private var colorT:ColorTransform = new ColorTransform();
public function mys()
{
addEventListener(MouseEvent.MOUSE_OVER,mEvt);
addEventListener(MouseEvent.MOUSE_OUT,mEvt);
addEventListener(Event.ENTER_FRAME,entEvt);
BG.graphics.beginFill(0xff0000);
BG.graphics.drawCircle(0,0,50);
BG.graphics.endFill();
BG.alpha = 0.5;
addChild(BG);
txt = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
txt.selectable = false;
txt.mouseEnabled = false;
txt.visible = false;
buttonMode = true;
addChild(txt);
}
private function entEvt(e:Event):void
{
if (moviePlay)
{
if (BG.scaleX < 1.2)
{
BG.scaleX = BG.scaleY += 0.02;
}
}
else
{
BG.scaleX = BG.scaleY = 1;
}
}
private function mEvt(e:MouseEvent):void
{
var temp:Number
if (e.type == MouseEvent.MOUSE_OVER)
{
setIndex()
moviePlay = txt.visible = true;
colorT.color = color2;
temp = 0.9;
}
else
{
moviePlay = txt.visible = false;
colorT.color = color;
temp = 0.5;
}
BG.transform.colorTransform = colorT;
BG.alpha = temp;
}
public function set text(value:String):void
{
txt.htmlText = value;
txt.x = - txt.width / 2;
txt.y = - txt.height / 2;
str = value;
}
public function get text():String
{
return str;
}
private function setIndex():void
{
parent.addChild(this);
}
}
}