View Full Version : displaying external .txt document.
tristaaaaaaaaa
10-02-2008, 04:37 AM
I have a document I am working on that is an portfolio. It is set up as a folder with different tabs. To get to tab to tab the project go to different frame labels. Anyway, I need to upload multiple external .txt documents, so that way the information in the project can easily be updated. Anyway, I can only get it to work on one frame label.
var content_req:URLRequest = new URLRequest("test.txt");
var content_ldr:URLLoader = new URLLoader(content_req);
content_ldr.addEventListener(Event.COMPLETE, onComplete);
function onComplete(event:Event):void
{
content_txt.text = event.target.data;
}
When I put this on a different frame label (changing the name of the text box created with the text tool and using a different text document) i get this error
1151: A conflict exists with definition content_req in namespace internal.
1151: A conflict exists with definition content_ldr in namespace internal.
1021: Duplicate function definition.
help please
rawmantick
10-02-2008, 04:58 AM
Variables and functions declared in one frame stay available in next frames. So you are trying to make function and variables with duplicated names, like redeclare them. It is forbidden in flash.
I suggest you to start normal coding instead of making code in frames.
tristaaaaaaaaa
10-02-2008, 05:45 AM
what do you mean tart new coding? what new code would i use?
rawmantick
10-02-2008, 11:45 AM
Writing code in frames is like for very very little tasks like clicking a button. No at least some serious developer will use writing code in frames...
You should use classes, where it's fully transparent to see which function goes to what sort of event... and such things.
Function actually corresponds to movie class associated with movie Clip, not to frame. So not to mix up you should use movie clips with classes associated. That's what i'm talking about.
Hope it makes sence...
Suggest you to lern Adobe Flex Builder, or FDT for eclipse, of AXDT, of FlashDevelop...
It will ease your development process on medium and big projects.
johanang
10-02-2008, 09:09 PM
I am currently working on a dynamic flash site where everything is brought in externally.
As soon as i have this script done you should be able to specify loading different text's for different frames..
Why is this different then your code: You will be able to put the action script on the first frame and the code will import dynamically different text files that can use html.
This will also apply css to your txt box for full control.
As soon as i get a answer from here or experts exchange on the variable required i will send to you.
please email me at johanang@hicommfcu.com if i do not respond within a day.
Mahalo
snickelfritz
10-02-2008, 10:23 PM
Use a switch or if statement in the frame1 button Click function to dynamically assign a new text document to the text field, based on the instance name of the button clicked.
ie: if you click button1, event.target.data = document1.txt; button2, event.target.data = document2.txt, and so forth.
lucidmedia
10-04-2008, 05:58 PM
my suggestion would be to put all of your content into a single structured XML file that gets downloaded on the first frame. The rest of your fields can pull content from the downloaded XML object when needed.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.