Load Multiple Dynamic Text Files in Different frames on Maintimeline
Hello!
I have managed to load an external text file in one place one the maintimeline. I would like to do the same thing on other frames. When I go to duplicate the same thing that I did on the first one I get a duplicate textReq request. Do I need to give the textReq a more specific name for each section? When I did this the movie wouldn't even recognize and of the code that was working before.
Can anyone help me with this code? Thanks in advance ![]()
I am attaching link so you can see sections I am talking about. Also you will notice that the swf file I loaded won't go away. That's another problem...ugh.
Here is link:
http://www.sandraschmitt.com/coclico/index100.html
Here is code on maintimeline:
stop();
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
function startLoad() {
var swfLoader:Loader = new Loader();
var swfRequest:URLRequest = new URLRequest("endlessCoclico3.swf");
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
swfLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
swfLoader.load(swfRequest);
}
function onCompleteHandler(loadEvent:Event) {
addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(swfProgress:ProgressEvent) {
var percent:Number = swfProgress.bytesLoaded/swfProgress.bytesTotal;
trace(percent);
}
startLoad();
//handle events for buttons...
collections.addEventListener(MouseEvent.CLICK, clickSection);
raison.addEventListener(MouseEvent.CLICK, clickSection);
stores.addEventListener(MouseEvent.CLICK, clickSection);
news.addEventListener(MouseEvent.CLICK, clickSection);
contact.addEventListener(MouseEvent.CLICK, clickSection);
home.addEventListener(MouseEvent.CLICK, clickSection);
function clickSection(evtObj:MouseEvent) {
//trace shows what's happening... in the output window
trace("The "+evtObj.target.name+" button was clicked!");
//go to the section clicked on...
gotoAndStop(evtObj.target.name);
}
Here is code on actual frame where the dynamic text is working:
//Loaded exteranl text fields
var textLoader:URLLoader = new URLLoader();
var textReq:URLRequest = new URLRequest("text_philosophy.txt");
function textLoaded(event:Event):void {
philosophy_txt.text = textLoader.data;
}
textLoader.load(textReq);
textLoader.addEventListener(Event.COMPLETE, textLoaded);