- 浏览: 1428051 次
- 性别:
- 来自: 苏州
文章分类
- 全部博客 (564)
- 算法 (7)
- 流金岁月 (1)
- Javascript (30)
- actionscript (108)
- as3.0 game (14)
- flex (84)
- fms2 (27)
- 正则表达式 (7)
- 开源组件代码(as3.0) (1)
- Pv3d (13)
- Cairngorm (4)
- vbs (54)
- VB程序设计 (26)
- 计算机应用与维护 (4)
- 职场实用穿衣技巧 (3)
- 历史风云 (15)
- 淡泊明志,宁静致远 (12)
- 情感 (26)
- 杂谈 (41)
- 越南风 (14)
- DirectX (9)
- Dev-cpp (11)
- 回望百年 (2)
- 建站经验 (2)
- Python (24)
- 网络赚钱 (4)
- php (2)
- html (1)
- ob0短址网 (1)
- ob0.cn (1)
- wordpress (1)
- pandas logistic (1)
- haxe (1)
- opencv (1)
- 微信小程序 (3)
- vue (3)
- Flutter (1)
最新评论
-
GGGGeek:
第一个函数滚动监听不起作用,onPageScroll可以
微信小程序--搜索框滚动到顶部时悬浮 -
naomibyron:
解决办法:工具 -> 编译选项 -> 编译器 ...
dev-c++中编译含WINSOCK的代码出现错误的解决方法 -
haichuan11:
这个…… 代码不全真的是让人很憋屈的感觉啊
actionScript 3.0 图片裁剪及旋转 -
chenyw101:
老兄能留个QQ号吗?具体的我有些东西想请教下你
用VB制作网站登陆器 -
yantao1943:
貌似有点问题,只派发一次事件啊
使用ActionScript 2.0或ActionScript 3.0处理音频文件的提示点(cue
最近一直做会议与AS3有关项目
今天花了点时间写了一个可以选择套皮肤,或无皮肤AS3.0文本滚动条
不需要皮肤的话,代码会简单的话花一个皮肤
初学,不完美的地方自己可以自己修改。
这里说下套 皮肤方式。
比如我们做一个styleTextScrollBar的皮肤,建一个styleTextScrollBar的影片剪辑然后捆绑上md.UI.styleTextScrollBar,这个类不用写,系统会帮你自动生成,我们只是需要里面一些元件。
分别做四个元件,2个按钮2个影片剪辑
upBtn(SimpleButton);
bottonBtn(SimpleButton);
bgMc(MovieClip)
slipMc:MovieClip;(MovieClip)
然后看类的使用方法吧!
文本滚动条类:
/*
使用方法
//导入mdTextScrollBar组件类
import md.UI.mdTextScrollBar
//库中绑定的皮肤 这个类可以不用写,在库链接写上 md.UI.styleTextScrollBar就会自动生成
import md.UI.styleTextScrollBar
//创建组件
var mdScroll:mdTextScrollBar=new mdTextScrollBar(Text,styleTextScrollBar,300)
addChild(mdScroll)
//说明
//Text:需要绑定的TextField对象,必填
//styleTextScrollBar:需要绑定的皮肤(可选,默认AS3绘制皮肤)
//300:滚动条高度(可选,默认100)
*/
package md.UI{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.text.TextField;
import flash.events.*;
import flash.geom.Rectangle;
import flash.utils.getTimer;
import flash.display.CapsStyle;
import flash.display.LineScaleMode;
public class mdTextScrollBar extends Sprite {
var Text:TextField;
var upBtn:SimpleButton;
var bottonBtn:SimpleButton;
var bgMc:MovieClip;
var slipMc:MovieClip;
var ScrollBarMc:Sprite;
var ScrollBarHeight:Number;
var slipVar:Number;
var slipHeight:Number;
var putTime:uint;
//构造函数
public function mdTextScrollBar(mdText:TextField,...tag) {
Text=mdText;
if (tag.length>0) {
if (tag[0] is Class) {
//有皮肤模式
if (tag[1]==undefined) {
//无设定高度
styleModeInit(tag[0]);
} else {
//有设定高度
styleModeInit(tag[0],tag[1]);
}
} else if (tag[0] is Number) {
//无皮肤模式
//trace("无皮肤模式,但设置了高度"+tag[0]);
nudityModeInit(tag[0]);
} else {
trace("mdTextScrollBar使用非法参数,启动无皮肤模式");
//无皮肤模式
nudityModeInit();
}
} else {
//无皮肤模式
nudityModeInit();
}
}
//皮肤模式
private function styleModeInit(...tag) {
ScrollBarMc=new tag[0];
addChild(ScrollBarMc);
//初始化皮肤
upBtn=ScrollBarMc.getChildByName("upBtn") as SimpleButton;
bottonBtn=ScrollBarMc.getChildByName("bottonBtn") as SimpleButton;
bgMc=ScrollBarMc.getChildByName("bgMc") as MovieClip;
slipMc=ScrollBarMc.getChildByName("slipMc") as MovieClip;
if (tag[1]!=undefined) {
ScrollBarHeight=tag[1];
} else {
ScrollBarHeight=100;
}
upBtn.y=0;
upBtn.x=0;
bgMc.x=0;
bgMc.y=upBtn.height;
bgMc.height=ScrollBarHeight-upBtn.height-bottonBtn.height;
bottonBtn.x=0;
bottonBtn.y=upBtn.height+bgMc.height;
slipMc.x=0;
slipMc.y=upBtn.height;
slipHeight=bgMc.height-slipMc.height;
ScrollBarMc.visible=false
;
//这里mdScrollBar对象的stage还没被赋值
//trace(mdScrollBar.stage)
addEventListener(Event.ENTER_FRAME, addStageEvent);
}
//裸奔模式,我好心点画套皮肤给他吧
private function nudityModeInit(...tag) {
if (tag[0]!=undefined) {
ScrollBarHeight=tag[0];
} else {
ScrollBarHeight=100;
}
ScrollBarMc=new Sprite();
upBtn=new directionButton(15,1);
bottonBtn=new directionButton(15,2);
bottonBtn.y=ScrollBarHeight-bottonBtn.height
bgMc=new MovieClip()
bgMc.graphics.beginFill(0xcccccc)
bgMc.graphics.drawRect(0,0,15,ScrollBarHeight-upBtn.height-bottonBtn.height)
bgMc.y=upBtn.height
slipMc=new MovieClip()
slipMc.graphics.beginFill(0x999999,0)
slipMc.graphics.drawRect(0,0,15,30)
slipMc.graphics.beginFill(0xeeeeee)
slipMc.graphics.drawRoundRect((15-10)/2,0,10,30,5,5)
slipMc.y=upBtn.height
slipHeight=bgMc.height-slipMc.height;
addChild(ScrollBarMc);
ScrollBarMc.addChild(bgMc);
ScrollBarMc.addChild(upBtn);
ScrollBarMc.addChild(bottonBtn)
ScrollBarMc.addChild(slipMc);
ScrollBarMc.visible=false
addEventListener(Event.ENTER_FRAME, addStageEvent);
}
//加载进场景后初始化事件
private function addStageEvent(event:Event):void {
if (ScrollBarMc.stage!=null) {
//文本滚动与鼠标滚轮
Text.addEventListener(Event.SCROLL, textScroll);
//上滚动按钮
upBtn.addEventListener(MouseEvent.MOUSE_DOWN, upBtnDown);
//下滚动按钮
bottonBtn.addEventListener(MouseEvent.MOUSE_DOWN, bottonBtnDown);
//滑块
slipMc.addEventListener(MouseEvent.MOUSE_DOWN, slipDown);
event.target.removeEventListener(Event.ENTER_FRAME, addStageEvent);
}
}
//文本滚动时候
private function textScroll(event:Event) {
//trace(Text.scrollV+"|"+Text.maxScrollV)
if (Text.maxScrollV != 1) {
ScrollBarMc.visible=true;
slipVar=Text.scrollV/Text.maxScrollV;
if (Text.scrollV!=1) {
slipMc.y=bgMc.y+(slipHeight*slipVar);
} else {
slipMc.y=bgMc.y;
}
} else {
ScrollBarMc.visible=false;
}
}
/*
* 滑块滚动
*/
private function slipDown(event : MouseEvent):void {
//首先取消文本框滚动侦听,因为文本滚动的时候会设置滑块的位置,而此时是通过滑块调整文本的位置,所以会产生冲突
Text.removeEventListener(Event.SCROLL, textScroll);
//限定拖动范围
var dragRect : Rectangle = new Rectangle(slipMc.x, bgMc.y, 0, slipHeight);
slipMc.startDrag(false,dragRect);
ScrollBarMc.addEventListener(Event.ENTER_FRAME, slipMcDownTime);
slipMc.stage.addEventListener(MouseEvent.MOUSE_UP, slipUp);
}
private function slipMcDownTime(event : Event):void {
Text.scrollV=Math.round(((slipMc.y-upBtn.height)/slipHeight)*Text.maxScrollV);
}
private function slipUp(event : MouseEvent):void {
Text.addEventListener(Event.SCROLL, textScroll);
slipMc.stopDrag();
slipMc.stage.removeEventListener(MouseEvent.MOUSE_UP, slipUp);
}
/*
* 上滚动按钮
*/
private function upBtnDown(event : MouseEvent):void {
Text.scrollV--;
if (Text.scrollV>1) {
slipMc.y =bgMc.y+(slipHeight*(Text.scrollV/Text.maxScrollV));
} else {
slipMc.y =bgMc.y;
}
//当鼠标在按钮上按下的时间大于设定时间时,连续滚动
putTime = getTimer();
ScrollBarMc.addEventListener(Event.ENTER_FRAME, upBtnDownTime);
upBtn.stage.addEventListener(MouseEvent.MOUSE_UP, upBtnUp);
}
private function upBtnDownTime(event : Event):void {
if (getTimer() - putTime > 500) {
Text.scrollV--;
if (Text.scrollV>1) {
slipMc.y =bgMc.y+(slipHeight*(Text.scrollV/Text.maxScrollV));
} else {
slipMc.y =bgMc.y;
}
}
}
private function upBtnUp(event : MouseEvent):void {
ScrollBarMc.removeEventListener(Event.ENTER_FRAME, upBtnDownTime);
upBtn.stage.removeEventListener(MouseEvent.MOUSE_UP, upBtnUp);
}
/*
* 下滚动按钮
*/
private function bottonBtnDown(event : MouseEvent):void {
Text.scrollV++;
slipMc.y =bgMc.y+(slipHeight*(Text.scrollV/Text.maxScrollV));
//当鼠标在按钮上按下的时间大于设定时间时,连续滚动
putTime = getTimer();
ScrollBarMc.addEventListener(Event.ENTER_FRAME, bottonBtnTime);
bottonBtn.stage.addEventListener(MouseEvent.MOUSE_UP, bottonBtnUp);
}
private function bottonBtnTime(event : Event):void {
if (getTimer() - putTime > 500) {
Text.scrollV++;
slipMc.y =bgMc.y+(slipHeight*(Text.scrollV/Text.maxScrollV));
}
}
private function bottonBtnUp(event : MouseEvent):void {
ScrollBarMc.removeEventListener(Event.ENTER_FRAME, bottonBtnTime);
bottonBtn.stage.removeEventListener(MouseEvent.MOUSE_UP, bottonBtnUp);
}
}
}
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.CapsStyle;
import flash.display.LineScaleMode;
//方向按钮类directionButton
class directionButton extends SimpleButton {
var upColor:uint = 0xE1E1E1;
var overColor:uint = 0xE6E6E6;
var downColor:uint = 0xcccccc;
var size:uint;
var way:uint;
public function directionButton(size,way) {
this.size=size;
this.way=way;
downState = new directionButtonDisplayState(downColor, size,way);
overState = new directionButtonDisplayState(overColor, size,way);
upState = new directionButtonDisplayState(upColor, size,way);
hitTestState = new directionButtonDisplayState(upColor, size,way);
}
}
//绘制方向按钮的方法类directionButtonDisplayState
class directionButtonDisplayState extends Shape {
var bgColor:uint;
var size:uint;
var way:uint;
public function directionButtonDisplayState(bgColor:uint, size:uint,way:uint) {
this.bgColor = bgColor;
this.size = size;
this.way=way;
draw();
}
private function draw():void {
graphics.beginFill(bgColor);
graphics.drawRect(0, 0, size, size);
graphics.endFill();
graphics.beginFill(0xffffff,.4);
if (way==1) {
graphics.drawRect(0, 0, size, size/2);
graphics.endFill();
} else if (way==2) {
graphics.drawRect(0, size/2, size, size/2);
graphics.endFill();
} else if (way==3) {
graphics.drawRect(0, 0, size/2, size);
graphics.endFill();
} else if (way==4) {
graphics.drawRect(size/2, 0, size/2, size);
graphics.endFill();
}
graphics.beginFill(0x000000);
graphics.lineStyle(1, bgColor, 0,true);
if (way==1) {
graphics.moveTo(size/2, size/2-size/4);
graphics.lineTo(size/2+size/4,size/2+size/4);
graphics.lineTo(size/2-size/4,size/2+size/4);
graphics.lineTo(size/2, size/2-size/4);
} else if (way==2) {
graphics.moveTo(size/2, size/2+size/4);
graphics.lineTo(size/2+size/4,size/2-size/4);
graphics.lineTo(size/2-size/4,size/2-size/4);
graphics.lineTo(size/2, size/2+size/4);
} else if (way==3) {
graphics.moveTo(size/2-size/4, size/2);
graphics.lineTo(size/2+size/4,size/2-size/4);
graphics.lineTo(size/2+size/4,size/2+size/4);
graphics.lineTo(size/2-size/4, size/2);
} else if (way==4) {
graphics.moveTo(size/2+size/4, size/2);
graphics.lineTo(size/2-size/4,size/2-size/4);
graphics.lineTo(size/2-size/4,size/2+size/4);
graphics.lineTo(size/2+size/4, size/2);
}
}
}
发表评论
-
haXe是什么?
2016-01-04 10:50 1022haXe是什么? haXe是一种编程语言,官方网站在 ... -
用EA类图生成AS3代码
2008-10-15 16:18 2691EA(Enterprise Architect)是支持多种流 ... -
变形实例-source
2008-10-15 12:46 1511涂抹原理 橡皮擦原理 import flash.geom.P ... -
actionScript 3.0 图片裁剪及旋转
2008-10-10 12:54 5900package com.wdxc { /** ... -
Flash(AS3)读取Excel文件
2008-10-09 13:29 5119var excelXml:XML; var loader=ne ... -
AS3 Loading的制作方法
2008-10-09 13:28 6041AS2的时候做LOADING有很多种方法,做起来也得心应手可是 ... -
让"Flash" 写文件(AS3)
2008-09-11 16:23 1768目前,出于安全考虑Flash不支持写文件的操作,在AS3的A ... -
AS3 中的 拖动 及 碰撞 检测
2008-09-11 16:11 2915没有press和release事件 hitTest()被分尸 ... -
As和js通信问题完全解析(解决addcallback失效的问题)
2008-09-11 16:10 3620as和js通信最早用的是fscommand,这个我就不说了,老 ... -
Flash CS3制作Fla形式的组件
2008-06-16 14:45 1350本文为大家介绍如何制作Flash CS3中的[*.fla]形 ... -
AS3图像处理之剪裁、动态选取
2008-06-15 23:25 2226和师傅写C#写的思维混乱,方法变量几乎第一反应就是大写,习惯都 ... -
从界面入手 划分类
2008-06-15 19:25 1250如何将一个项目细化成各个类呢? 1 从一个项目的界面入手,按照 ... -
AS3-DisplayEffect组件
2008-06-14 20:40 2035[AS3]DisplayEffect组件【组件版本】:0.5【 ... -
KTooltip 工具提示组件
2008-06-14 20:38 1009发布一个小工具KTooltip 。这是0.9beta版,出发日 ... -
AS3.0写的一个滚动条【缓动效果】
2008-06-13 16:10 6374package { import flash.d ... -
自定义滚动条类
2008-06-13 16:01 2063在平常的开发中,经常需要用到滚动条,今天将滚动条类整理了下,有 ... -
AS3加载机制
2008-06-13 15:03 2178摸了好一阵子,才弄明白AS3.0的加载机制.还是坚持自己的原则 ... -
写了一个Flash的Transition
2008-06-11 10:36 1721写了一个Flash的Transition package { ... -
JavaScript与ActionScript函数相互调用
2008-06-06 15:07 22521、在JavaScript中调用Flex( ... -
传参之事件代理
2008-06-05 10:23 1083有时候我们在调用事件侦听器的时候,需要给它传进相应的参数,这个 ...
相关推荐
自定义滚动条。textfild控件。as3 textfild动态文本滚动条模型
AS3滚动条,可自定义横向还是竖向,带源码
用flash的as3写的横向和纵向的滚动条。有源码
ActionScript 3动态文本滚动条模型 大家一起学习
AS3 滚动条 源码 横向和竖向滚动
从最初下载的火山动态文本滚动条V5到现在的版本,优化了很多,也改了些小bug,目前版本不能说非常完美但也自认为很棒了。 今天我就将多年的成果贡献出来,让大家借鉴或批评^_^,今天我还完善了一下,以后我还会继续...
类-结-构(一部分没有在下表列出) xml: XMLLoader.as ---------------------- 加载xml的类 xmlToArray.as ---------------------- xml转换Array util: ArrayUtil.as ---------------------- 数组辅助功能 ...
NULL 博文链接:https://as3.iteye.com/blog/1047420
AS3.0 TLFTextField 最新的组件库 以往的有BUG,这个可是最新的哦 package { import fl.controls.UIScrollBar; import fl.text.TLFTextField; import flash.events.Event; import flashx.textLayout....
sPart UI组件库,一个用AS3.0 编写的轻量级开源 flash UI组件库,它旨在:让用户第一时间、以最快速度搭建一个flash游戏、应用所需要的前端界面。也许它并不如其他同类UI组件那样功能强大,但它的体积小,使用方便,...
9、不要使用多重继承并尽量减少一个类中封装过多的功能。 1.5 MFC中常用类,宏,函数介绍 常用类 CRect:用来表示矩形的类,拥有四个成员变量:top left bottom right。分别表是左上角和右下角的坐标。可以通过以下...
CStatic 用于标识另一个控件或给用户提供消息的简单文本框 afxwin.h CStatusBar afxext.h CStatusBarCtrl 提供一个层次窗口,通常放于父窗口的底部,用于显示关于应用程序的状态信息 afxcmn.h CStdioFile afx.h ...
建立一个应用程序 ................................................................................................................................ 17 应用程序的关闭 .......................................
简单的滚动条“无箭头” 新的小部件即将推出 屏幕截图: 使用AwesomeTkinter的应用程序示例: 安装: python pip install awesometkinter在Windows上python pip install awesometkinter python3 pip install ...
《C#全能速查宝典》共分为8章,分别介绍了C#语言基础、Windows窗体及常用控件、Windows高级控件、控件公共属性、方法及事件、数据库开发、文件、数据流与注册表...,共包含562个C#编程中常用的属性、方法、类和各种技术...
3. Here is the handler for WM_VSCROLL. void CCharlesDlg::OnVScroll(UINT nSBCode,UINT nPos,CScrollBar* pScrollBar) { //TODO:Add your message handler code here and/or call default int nDelta; int ...
滚动条不会重绘,但是如果将鼠标悬停在滚动条上,滚动条会重新出现。 提交时间 2009-05-04 12:10:54 经过 等级 初学者 用户评分 4.8(19个地球仪,来自4个用户) 兼容性 VB 5.0,VB 6.0 类别 世界 存档文件 ...
VF辅导:内存变量操作命令及文件操作命令 来源:学生大 2007年11月01日 11:35 一.内存变量操作命令: 1.... 格式:display memory ... 功能:执行该命令,将文本文件的内容输出到屏幕,窗口,打印机或一个文本文件中.