[quoted text, click to view] kglad wrote: > no change. you can use the LoadVars() object or use loadVariables(). for > example, in your text file use: > > myvar=this is the content of the string variable myvar
Just a quick note. While this works, I usually recommend using the "&" Probably no benifit other than standardization in this case. -- -=tn=-
Can anyone walk me through loading a .txt file into a dynamic text field? I know how to do that with MX, but with MX2004... I'm clueless.
no change. you can use the LoadVars() object or use loadVariables(). for example, in your text file use: myvar=this is the content of the string variable myvar in your flash file you can use: _root.createEmptyMovieClip("holderMC",1); holderMC.loadVariables("yourTextFile.txt"); holderMC.onData=function(){ yourTextField.text=this.myvar; }
This might also help - It's a setInterval fade text in and out transition. (kglad might have given it to me - I can't remember (he/she) has done so much for me in the past). It simply fades the text in and fades it out automatically and replaces it with other text when you repeat the button command for different text: This might be overkill for what you need to be told or need but it can simply be copied and pasted and away you go. Good luck. // Just paste this on the keyframe that your dynamic text field is on and give the field a name of box t_fmt = new TextFormat(); t_fmt.font = 'sx'; box.setNewTextFormat(t_fmt); box.embedFonts = true; TextField.prototype.fadeOutIn = function(alpha_change, per_ms, updateAfterE) { clearInterval(this.fadeID); this.dir = -1; var fade = function (tf) { tf._alpha += tf.dir*alpha_change; if (tf._alpha<=0) { tf._alpha = 0; tf.dir = 1; tf.text = tf.newtext; } else if (tf._alpha>=100) { tf._alpha = 100; clearInterval(tf.fadeID); } if(updateAfterE){ updateAfterEvent(); } }; this.fadeID = setInterval(fade,per_ms,this); }; // All of the above gets pasted on the keyframe that houses your text field called box // Then paste this in your button function for each button: box.newtext = "This text will show up in your Dynamic text field. Impress your friends and family and even get laid with such cool dynamic field effects!"; _parent._parent.box.fadeOutIn(5,10,true); // adjust these 2 numbers to adjust speed of fade // example: you can paste all of the stuff below for your buttons. (Just make sure that it correctly targets the box text field). //-----------< this function allows you to logically enable and disable the set of buttons>-------------------\\ function releaseAll(){ button1.enabled = true; button2.enabled = true; button3.enabled = true; button4.enabled = true; button1.gotoAndStop(1); // tell the button to go to a certain point in it's timeline(usually it's plain rolled out state) button2.gotoAndStop(1); button3.gotoAndStop(1); button4.gotoAndStop(1); } button1.onRollOver = function() { this.gotoAndPlay(2); // tell the button mc to go to it's rollOver state. } button1.onRollOut = function() { this.gotoAndPlay(1);//tell it to go to another state or it's original state etc. } button1.onReleaseOutside = function() { this.gotoAndPlay(1); // tell it to do the same as above if the user drags their mouse out of your button so it doesn't get stuck in the usual rollover default state on dragout. } button1.onRelease = function() { this.gotoAndStop(3); //tell the button to go to another state after the release box.newtext = "This is more text blah blah etc rhubarb."; //whatever text you want showing up box.fadeOutIn(5,10,true); releaseAll(); // releases all the other buttons now you have selected this one. this.enabled = false;//disables this button as it has already been pressed until it gets automatically enabled again if you //cont....press another button. } // so for each button you would use the above button handlers and simply change the text inbetween the quotes. //don't forget to right click on the font in your library and set it to export for actionscript and use the name of that font as it is written in the top line of all of this actionscript. Hope this can help someone. (cheers kglad).
I got the text to work. I have two Dynamic Text boxes that loads two different ..txt files externally. Everything works fine, except once in a while, I'll get an error message, "undefined." on the text box. I've copied the actionscript code to the beginning keyframe and the last frame where the text would load, thinking I can call the text to load up first than again on the "stop" frame. I'm still getting the "undefined" message. What did I do wrong?
Don't see what you're looking for? Try a search.
|