学习自定义slider组件的方法
以下是我在学习中整理的关于怎样自定义slider组件的方法?
希望对大家在学习中遇到这样的问题能有所帮助。
代码:
package com{
import flash.display.*;
import flash.geom.*;
import flash.events.*;
public class aa extends Sprite {
private var hsj:灰三角;
private var lsj:绿三角;
private var hk:滑块;
public var zz:Number=100;
private var lsj_width:Number;
private var lsj_height:Number;
private var rect:Rectangle;
public function aa() {
hsj=new 灰三角();
lsj=new 绿三角();
hk=new 滑块();
init();
}
public function init() {
addChild(hsj);
addChild(lsj);
addChild(hk);
hsj.y=hsj.height;
lsj.y=lsj.height;
hk.x=hsj.width;
lsj_width=lsj.width;
lsj_height=lsj.height;
rect= new Rectangle(10,0,50,0);
hk.addEventListener(MouseEvent.MOUSE_DOWN,ondown);
hk.addEventListener(MouseEvent.MOUSE_UP,onup);
}
public function ondown(e:MouseEvent):void {
e.currentTarget.startDrag(false,rect);
}
public function onup(e:MouseEvent):void {
e.currentTarget.stopDrag();
zz=(hk.x-hk.width)*2;
lsj.width=hk.x-hk.width/2;
lsj.height=lsj.width*lsj_height/lsj_width;
onchange();
}
public function onchange(){
trace(zz);
return zz;
}
}
}
*******************fla文件代码**********************
import com.aa;
var ab:aa=new aa();
addChild(ab);
ab.x=200;
ab.y=200;
trace(ab.zz);
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |