HI guys,
I have a problem with this TextSlider class.
I got an error saying that the slider is null and I can’t find the problem.
Here is the class file or if you are lazy to go to the site and download, I have also attach the class file with this post.
While my code is (which I copied from their example);
import com.flashandmath.dg.text.TextSlicer;
import fl.transitions.TweenEvent;
import fl.transitions.Tween;
import fl.transitions.easing.*;
var ldr:URLLoader = new URLLoader();
var slicer:TextSlicer
var paramObj:Object;
var paramTween:Tween;
var textBoard:Sprite;
var fileContent:String;
var isMoving:Boolean=false;
var curCont:int=0;
txtOutput.wordWrap=true;
txtOutput.mouseEnabled=false;
ldr.addEventListener(Event.COMPLETE, loadComplete);
ldr.addEventListener(IOErrorEvent.IO_ERROR, loadError);
ldr.load(new URLRequest("home.txt"));
function loadComplete(e:Event):void {
fileContent = ldr.data;
txtOutput.text="Click anywhere on the Stage to display or repeat text animation.";
ldr.removeEventListener(Event.COMPLETE, loadComplete);
ldr.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
init();
}
function loadError(e:IOErrorEvent):void {
txtOutput.text = "Error loading an external file. The server may be busy. Try refreshing the page.";
}
function init():void {
textBoard = new Sprite();
textBoard.x = 40;
textBoard.y = 60;
this.addChild(textBoard);
slicer = new TextSlicer;
slicer.fontSize = 24;
slicer.fontColor = 0x000000;
slicer.numLinesPerSlice = 1;
slicer.vertPadding=2;
slicer.importText(fileContent, "textLayout");
for (var i:int = 0; i < slicer.numContainers; i++) {
textBoard.addChild(slicer.containers*);
slicer.containers*.x = 0;
slicer.containers*.y = i*slicer.slatHeight;
slicer.containers*.alpha = 0;
}
stage.addEventListener(MouseEvent.CLICK, onClick);
paramObj = {t:0};
}
function onClick(evt:MouseEvent):void {
if(isMoving){return;}
isMoving=true;
curCont=0;
for (var i:int = 0; i < slicer.numContainers; i++) {
slicer.containers*.alpha = 0;
}
paramTween = new Tween(paramObj, "t", Regular.easeOut, 0, 1, 24);
paramTween.addEventListener(TweenEvent.MOTION_CHANGE, onMotionChange);
paramTween.addEventListener(TweenEvent.MOTION_FINISH, onMotionFinish);
}
function onMotionChange(evt:TweenEvent):void {
if(curCont < slicer.numContainers){
slicer.containers[curCont].alpha = paramObj.t*paramObj.t*paramObj.t*paramObj.t;
}
}
function onMotionFinish(evt:TweenEvent):void {
paramTween.removeEventListener(TweenEvent.MOTION_CHANGE, onMotionChange);
paramTween.removeEventListener(TweenEvent.MOTION_FINISH, onMotionFinish);
curCont+=1;
if(curCont==slicer.numContainers){
isMoving=false;
} else {
paramTween = new Tween(paramObj, "t", Regular.easeOut, 0, 1, 24);
paramTween.addEventListener(TweenEvent.MOTION_CHANGE, onMotionChange);
paramTween.addEventListener(TweenEvent.MOTION_FINISH, onMotionFinish);
}
}
I am not really good in reading classes. Can anyone point out where I d wrong?
I have a dynamic textfield with instance name ‘txtOutput’.
Thanks in advanced.