View Full Version : Having a NIGHTMARE!! - Loading simple text into dynamic text box within movie clip
grafyte
05-29-2005, 07:09 PM
Having a NIGHTMARE!! - Loading simple text into dynamic text box within movie clip
I have a flash file.
Within this flash file there are various movie clips, and within one of the movieclips is a dynamic text box.
I want to import a txt file (vitae.txt) into my dynamic text box (instance name = vitae_txt)
There doesn't seem to be a tutorial anywhere for this...
I have tried and failed with so many methods, but none seem to make it simple.
My problem may lie with one thing... I have a preloader at the start of my movie, so I have been inserting the script that loads the data etc into the 3rd frame, instead of the first.
Can anyone help? this would be fantastic to fix.
My movie clip, that contains the text box has an instance of AboutContent
Thanks
Alex...
snapple
05-29-2005, 07:11 PM
can you upload your fla?
grafyte
05-29-2005, 07:17 PM
I can upload a very simplified version of my problem. I've created a small flash file to demonstrate the problem.
I have not added any code to it though, as I'm not sure where to start.
There's also no preloader, just a couple of empty blank frames...
Hope this is ok...
snapple
05-29-2005, 07:40 PM
You obviously have not searched the tutorials section on this site or searched the forums properly because there are hundreds of thousands of posts on exactly your problem.
Anyway, here is your fla.
snapple
grafyte
05-29-2005, 07:47 PM
Excuse me, but I've been trawling this site, and the tutorials section all afternoon to no avail.
It's not for want of trying. I AM aware of how the site works...
Anyways, your zip file wouldn't open, and I think I see where my problems are lying...
It's the fact that the text box wasn't on the first frame of my movieclip when I was referencing it, and for some reason, I can't tell the actionscript to look further on in the movie. And masking it, makes the text dissapear again.
well... the nightmare continues. Maybe someone's just not smiling down on me today...
grafyte
05-29-2005, 07:51 PM
Righto...
Bit quick off the mark to download, there. maybe not fully uploaded or whatever.
I got it downloaded, but without the mind of a coder, i'm having trouble decoding what you've done here. I wouldn't call myself stupid, but there seems to be a great deal of code I've not come across before...
oldnewbie
05-29-2005, 07:58 PM
Not being on MX2004, I can't open your .fla or Snapple's...
If you save a copy of it in a MX only format (and/or even Snapple's .fla), I could have a look...
snapple
05-29-2005, 08:02 PM
I bet you that i could find over 20 posts asking exactly what you have.
There is hardly any code there, its the very basics:
Stop the main timeline form playing straight away:
this.stop();
Create a LoadVars object to use and ask it to load the text file:
var v:LoadVars = new LoadVars();
v.load( "vitae.txt" );
Set-up two variables, the method names should be a dead give-away as to what they do:
var loadedSoFar:Number = v.getBytesLoaded();
var loadedComplete:Number = v.getBytesTotal();
Use a mthod of the LoadVars class to check that the loading worked properly:
v.onLoad = function( success:Boolean ):Void
{
if( success )
{
populateTextBox( this.contents );
}
else
{
trace( "Error loading vars" );
}
}
Populate the text box with the text file variable:
function populateTextBox( s:String ):Void
{
_root.showContent.text = s;
}
Check that the loading of the text has completed before moving to the frame to show the text:
if( loadedSoFar >= loadedComplete )
{
_root.gotoAndStop( "mainDisplay" );
}
snapple
snapple
05-29-2005, 08:05 PM
oldnewbie, there was nothing in grafyte's fla, just blank frames. I can save it as MX, but it really isn't worth it, seeing as it all works fine and your abilities are far beyond looking at my fla's ;).
grafyte
05-29-2005, 08:12 PM
Cheers snapple.
That's explained it a little better for me.
I apreciate your time and effort. Hopefully I can use this all to my advantage...
Thanks again
Alex.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.