Stupid question for Flash developers

Let me preface this by saying that I’m completely new to Flash. I’m basically a C++/VB developer who’s had a big fat pile of .as files dumped in his lap and has no idea what to do with them. Thus, my apologies if my question is unclear; I’m not sure if it’s possible to answer my question without seeing the relevant code, but I can’t seem to find which bits of code are relevant.

What I’ve got is basically a “game show” app that displays multiple choice answers to questions. What I want to do is make the text wrap if the answer is longer than X characters; right now, the rest of the answer just disappears after character #X. I figured out that the app is reading the questions from an XML doc, but I can’t seem to find which .as file they’re being imported TO, let alone which specific object(s) are displaying the answers.

What would make my day is if there were some generic code I could plop willy-nilly into every answer-related .as that would cause all text longer than X characters to automatically wrap to a new line. Failing that, if somebody could give me the quick n’ dirty on what Flash object-import code looks like, so that I can at least find out WHERE the problem is, I can probably get to the “what” of it on my own.

Any advice is greatly appreciated. Thanks!

Okay, after some poking around at it, I’ve determined that the code I need should follow the form:

if (answer.length) > (X) then
{
answer.wordWrap = true
}
else
{
answer.wordWrap = false
}

…which seems pretty straightforward, except for the life of me I can’t figure out which string contains the answer, because I cannot find where the Answers.xml file is being read. If this were a language I knew, I’d just have every string throw self-containing message boxes at me and figure out what was going where, but I don’t know how to do that in Flash.

I need at least a starting point. Suppose, in a Flash project, you were going to create four labels, set up string variables to be read into those labels, and import the string values from an XML file. What would that code look like?

I am NOT an Action Script guru by any stretch, and at the moment, I don’t work with .as files, but rather with code that’s attached to frames of a Flash document, but I can offer you these pointers:

In Flash, to read XML you have to create an instance of an XML object somewhere. There should be some code that reads something like:

var content:XML = new XML();

To load the XML, something like this should be in the code:

content.load(“path to file”);

Then, the XML content needs to be parsed. The usual way to do this is something like:

content.onLoad = parseXML;

(parseXML is a function that parses the XML. It might be called something else, depending on how the programmer is naming the functions. It’s a user-defined function that should have something like:

if (success && this.status == 0) { do a bunch of stuff }

in it.
The XML structure in Flash is a little bit confusing. You’ll be looking for stuff in your XML file that looks like “this.firstChild” or “this.childNodes” when referencing information in the XML file.

This is the tutorial I used to learn the structure of Flash XML files.

If there is nothing that looks like that in your .as files, is it possible there’s an .fla file somewhere that has the code attached to it?

Well, thanks to you, I found where the XML is imported, but all that happens there is that it references another .as…and I think I found where I need to be. If I’m reading right, somehow the following code segments:



private var tText:TextField;
public function set Text(s:String) { tText.text = s; }

private function init()
	{
		tLabel = this["tLabel"];
		tLabel.embedFonts = true;
		
		tText.autoSize
		tText = this["tText"];
		tText.embedFonts = true;
		
		super.init();
	}


…are where the text is being assigned to the answer boxes. It’s bugging the hell out of me that modifying “tText” actually affects four text boxes (one for each answer) and there don’t seem to be any arrays or loops involved, but I have the serenity to accept what I cannot change, I just need the juju to change what I (hopefully) can. [ETA: Okay, the main game just calls the init() function four times. Duh. Been staring at this too long.]

Now, I’ve tried setting tText.wordWrap and tText.multiline to “true” within init(), but all that did was cause the text to truncate after one less character than it did before. I then figured it might be an issue of text box height, so I tried setting tText.height to arbitrarily large numbers, with no effect.

So, in conclusion, I definitely need to do something to tText, and I think I need to do it in init()…I just don’t know what.

VICTORY FOR SYLVANAS!

Heh…never mind. I’m almost ashamed to admit this, but I don’t want puly or anyone else racking their brains to try to figure out the problem, since they’d probably give me too much credit from the outset.

See, I got the coding right, but…it just occurred to me that, when messing with object size, pulling up the project file and actually looking at the object itself - and even, if you want to get really funky about it, adjusting the size of the object on the form - tends to help. I expanded the size of the tText object to be able to hold two lines, and the wordWrap code worked like a charm.

Told you I never used Flash before. At least the blinky box with the cup holder was plugged into the wall… :o :smack: