home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PCGUIA 2010 Software/Programs
/
PCGuia_programas.iso
/
Swf
/
Completos.swf
/
scripts
/
FTicker.as
< prev
next >
Wrap
Text File
|
2010-02-24
|
7KB
|
297 lines
function FTickerClass()
{
ASBroadcaster.initialize(this);
this.originalWidth = 180;
this.originalHeight = 20;
this.currentMessage = 0;
if(!this.tickerMessages)
{
this.tickerMessages = new Array();
}
this.init();
}
FTickerClass.prototype = new MovieClip();
FTickerClass.prototype.init = function()
{
this.makeText();
this.preventScale();
if(this.tickerMessages[this.currentMessage] != undefined)
{
this.setText(this.currentMessage);
}
this.formatText();
this.scrollText();
};
FTickerClass.prototype.makeText = function()
{
this.attachMovie("tickertxt_mc","tickertxt_mc",1);
tickertxt_mc._width = this.originalWidth;
tickertxt_mc._height = this.originalHeight;
};
FTickerClass.prototype.formatText = function()
{
this.tickertxt_mc.ticker.autosize = true;
this.tickerFormat = new TextFormat();
with(this.tickerFormat)
{
selectable = false;
size = this.tickerSize;
color = this.tickerColor;
}
this.tickertxt_mc.ticker.setTextFormat(this.tickerFormat);
};
FTickerClass.prototype.positionText = function()
{
if(this.scrollDirection == "left")
{
this.tickertxt_mc._x = this.tickermask_mc._width;
}
else
{
this.tickertxt_mc._x = this.tickertxt_mc._width * -1;
}
this.broadcast();
switch(this.textAlign)
{
case "top":
this.tickertxt_mc._y = 0;
break;
case "middle":
this.tickertxt_mc._y = (this.tickermask_mc._height - this.tickertxt_mc._height) / 2;
break;
case "bottom":
this.tickertxt_mc._y = this.tickermask_mc._height - this.tickertxt_mc._height;
}
this.tickertxt_mc.setMask(this.tickermask_mc);
};
FTickerClass.prototype.scrollText = function()
{
this.positionText();
this.onEnterFrame = function()
{
if(this.scrollDirection == "left")
{
if(this.tickertxt_mc._x > this.tickertxt_mc._width * -1)
{
if(!this.pause)
{
this.tickertxt_mc._x -= this.scrollSpeed;
}
}
else
{
this.nextMessage();
}
}
else if(this.tickertxt_mc._x < this.tickermask_mc._width)
{
if(!this.pause)
{
this.tickertxt_mc._x += this.scrollSpeed;
}
}
else
{
this.nextMessage();
}
if(this.pauseScroll)
{
this.checkPause();
}
};
};
FTickerClass.prototype.checkPause = function()
{
if(this.tickertxt_mc.hitTest(_root._xmouse,_root._ymouse,false))
{
this.pause = true;
}
else
{
this.pause = false;
}
};
FTickerClass.prototype.nextMessage = function()
{
if(this.currentMessage < this.tickerMessages.length - 1)
{
this.currentMessage = this.currentMessage + 1;
}
else
{
this.currentMessage = 0;
}
this.setText(this.currentMessage);
this.formatText();
this.positionText();
};
FTickerClass.prototype.broadcast = function()
{
this.currentMessage;
this.broadcastMessage("onScroll",this.currentMessage);
};
FTickerClass.prototype.preventScale = function()
{
var _loc3_ = this._width / (this.originalWidth / 2);
var _loc2_ = this._height / this.originalHeight;
this.tickertxt_mc._width /= _loc3_;
this.tickertxt_mc._height /= _loc2_;
};
FTickerClass.prototype.setText = function(message)
{
this.tickertxt_mc.ticker.htmlText = this.tickerMessages[message];
};
FTickerClass.prototype.getText = function()
{
return this.tickerMessages[this.currentMessage];
};
FTickerClass.prototype.setSpeed = function(speed)
{
this.scrollSpeed = speed;
};
FTickerClass.prototype.getSpeed = function()
{
return this.scrollSpeed;
};
FTickerClass.prototype.setDirection = function(direction)
{
this.scrollDirection = direction;
};
FTickerClass.prototype.getDirection = function()
{
return this.scrollDirection;
};
FTickerClass.prototype.getQueue = function()
{
var _loc2_ = this.currentMessage;
var _loc4_ = new Array();
var _loc3_ = 0;
while(_loc3_ < this.tickerMessages.length)
{
_loc4_.push(this.tickerMessages[_loc2_]);
if(_loc2_ < this.tickerMessages.length - 1)
{
_loc2_ = _loc2_ + 1;
}
else
{
_loc2_ = 0;
}
_loc3_ = _loc3_ + 1;
}
return _loc4_;
};
FTickerClass.prototype.getMessageID = function()
{
return this.currentMessage;
};
FTickerClass.prototype.setPause = function(bool)
{
if(bool)
{
this.pauseScroll = true;
}
else
{
this.pauseScroll = false;
}
};
FTickerClass.prototype.getPause = function()
{
return this.pauseScroll;
};
FTickerClass.prototype.setAlign = function(alignment)
{
this.textAlign = alignment;
switch(this.textAlign)
{
case "top":
this.tickertxt_mc._y = 0;
break;
case "middle":
this.tickertxt_mc._y = (this.tickermask_mc._height - this.tickertxt_mc._height) / 2;
break;
case "bottom":
this.tickertxt_mc._y = this.tickermask_mc._height - this.tickertxt_mc._height;
}
};
FTickerClass.prototype.getAlign = function()
{
return this.textAlign;
};
FTickerClass.prototype.setColor = function(textcolor)
{
this.tickerColor = textcolor;
this.formatText();
};
FTickerClass.prototype.getColor = function()
{
return this.tickerColor;
};
FTickerClass.prototype.setSize = function(size)
{
this.tickerSize = size;
this.formatText();
this.setAlign(this.textAlign);
};
FTickerClass.prototype.getSize = function()
{
return this.tickerSize;
};
FTickerClass.prototype.addMessage = function(newtext)
{
this.tickerMessages.push(newtext);
this.setText(this.currentMessage);
this.formatText();
};
FTickerClass.prototype.removeMessage = function(textid)
{
if(typeof textid == "number")
{
this.tickerMessages.splice(textid,1);
}
else
{
var _loc2_ = 0;
while(_loc2_ < this.tickerMessages.length)
{
if(this.tickerMessages[_loc2_] == textid)
{
this.tickerMessages.splice(_loc2_,1);
}
_loc2_ = _loc2_ + 1;
}
}
};
FTickerClass.prototype.switchMessage = function(from, to)
{
if(typeof from == "number")
{
var _loc4_ = this.tickerMessages[from];
var _loc3_ = this.tickerMessages[to];
}
else
{
var _loc2_ = 0;
while(_loc2_ < this.tickerMessages.length)
{
if(this.tickerMessages[_loc2_] == from)
{
_loc4_ = _loc2_;
}
if(this.tickerMessages[_loc2_] == to)
{
_loc3_ = _loc2_;
}
_loc2_ = _loc2_ + 1;
}
this.tickerMessages[_loc4_] = to;
this.tickerMessages[_loc3_] = from;
}
this.tickerMessages[from] = _loc3_;
this.tickerMessages[to] = _loc4_;
this.setText(this.currentMessage);
this.formatText();
};
Object.registerClass("FTicker",FTickerClass);