PDA

View Full Version : TypeError: Error #2007: Parameter text must be non-null.


fungusmungus07
08-27-2009, 10:18 PM
Hello,

I am a newbie to this forum and have a frustrating question that I cannot seem to figure out. Been working on small school project doing a simple slideshow. I cannot figure out why is it that on some computers/browsers. I am not a AS whiz so if someone can possibly point out the line of code that is causing this error. I keep getting and on some I don't get the following:

TypeError: Error #2007: Parameter text must be non-null.
at flash.text::TextField/set text()
at code::Slideshow/dysplayText()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.transitions::Tween/set time()
at fl.transitions::Tween/nextFrame()
at fl.transitions::Tween/onEnterFrame()

Here is the .as for it.

package code{
import flash.display.*;
import flash.events.*;
import flash.xml.*;
import flash.net.*;
import flash.utils.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.text.*;
public class Slideshow extends MovieClip {

public var xmlPath:String="images.xml"; //Path to a xml file containing data about images
public var imageData:XMLList; //Data about images, pulled from XML file
public var images:Array=new Array; //Array for storing pointer to a specific image
public var currentActive:int; // indicates which image is currently active
public var previousActive:int; // indicates which image was previously active
public var textArea:ImgInfo; // Text for description of images
public var imagesLoaded:int; // indicates how much images are loaded
public var imagesLoadedText:ImgInfo; // text for indicating how much images are loaded aka preloader text

public function Slideshow() { //constructor
loadXml(); //Load data from XML
textArea=new ImgInfo ; // Creating object for dysplaying image description
imagesLoadedText=new ImgInfo ; // Creating object for dysplaying preloader text

//setting default values
currentActive=0;
previousActive=0;
imagesLoaded=0;

}
public function loadXml() {
var xmlLoader:URLLoader=new URLLoader;
xmlLoader.load(new URLRequest(xmlPath));
xmlLoader.addEventListener(Event.COMPLETE,onXmlLoa d);
}
public function onXmlLoad(e:Event):void {
var xmlData=new XML(e.target.data);
imageData=new XMLList(xmlData);

addChild(imagesLoadedText); //show preloader text
updateImagesLoadedText(0); //writes Loading images: 0/xx loaded where xx is total number of images

loadImage(0); //XML data is loaded, so now we are loading first image

}
public function loadImage(i) {
images[i]=new Loader();
images[i].load(new URLRequest(imageData.images.image.path[i]));
addChild(images[i]);
images[i].alpha=0;
images[i].contentLoaderInfo.addEventListener(Event.COMPLETE ,waitAllImages);
}
public function waitAllImages(e:Event):void {
images[imagesLoaded].contentLoaderInfo.removeEventListener(Event.COMPL ETE,waitAllImages);

imagesLoaded++; //another image is loaded
updateImagesLoadedText(imagesLoaded);

if (imagesLoaded == imageData.images.image.length()) { //if true, all images are loaded
var tween=new Tween(imagesLoadedText,"alpha",Regular.easeOut,1,0 ,.5,true); //fadeout preload text

addChild(textArea); // showing text for image description
textArea.y=- textArea.height; // placing it above image

var timer:Timer=new Timer(imageData.duration_sec * 1000); // timer which will change image every xx seconds
timer.addEventListener(TimerEvent.TIMER,changeImg) ;
timer.start();

dysplayImage(0); // show first image

} else { // if not true load next image
loadImage(imagesLoaded);
}
}
public function changeImg(e:TimerEvent):void {
dysplayImage(currentActive); //loads next image
}
public function dysplayImage(number) { //displays image
setChildIndex(images[number],imageData.images.image.length() ); //bring image that needs to be displayed in front of others
var tween=new Tween(images[number],"alpha",Regular.easeIn,0,1,.8,true); // fade in image
tween.addEventListener(TweenEvent.MOTION_FINISH,dy splayText); // after fading in is complete slide image description box

// calculating which image needs to be loaded next
previousActive=currentActive;
currentActive=number;
if (currentActive == imageData.images.image.length() - 1) {
currentActive=0;
} else {
currentActive++;
}
// end of calculating which image needs to be loaded next
}
public function dysplayText(e:TweenEvent):void {
if (imageData.images.image.text[previousActive] != "") { // if not true, don't dysplay text at all
textArea.imageInfo.text=imageData.images.image.tex t[previousActive];
textArea.background.width=textArea.imageInfo.width + 10;
textArea.background.alpha=.6;
textArea.x=stage.stageWidth / 2 - textArea.width / 2;

var tween=new Tween(textArea,"y",Regular.easeOut,textArea.y,0,.5 ,true); //slides down the description text box

var timer=new Timer((imageData.duration_sec - 1) * 1000,1); // slides up the description text box
timer.addEventListener(TimerEvent.TIMER,undysplayT ext);
timer.start();
}
}
public function undysplayText(e:TimerEvent):void {
var tween=new Tween(textArea,"y",Regular.easeOut,0,- textArea.height,.5,true); // slides up the description text box
}
public function updateImagesLoadedText(number) {
imagesLoadedText.imageInfo.text="Loading images: " + number + "/" + imageData.images.image.length()+" loaded";
imagesLoadedText.background.width=imagesLoadedText .imageInfo.width + 10;
imagesLoadedText.background.alpha=.3;
imagesLoadedText.y=stage.stageHeight / 2 - imagesLoadedText.height / 2;
imagesLoadedText.x=stage.stageWidth / 2 - imagesLoadedText.width / 2;

}
}
}

Any help or advice will be much appreciated.

Thanks!!!