scrollText
♥0 |
Line 44 |
Modified 2012-04-26 22:45:07 |
MIT License
archived:2017-03-30 02:54:37
ActionScript3 source code
/**
* Copyright tepe ( http://wonderfl.net/user/tepe )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/oeIQ
*/
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var st:scrollText = new scrollText();
var tf:TextField = new TextField();
tf.htmlText = '<font color="#00ee00">'+"aaaaa"+'</font>';
st.setTextField(tf);
st.x =100;
addChild(st);
//addChild(tf);
}
}
}
//-------------------
import flash.display.*;
import flash.events.*;
import flash.text.*;
class scrollText extends Sprite{
private var m:Sprite = new Sprite();
private var tf:TextField = new TextField();
public function scrollText(){
m.graphics.beginFill(0xff0000,1);
m.graphics.drawRect(40,0,100,20);
m.graphics.endFill();
addChild(m);
tf.mask = m;
addEventListener(Event.ENTER_FRAME,onEnter);
}
public function setTextField(t:TextField,w:Number=100,h:Number=20):void{
tf=t;
tf.mask = m;
//tf.selectable = false;
tf.multiline = false;
//tf.width=w;
//tf.height=h;
addChild(tf);
m.graphics.clear();
m.graphics.beginFill(0xff0000);
m.graphics.drawRect(0,0,w,h);
m.graphics.endFill();
}
private function onEnter(e:Event):void{
tf.x--;
if(tf.x+tf.width < 0)tf.x = m.width;
//if(50 < scrTxt.x)scrTxt.width = 100-scrTxt.x;
}
}