Our Blog / อับเดทความเคลื่อนไหว และข่าวสาร

ตัวอย่าง Scrollbar เป็นแบบ Flash?Action Script 3.0 ครับ

package
{
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;

public class Scrollbar extends MovieClip
{
private var _1124:Number;
public var text:MovieClip;
public var background:MovieClip;
public var _112c:BlurFilter;
private var _11210:Number;
private var _1133:Number;
public var maskmc:MovieClip;
public var area:MovieClip;
public var _1137:uint;
public var ruler:MovieClip;

public function Scrollbar()
{
addFrameScript(0, frame1);
addEventListener(Event.ADDED_TO_STAGE, _1126);
return;
}// end function

public function _1126(param1:Event = null) : void
{
_1132();
_112c = new BlurFilter(0, 0, 1);
this.text.filters = new Array(_112c);
this.text.mask = this.maskmc;
this.text.cacheAsBitmap = true;
this._11210 = background.y;
this._1133 = background.y + background.height – ruler.height;
this.ruler.buttonMode = true;
this._1124 = text.y;
this._11210 = 0;
this._1133 = this.background.height – this.ruler.height;
ruler.addEventListener(MouseEvent.MOUSE_DOWN, _1139);
stage.addEventListener(MouseEvent.MOUSE_UP, _1127);
this.addEventListener(MouseEvent.MOUSE_WHEEL, _1131, true);
this.addEventListener(Event.ENTER_FRAME, _112b);
return;
}// end function

private function _1127(param1:MouseEvent)
{
ruler.stopDrag();
return;
}// end function

public function _112a() : void
{
var _loc_1:Number;
var _loc_2:Number;
var _loc_3:Number;
var _loc_4:Number;
var _loc_5:Number;
var _loc_6:Number;
var _loc_7:Number;
var _loc_8:Number;
_1137 = 100 / _1133 * ruler.y;
_loc_1 = 0;
_loc_2 = text.height – maskmc.height / 2 + 20;
_1135();
_loc_4 = _1124 – (_loc_2 – maskmc.height / 2) / 100 * _1137;
_loc_5 = text.y;
_loc_6 = _loc_4;
if (_loc_5 != _loc_6)
{
_loc_7 = _loc_6 – _loc_5;
_loc_5 = _loc_5 + _loc_7 / 4;
_loc_8 = Math.abs(_loc_7) / 8;
_112c.blurY = _loc_8 / 2;
text.filters = new Array(_112c);
}
text.y = _loc_5;
return;
}// end function

private function _112b(param1:Event)
{
_112a();
return;
}// end function

private function _112f(param1:int)
{
var _loc_2:Number;
var _loc_3:Number;
_loc_2 = (-param1) * 10;
if (_loc_2 > 0)
{
_loc_3 = Math.min(_1133, ruler.y + _loc_2);
}
if (_loc_2 < 0)
{
_loc_3 = Math.max(_11210, ruler.y + _loc_2);
}
ruler.y = _loc_3;
_112a();
return;
}// end function

private function _1131(param1:MouseEvent)
{
if (this.area.hitTestPoint(stage.mouseX, stage.mouseY, false))
{
_112f(param1.delta);
}
return;
}// end function

function frame1()
{
stop();
return;
}// end function

public function _1132() : void
{
text.y = 0;
ruler.y = 0;
return;
}// end function

public function _1135() : void
{
if (text.height < maskmc.height)
{
ruler.visible = false;
}
else
{
ruler.visible = true;
}
return;
}// end function

private function _1139(param1:MouseEvent)
{
var _loc_2:Rectangle;
_loc_2 = new Rectangle(background.x – ruler.width / 2 + 1, _11210, 0, _1133);
ruler.startDrag(false, _loc_2);
return;
}// end function

}
}

ดาวโหลดไฟล์ได้ที่นี่?( ตอนนี้ติด password ก่อนนะครับ ยังทำหน้ารวมดาวโหลดไม่เสร็จ )

Comments

comments

Tle Jakapong L.

Managing Directer at Digitalmedia Outsource Solution Co.,Ltd. @tlecoco

Comments are closed.