Dynamic | Data This class file is placed in the same directory as tween
This allows you to change the component with the Tween class
You don't have to write the gradient function yourself.
Usage:
Same as tween.
Such as:
Import Mx.transitions.fanflash_Tween;
Import Mx.transitions.easing.Strong;
var fan = new Fanflash_tween (A, test, strong.easeout, 6, true);
function test (t:number) {
_root.txt_txt.setsize (_root.txt_txt._width, T);
To first define a function, there is a parameter, this parameter is used to change (when the second parameter is a function, the first parameter will be useless, so the random write can), just because of the need to change, the inadequacies must have, together with the use of it
If the second argument is a character, it's the same as the usual tween class.
Example:
Click to browse the file
class file (suffix changed to AS):
Fanflash_tween.as
Import Mx.transitions.BroadcasterMX;
Import Mx.transitions.OnEnterFrameBeacon;
Class Mx.transitions.fanflash_Tween {
static var __initbeacon = Onenterframebeacon.init ();
static var __initbroadcaster = Broadcastermx.initialize (Fanflash_tween.prototype, true);
public Var Isplaying:boolean;
public Var addlistener:function;
public Var removelistener:function;
public Var broadcastmessage:function;
public Var Obj:object;
public Var prop:string;
var func:function = Function (T, B, C, D) {
return c*t/d+b;
};
public Var Begin:number;
public Var Change:number;
public Var Useseconds:boolean;
public Var Prevtime:number;
public Var Prevpos:number;
public Var Looping:boolean;
public Var Forp:boolean;
public Var tf:function;
private Var _listeners:array;
private Var _duration:number;
private Var _time:number;
private Var _pos:number;
private Var _fps:number;
private Var _position:number;
private Var _starttime:number;
private Var _intervalid:number;
private Var _finish:number;
function set Time (T:number): Void {
This.prevtime = This._time;
if (t>this.duration) {
if (this.looping) {
This.rewind (t-this._duration);
This.update ();
This.broadcastmessage ("onmotionlooped", this);
} else {
if (this.useseconds) {
This._time = this._duration;
This.update ();
}
This.stop ();
This.broadcastmessage ("onmotionfinished", this);
}
else if (t<0) {
This.rewind ();
This.update ();
} else {
This._time = t;
This.update ();
}
}
function Get Time (): number {
return this._time;
}
function set Duration (D:number): Void {
This._duration = (d = = NULL | | d<=0)? _global. Infinity:d;
}
function get Duration (): number {
return this._duration;
}
function set FPS (fps:number): Void {
var oldisplaying = this.isplaying;
This.stopenterframe ();
This._fps = fps;
if (oldisplaying) {
This.startenterframe ();
}
}
function Get FPS (): number {
return this._fps;
}
function set Position (P:number): Void {
if (This.forp) {
This.setposition (P);
} else {
This.setfunction (P);
}
}
function SetPosition (p:number): Void {
This.prevpos = This._pos;
This.obj[this.prop] = this._pos=p;
This.broadcastmessage ("onmotionchanged", this, this._pos);
Updateafterevent ();
}
function Setfunction (p:number): Void {
This.prevpos = This._pos;
THIS.TF (P);
This.broadcastmessage ("onmotionchanged", this, this._pos);
Updateafterevent ();
}
function Get Position (): number {
return This.getposition ();
}
function GetPosition (t:number): number {
if (t = = undefined) {
t = this._time;
}
Return This.func (t, This.begin, This.change, this._duration);
}
function set Finish (F:number): Void {
This.change = F-this.begin;
}
function Get Finish (): number {
return this.begin+this.change;
}
function Fanflash_tween (obj, prop, Func, Begin, Finish, duration, useseconds) {
Onenterframebeacon.init ();
if (!arguments.length) {
Return
}
This.obj = obj;
if (typeof (prop) = = "string") {
This.prop = prop;
This.forp = true;
} else {
THIS.TF = prop;
This.forp = false;
}
This.begin = begin;
This.position = begin;
this.duration = Duration;
This.useseconds = Useseconds;
if (func) {
This.func = func;
}
This.finish = finish;
This._listeners = [];
This.addlistener (this);
This.start ();
}
function Continueto (Finish:number, Duration:number): Void {
This.begin = this.position;
This.finish = finish;
if (duration!= undefined) {
this.duration = Duration;
}
This.start ();
}
function Yoyo (): Void {
This.continueto (This.begin, this.time);
}
function Startenterframe (): Void {
if (This._fps = = undefined) {
_global. Movieclip.addlistener (this);
} else {
This._intervalid = SetInterval (This, "Onenterframe", 1000/this._fps);
}
This.isplaying = true;
}
function Stopenterframe (): Void {
if (This._fps = = undefined) {
_global. Movieclip.removelistener (this);
} else {
Clearinterval (This._intervalid);
}
This.isplaying = false;
}
function Start (): Void {
This.rewind ();
This.startenterframe ();
This.broadcastmessage ("onmotionstarted", this);
}
function Stop (): Void {
This.stopenterframe ();
This.broadcastmessage ("onmotionstopped", this);
}
Function Resume (): Void {
This.fixtime ();
This.startenterframe ();
This.broadcastmessage ("onmotionresumed", this);
}
Function Rewind (t): Void {
This._time = (t = = undefined)? 0:t;
This.fixtime ();
This.update ();
}
function Fforward (): Void {
This.time = this._duration;
This.fixtime ();
}
function NextFrame (): Void {
if (this.useseconds) {
This.time = (Gettimer ()-this._starttime)/1000;
} else {
This.time = this._time+1;
}
}
function Onenterframe (): Void {
This.nextframe ();
}
function Prevframe (): Void {
if (!this.useseconds) {
This.time = this._time-1;
}
}
function toString (): String {
Return "[Fanflash_tween]";
}
Private Function Fixtime (): Void {
if (this.useseconds) {
This._starttime = Gettimer ()-this._time*1000;
}
}
Private Function Update (): Void {
This.position = This.getposition (this._time);
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.