Log in

View Full Version : varible w,h Dynamic Text



bluewalrus
11-26-2008, 06:31 AM
Is there a way to have a dynamic text fields height be set exactly to what the content inside it is. I have a code that scrolls threw a movie file from the top to the bottom of the contents of the file. So I want to put the dynamic text field in the movie file and have it only be scrollable till the bottom. There are 5 buttons each will be loading in different content in that text field(at different times)?

Thanks for any ideas you have.

EDIT:
Also changing this once more shouldnt matter though cause no ones responded yet and i dont wanna flood this with threads...

This is actionscript i got from a tutorial to make a dynamic graph but its only increasing vertically (i want it to go horizontally) i swapped the movie to expand horizontally but its still going vertically.Any ides? Theres some other stuff but it just loads in values from a text file and the other one reloads the frame this code is in. bar is a movie containing an increasing block with a motion tween 1-100 frames. there are 14 instances of it each with the number next to bar (bar1, bar2, etc.)


a = 1;
while (Number(a)<14) {
tellTarget ("bar" add a) {
gotoAndStop(eval("_level0/:bar" add ../:a));
}
a = Number(a)+1;
}

Medyman
11-27-2008, 04:47 AM
Look into the TextField.autoSize (http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#autoSize) property.

bluewalrus
11-28-2008, 07:19 AM
That does look like what I want but the code on that page doesnt work I tried putting it in and then playing around with it but I just get this error message
"1037: Packages cannot be nested.

bluewalrus
12-05-2008, 06:20 PM
I'll try and be more specific....

I have a flash file It's AS2. I want to have a dynamic text field on frame 25 within a movie clip called content3. On frame 3 I have 10 buttons if one of those buttons is hit i want to to go to frame 25 and load text from one of ten external text files into that dynamic text field. I also want the dynamic text field to expand only as far as the content is height wise i want a set width. I've created the text field, external files, and buttons but can not get the text to load into the text field nor to load at the least. Thanks for any ideas you can offer. Below is the code I have for the 1 of the buttons so far .


contentMain.infokeena.onRelease = function() {
loadVarsText = new loadVars();
loadVarsText.load("data.txt");
gotoAndStop(25);
};

BLiZZaRD
12-06-2008, 04:02 PM
Do you have your whole system set up correctly? Here is what you need to do:

1. Give your Dynamic Text box a variable name (for this I will use "myText")
2. In the .txt you are loading, you need to state the variable name:


myText= blah blah this is loaded blah blah

3. Now we need to load the text into the MC, not at root level. So we have a button (lets call it btn1 since you have 10) and we want to load it into MC named content3..


but1.onRelease=function(){
loadVariablesNum ("data.txt", "_root.content3");
}

4. Ensure all .txt files and the swf/html are in the same folder when uploaded. <~~ Most common mistake

That should do it.

Medyman
12-06-2008, 04:54 PM
That does look like what I want but the code on that page doesnt work I tried putting it in and then playing around with it but I just get this error message
"1037: Packages cannot be nested.

package? Did you copy and paste some random example from the page that I linked to?

All you needed to do is add:

textfield.autoSize = "LEFT"
where textfield is the instance name of your text field.

bluewalrus
12-06-2008, 08:31 PM
Oo ok. Yeah, I thought the code included in that was a tutorial code to try it in flash and modify, not a just a sample of how to write it.

I tried using that code but I don't think the text is loading in properly or maybe the text field is not loading? I don't know which but this is the code I'm trying to use to do it.
contentMain is one movie and contentMain3 is another movie which contains load_it a dynamic text field located on frame 25.

contentMain.infokeena.onRelease = function() {
loadText = new LoadVars();
contenMain3.loadText.load("data.txt");
contentMain3.load_it.autoSize = "LEFT";
gotoAndStop(25);
};

BLiZZaRD
12-06-2008, 09:22 PM
what does data.txt look like?

bluewalrus
12-06-2008, 09:32 PM
it contains
text=KEENA

BLiZZaRD
12-07-2008, 03:12 PM
so your dynamic text box has a variable of "text"?

bluewalrus
12-07-2008, 05:10 PM
hmm actually i missed your first post Blizzard, sorry my eyes are darty. But I have updated with what you posted. I also renamed and moved the files around they are in the specified place now. However now with this code it is trying to load the txt file in my web browser and in the flash movie it is still just blank.
This is my code right now...
On frame 25 At the var field for load_it (the dynamic text field) i put in myText. On frame 2 where the button called infokeena (located in the movie contentMain) is this which should load keena.txt:

contentMain.infokeena.onRelease = function() {
loadVariablesNum ("text/code/keena.txt", "_root.contentMain3");
contentMain3.load_it.autoSize = "LEFT";
gotoAndStop(25);
};

And the text file at text/code/keena.txt contains myText=KEENA.

I've double checked the location of the file and I believe it is right. The fla is saved in a folder called newport in newport there is a folder called text with a folder called code file 5 text files on of which is called keena.txt.

Thanks for your help.

Medyman
12-07-2008, 05:17 PM
You should be using loadVariables(). loadVariablesNum() was deprecated in Flash Player 4 and doesn't take the target parameter like you're supplying it.

BLiZZaRD
12-07-2008, 05:44 PM
EEk! Did I use that? holy cow. I don't know what I was thinking there. I haven't used LVN in YEARS!

bluewalrus
12-07-2008, 07:47 PM
Ok I changed it to loadVariables that stopped the web browser from trying to load the content but the text field is still not appearing or its appearing with no content in it? I don't know which or if there is a way to test one?

Medyman
12-07-2008, 07:55 PM
bluewalrus,

Can you paste the relevant code that you have now? I'm a bit confused as to the state that it's currently in.

bluewalrus
12-07-2008, 08:31 PM
This is the code for the button that is suppose to load the text. Let me know if you want any of the other code or need to know any of the other elements.

contentMain.infokeena.onRelease = function() {
loadVariables("text/code/keena.txt", "_root.contentMain3");
contentMain3.load_it.autoSize = "LEFT";
gotoAndStop(25);
};


Thanks

BLiZZaRD
12-07-2008, 08:58 PM
Maybe I am looking at this wrong, but shouldn't the button release go to frame 25, and in frame 25, the data.txt gets loaded? It seems to me the data is trying to load in frame 1 of the MC, not in the text box of frame 25. Get the MC to frame 25 THEN load it.

bluewalrus
12-07-2008, 09:06 PM
I wanted to be able to have all the buttons go to the same frame though so I wouldn't have to make 10 different frames with 10 text fields. I thought there would be a way to trigger it from the first frame so that it would send the information to the other frame depending on which button was hit from the first frame.

BLiZZaRD
12-07-2008, 09:09 PM
You can.. it's difficult to explain.

And I am off work and have errands. If Medy hasn't got you sorted by the time I get back to a computer tonight I will whip something up as an example. :D

bluewalrus
12-07-2008, 09:22 PM
Okay. thanks to you and Medy.

bluewalrus
12-14-2008, 05:03 PM
Didn't know if anyone had a chance to make an example or know of one online somewhere?

BLiZZaRD
12-14-2008, 05:18 PM
Sorry, this slipped my short term memory problem. I have a bit to do right this moment, (i am sewing! lol) but will try to get something soon. I just made a sticky note reminding me about it.

Sorry for the delay.

Oh.. which version of Flash are you working in?

bluewalrus
12-14-2008, 05:22 PM
Oh that's fine I'm not in a real rush, just want to get it working. I'm using cs3, AS2. Thanks.

BLiZZaRD
12-14-2008, 05:54 PM
Okay, when I get off work I will go home and sit at my computer watching the Vikings kill the Cardinals on one monitor, so I will pull up Flash 9 on the other and whip something up for you.

Medyman
12-15-2008, 03:44 AM
watching the Vikings kill the Cardinals on one monitor

And a beating it was...

BLiZZaRD
12-15-2008, 02:28 PM
So I go home and the 4+ inches of snow that fell knocked out my power. dropping below 20 I was pretty cold last night and didn't get anything done.

Back at work and warming up I will attempt to get to this again today.

and yes, it was a beating! Go Vikes! :D

bluewalrus
12-26-2008, 07:13 AM
Didn't know if you lost track of this again or if your still working on that example?

Thanks again.

bluewalrus
01-14-2009, 05:15 AM
I still haven't gotten this to function yet didn't know if you or anyone else had an example they could show me or knew of where one is located. Thanks.

BLiZZaRD
01-14-2009, 08:53 PM
Working on it as I get the time, which isn't a lot. I still have no internet at home and my "hacked" Flash on my Linux box at work is very slow.

I haven't forgotten you, just been very busy.