5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:山东
性别:先生
最后登录:2011-01-05
http://xbzg.5d.cn/
专注于Flash+FMS开发...通过Google搜索西部之光Software
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/06/09 | 滚动字幕组件用到的类
类别(Flash)
|
评论
(1)
|
阅读(262)
|
发表于 11:04
//****************************************************************************
//Copyright (C) 2005 西部之光Software. All Rights Reserved.
//This is a product to study how to build a V2 Component
//****************************************************************************
import mx.core.UIObject;
import FontName;
class Roll_title extends UIObject {
private var containter:MovieClip;
public var mask:MovieClip;
private var rect:Boolean;
private var Point:MovieClip;
private var txt:String;
private var _txtcolor:Number;
public var _rectcolor:Number;
public var _font:String;
private var dir:String;
private var _speed:String;
private var _maskWidth:String;
private var len:Number;
private var myformat:TextFormat;
private var myArray:Array;
private var font_array:Array;
private var i:Number;
[Inspectable(defaultvalue="组件名称:滚动字幕。作者:西部秋虫。来自:西部之光Software。主页:http://home.cfe21.com/xbzg")]
public function set 文本(Text:String):Void {
txt = Text;
}
public function get 文本():String {
return txt;
}
[Inspectable(enumeration="自右向左,自左向右,自上向下,自下向上"defaultvalue="自右向左")]
function set 滚动方向(val:String) {
this.dir = val;
invalidate();
}
function get 滚动方向():String {
return dir;
}
[Inspectable(enumeration="是,否"defaultvalue="是")]
function set 边框显示(val:Boolean) {
rect = val;
invalidate();
}
function get 边框显示():Boolean {
return rect;
}
[Inspectable(defaultvalue="#000000")]
function set 边框颜色(val:Number):Color {
_rectcolor = val;
invalidate();
}
function get 边框颜色():Number {
return _rectcolor;
}
//设置字体
[Inspectable(type="Font Name"defaultvalue="Arial Black")]
function set 字体(val) {
_font = val;
invalidate();
}
function get 字体():String {
return _font;
}
[Inspectable(defaultvalue="#000000")]
function set 文字颜色(val:Number):Color {
_txtcolor = val;
invalidate();
}
function get 文字颜色():Number {
return _txtcolor;
}
//设置速度
[Inspectable(enumeration="1,2,3,4,5"defaultvalue="1")]
function set 滚动速度(val:String):String {
_speed = val;
invalidate();
}
function get 滚动速度():String {
return _speed;
}
//设置遮罩长度
[Inspectable(enumeration="1,2,3,4,5"defaultvalue="1")]
function set 宽度(val:String):String {
_maskWidth = val;
invalidate();
}
function get 宽度():String {
return _maskWidth;
}
function Roll_title() {
trace("ok");
switch (this.dir) {
case "自右向左" :
trace("自右向左");
RToL();
break;
case "自左向右" :
LToR();
break;
case "自上向下" :
TToB();
break;
case "自下向上" :
BToT();
break;
default :
RToL();
}
}
function RToL():Void {
attachMovie("containter", "containter", 1);
trace(containter._x);
trace(containter._y);
containter.createTextField("otpt", 2, 0, 0, txt.length*11, 20);
containter.otpt.border = false;
containter.otpt.text = txt;
//设置字体颜色等
myformat = new TextFormat();
myformat.color = this._txtcolor;
myformat.bullet = false;
myformat.underline = false;
//字体只对英文有效
myformat.font = _font;
containter.otpt.setTextFormat(myformat);
attachMovie("mask", "mask", 3);
mask._height = containter._height;
mask._width = txt.length*2*_maskWidth;
mask._x = -mask._width/2;
mask._y = containter._y;
if (rect == "是") {
createEmptyMovieClip("Point", 4);
with (Point) {
moveTo(this.mask._x, this.mask._y);
lineStyle(1, this._rectcolor, 100);
lineTo(this.mask._x+this.mask._width, this.mask._y);
lineTo(this.mask._x+this.mask._width, this.mask._y+this.mask._height);
lineTo(this.mask._x, this.mask._y+this.mask._height);
lineTo(this.mask._x, this.mask._y);
}
}
//设置文字位置
containter._x = mask._x+mask._width;
containter.setMask(mask);
onEnterFrame = function () {
if (containter.hitTest(mask)) {
containter._x -= _speed;
} else {
containter._x = mask._x+mask._width;
}
};
}
//从左向右;
function LToR() {
//对txt进行反转
myArray = new Array();
len = txt.length;
for (var i = 0; i<=len; i++) {
myArray[i] = txt.substr(i, 1);
}
myArray.reverse();
txt = "";
for (var i = 0; i<=len; i++) {
txt += myArray[i];
}
trace(txt);
attachMovie("containter", "containter", 1);
trace(containter._x);
trace(containter._y);
containter.createTextField("otpt", 2, 0, 0, txt.length*11, 20);
containter.otpt.border = false;
containter.otpt.text = txt;
//设置字体颜色等
myformat = new TextFormat();
myformat.color = this._txtcolor;
myformat.bullet = false;
myformat.underline = false;
//字体只对英文有效
myformat.font = _font;
containter.otpt.setTextFormat(myformat);
attachMovie("mask", "mask", 3);
mask._height = containter._height;
mask._width = txt.length*2*_maskWidth;
mask._x = -mask._width/2;
mask._y = 0;
if (rect == "是") {
createEmptyMovieClip("Point", 4);
with (Point) {
moveTo(this.mask._x, this.mask._y);
lineStyle(1, this._rectcolor, 100);
lineTo(this.mask._x+this.mask._width, this.mask._y);
lineTo(this.mask._x+this.mask._width, this.mask._y+this.mask._height);
lineTo(this.mask._x, this.mask._y+this.mask._height);
lineTo(this.mask._x, this.mask._y);
}
}
//设置文字位置
containter._x = mask._x-containter._width;
containter.setMask(mask);
onEnterFrame = function () {
if (containter.hitTest(mask)) {
containter._x += _speed;
} else {
containter._x = mask._x-containter._width;
}
};
}
//从下向上;
function BToT() {
attachMovie("containter", "containter", 1);
trace(containter._x);
trace(containter._y);
containter.createTextField("otpt", 2, 0, 0, txt.length*2, 100);
containter.otpt.border = false;
containter.otpt.multiline = true;
containter.otpt.wordWrap = true;
containter.otpt.autoSize = true;
containter.otpt.text = txt;
//设置字体颜色等
myformat = new TextFormat();
myformat.color = this._txtcolor;
myformat.bullet = false;
myformat.underline = false;
//字体只对英文有效
myformat.font = _font;
containter.otpt.setTextFormat(myformat);
attachMovie("mask", "mask", 3);
mask._height = containter._height;
mask._width = containter._width*_maskWidth;
containter.otpt._width *= _maskWidth;
mask._x = containter._x;
mask._y = containter._y;
if (rect == "是") {
createEmptyMovieClip("Point", 4);
with (Point) {
moveTo(this.mask._x, this.mask._y);
lineStyle(1, this._rectcolor, 100);
lineTo(this.mask._x+this.mask._width, this.mask._y);
lineTo(this.mask._x+this.mask._width, this.mask._y+this.mask._height);
lineTo(this.mask._x, this.mask._y+this.mask._height);
lineTo(this.mask._x, this.mask._y);
}
}
//设置文字位置
containter._y = mask._y+mask._height;
containter.setMask(mask);
onEnterFrame = function () {
if (containter.hitTest(mask)) {
containter._y -= _speed;
} else {
containter._y = mask._y+mask._height;
}
};
}
//从上向下;
function TToB() {
//对txt进行反转
myArray = new Array();
len = txt.length;
for (var i = 0; i<=len; i++) {
myArray[i] = txt.substr(i, 1);
}
myArray.reverse();
txt = "";
for (var i = 0; i<=len; i++) {
txt += myArray[i];
}
attachMovie("containter", "containter", 1);
trace(containter._x);
trace(containter._y);
containter.createTextField("otpt", 2, 0, 0, txt.length*2, 100);
containter.otpt.border = false;
containter.otpt.multiline = true;
containter.otpt.wordWrap = true;
containter.otpt.autoSize = true;
containter.otpt.text = txt;
//设置字体颜色等
myformat = new TextFormat();
myformat.color = this._txtcolor;
myformat.bullet = false;
myformat.underline = false;
//字体只对英文有效
myformat.font = _font;
containter.otpt.setTextFormat(myformat);
attachMovie("mask", "mask", 3);
mask._height = containter._height;
mask._width = containter._width*_maskWidth;
containter.otpt._width *= _maskWidth;
mask._x = containter._x;
mask._y = containter._y;
if (rect == "是") {
createEmptyMovieClip("Point", 4);
with (Point) {
moveTo(this.mask._x, this.mask._y);
lineStyle(1, this._rectcolor, 100);
lineTo(this.mask._x+this.mask._width, this.mask._y);
lineTo(this.mask._x+this.mask._width, this.mask._y+this.mask._height);
lineTo(this.mask._x, this.mask._y+this.mask._height);
lineTo(this.mask._x, this.mask._y);
}
}
//设置文字位置
containter._y = mask._y-containter._height;
containter.setMask(mask);
onEnterFrame = function () {
if (containter.hitTest(mask)) {
containter._y += _speed;
} else {
containter._y = mask._y-containter._height;
}
};
}
}
0
评论
Comments
(
1
条)
[该闪就闪]
2005/7/1 21:45:43
沙发
看见题目时以为是用字串操作做的单行字幕呢。
原来是用遮照做,功能挺全的
<<
1
立即注册5D通行证
Join 5D!
发表留言
post
正在发送...
Send...
游客
Guest
用 户
Name
:
密 码
Password
:
内 容
Comment
:
主 页
Homepage
:
验 证
Verify
:
换一个
change the code
日志分类
首页
[186]
Flash
[84]
FMS
[41]
AIR
[2]
ASP
[11]
作品区
[12]
其他
[36]