Flash help loading from textfile

  • Thread starter sid_galt
  • Start date
  • Tags
    Flash
In summary: Thanks for the clarification. [/edit]In summary, the person wants to be able to load text from a text file into a pop up window, and in this text they want there to be "links" that load other movies into other levels. There is not any functionality that will enable them to do this without some work, but they can do it if they really want to.
  • #1
sid_galt
502
1
So i have made a tutorial in which a popup window appears and draws content from a variable stored in a textfield. The base swf is at level 0. On that swf there appears an swf at level 1. and the popup window is at level 2.

What I want is that inside the content loaded from the textfile into the popup window, there should be links or buttons that open up a further swf file at level 2 or higher so as to not replace the previous two levels.

Is it possible to do so in Flash?
 
Technology news on Phys.org
  • #2
can anyone help please?
 
  • #3
Let me get a clear idea of what you want to do. You want to load text from a text file into a pop up window, and in this text you want there to be "links" that load other movies into other levels. There's not anyfunctionality that will enable you to do this without some work, but you can do it if you really want to.
The first thing you will need to do is establish a format for your text files. You should use XML because it's easy to parse. An example XML file is:
Code:
<root>
<links>
<link ref="myswf.swf" level="3">A link</link>
<link ref="myswf2.swf" level="4">Another link</link>
</links>
<text>This is some text that you are loading into level 0, for some reason</text>
</root>

You would then use Flash's XML object to read in everything:
Code:
xmlObj = new XML();
xmlObj.ignoreWhite = true;
xmlObj.onLoad = function(success) {
	links = this.firstChild.childNodes[0].childNodes;
	for (i=0; i<links.length; i++) {
		link = new Object();
		link.ref = links[i].attributes.ref;
		link.level = links[i].attributes.level;
		link.text = links[i].firstChild.nodeValue;
		button = _root.createClassObject(mx.controls.Button, "b"+i, _root.getNextHighestDepth(), {label:link.text});
		button.move(100*i, 20*i);
		button.link = link;
		button.onPress = function() {
			loadMovieNum(this.link.ref, this.link.level);
		};
	}
	txt = this.firstChild.childNodes[1].firstChild.nodeValue;
	trace("Loaded text: "+txt);
};
xmlObj.load("myxml.xml");

The code above reads the XML file and creates a link Object storing the link's ref, level, and text fields. We then create an instance of the Flash Button component (this code will only work if you have an instance of a the flash button component in your library, just drag a button component into the stage to accomplish this) for each link. It sets the label on the button to the text corresponding to the link, and it sets the button so that, when it is pressed, loads the correct movie into the correct level. Of course you don't have to use the Flash Button Component, you can create just create an empty movie clip, create a textField inside it and use that as a button, but you get the idea.

BTW: the code works.
 
Last edited:
  • #4
Thanks.

One point I would like to clarify - since we have to build a button for each link, does that mean that we have to know the number of links we have in advance?
 
  • #5
That depends on how you want to position the buttons in the page. Right now the code i posted just throws them in there.
I can imagine that you probably want your links to be all text and displayed as in an HTML page but this would not be very easy. It could get quite complicated. It would be doable if the flas's text fields supported the HTML tag <a>, but they don't, they only support text formatting tags. Unless you can find a flash component that does this i wouldn't go for it. On the other hand i think such a flash component would be pretty popular and i think i'll try to make one when i have the time.
 
  • #6
flash 7 up does support <a> tags only they support only the href attribute. No other attributes
 
  • #7
I tried it with flash 8 and it didn't fly. But if that's the case, then you can do it by using Flash-Javascript integration. Basically your "link" would be a call to a javascript function in the same page as the flash movie which calls a function in the flash movie which is responsible for loading a movie into a lvel. This may seem a little ridiculous because you're calling Javascript only to call a flash function, but it would save alot of text parsing and calculations.
If your flash movie is for standalone use, then it's another story.

[edit] it does work with flash 8.
 
Last edited:

Related to Flash help loading from textfile

1. What is "Flash help loading from textfile" used for?

"Flash help loading from textfile" is a feature in Adobe Flash that allows developers to load external text files into their Flash projects. This can be useful for creating dynamic and customizable content, such as loading in product information or user-generated data.

2. How do I use "Flash help loading from textfile" in my Flash project?

To use "Flash help loading from textfile", you will need to use ActionScript code to load the external text file. This code can be written in the Actions panel or in an external .as file. You will also need to specify the location of the text file and how you want to display the text in your project.

3. What file formats are supported for the external text file?

"Flash help loading from textfile" supports various file formats for the external text file, including .txt, .xml, and .html. These files can be formatted with basic text or with markup languages such as XML or HTML.

4. Can I load multiple text files into my Flash project?

Yes, "Flash help loading from textfile" allows you to load multiple text files into your project. This can be done by using different ActionScript codes to load each file, or by combining multiple text files into one and loading that single file into your project.

5. Are there any limitations to using "Flash help loading from textfile"?

One limitation of "Flash help loading from textfile" is that it requires an internet connection to load the external text file. If the file is not accessible or the internet connection is lost, the text will not be displayed in the project. Additionally, the size of the external text file may affect the performance of the Flash project.

Similar threads

  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
4
Views
5K
  • Electrical Engineering
Replies
2
Views
570
  • Programming and Computer Science
Replies
4
Views
3K
Replies
6
Views
4K
  • Programming and Computer Science
Replies
2
Views
10K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • DIY Projects
Replies
23
Views
4K
  • Classical Physics
Replies
4
Views
1K
Back
Top