FORUMS: list search recent posts

Loading external text files using variables

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Fred Shakeshaft
Loading external text files using variables
on Aug 22, 2012 at 3:10:45 pm

I am trying to load txt files that are named after buttons. During a MOUSE OVER the text files should be loaded into a dynamitic text file.

Here is my code:
var TxtSrc:String

vTab_mc.addEventListener(MouseEvent.MOUSE_OVER, mouse_over);
function mouse_over(event:MouseEvent):void {
var TxtSrc:String = event.target.name+ ".txt";
}

vTab_mc.addEventListener(MouseEvent.MOUSE_OVER, Load_text);

function Load_text(event:MouseEvent):void {
var loader:URLLoader = new URLLoader(new URLRequest (TxtSrc ));
loader.addEventListener (Event.COMPLETE, processTXT);

function processTXT (event:Event):void {
var loadedText:URLLoader = URLLoader (event.target);
vdes_txt.text = loadedText.data;
}
}

I get a "TypeError: Error #2007: Parameter url must be non-null."

Any help wouldbe greatly appericated.

Fred


Return to posts index

Fred Shakeshaft
Re: Loading external text files using variables
on Aug 22, 2012 at 3:55:11 pm

I had typo in first post: it suppose to load in a dynamic text field. Not a file...

Any way when I preview the swf its fine until I roll over a button then I get the “Error #2007: Parameter url must be non-null."

Right now I have only 6 buttons so I could do the urlload for each roll over but I hope to add move in the future and using button names as variable would make it much easer to update


Return to posts index

demetri tashie
Re: Loading external text files using variables
on Aug 22, 2012 at 4:04:18 pm

try this. i added code for 2 buttons, for 2 .txt files

var TxtSrc:String
var loader:URLLoader = new URLLoader();

vTab_mc.addEventListener(MouseEvent.MOUSE_OVER, mouse_over); // first button
vTab_2_mc.addEventListener(MouseEvent.MOUSE_OVER, mouse_over); // second button
function mouse_over(e:MouseEvent):void {
TxtSrc = e.target.name+ ".txt";

loader.load(new URLRequest(TxtSrc));

loader.addEventListener (Event.COMPLETE, processTXT);
}

function processTXT (e:Event):void {
vdes_txt.text = e.target.data;
}


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]