View Full Version : dynamic text/text file/actionscript
chrizzle
06-27-2007, 04:36 AM
Hi folks
Ive got a simple 'ticker' movie clip. Already reading a sinlge line of text from my external text file. I want to add a few lines of text to the text file and have the ticker movie clip grab a different line each time it hits frame one again.
So, first pass of the ticker would read line 1, second pass line 2, third pass line 3 etc... Here is my working actionscript and also my text file content. Any input would be much appreciated.
=====actionscript======
myData = new LoadVars();
myData.onLoad = function(){
tickertext.text = this.content;
};
myData.load("tickertext.txt");
===end actionscript=====
===text file data=======
content="this is the first line of text to display." - big bird, sesame street
===end text file content==
i imagine the text file would change to:
content1= first ine of text to display
content2= second line of text to display
maybe, any ideas ? thank you in advance.
Medyman
06-27-2007, 06:15 PM
Doing something like that with loadVaris is kind of cumbersome.
I recommend switching over to XML.
Then you can use an array and a for loop to do exactly what you're talking about.
chrizzle
06-27-2007, 07:43 PM
thanks for the reply Man
Im just now getting a grasp on this stuff. My html and css is pretty tight, but my actionscripting and xml is not. I usually research as much as possible on my own, but im in a bind and will learn faster from a good example.
If you have time, could you post and example xml snippet and also how the AS might call on that file ? or even link me to a nice tutorial ...I will keep studying in the meantime.
thanks again
Medyman
06-28-2007, 05:36 AM
I made up a quick little example....
Here (http://www.demos.designsbyvishal.com/dynamicdrive/OnebyOne.html) is what it looks like
Here (http://www.demos.designsbyvishal.com/dynamicdrive/OnebyOne.fla) is the source file
Here (http://www.demos.designsbyvishal.com/dynamicdrive/ticker.xml) is the XML
The .fla is probably not as commented as you might need. Post back if you have any questions.
chrizzle
06-29-2007, 02:14 AM
Hey, thanks so much for taking the time to do that.
I applied your method to my FLA. For the most part it's perfect. One thing that I don't think really matters, on your original file, and after applying it to mine, when 'previewing' in Flash, the 'output' log keeps kicking out what would normally be an error, with each pass of text the log shows "next", i am assuming that is normal and doesnt have anything to do with an error.
Second, i tried everything i could to adjust this, placement, matching your set up exactly, scanning code for a place to change setting, But nothing is fixing this 'speed' issue, for example, the first pass is normal, then after the first pass everything speeds up immensely. Here is a link to my fla/xml if you get a chance.
http://www.droptest.org/Ticker-V2.zip
again, thank you so much.
Medyman
06-29-2007, 03:31 AM
Since you're just starting out with actionscript, here is the biggest tip I can give you: learn to love the trace function.
If you look at the function "nextLine" (or something like that) you'll see a code line which says trace("next"). This is what's producing the next output. A trace function can be very useful in pinpointing the source of errors.
Since a lot of work is done with abstract math and variables, it hard to conceptualize what these variables' values are at certain times. A trace call does just that. It also helps to figure out if everything is running as planned.
Since, the "next" shows up in the output window, I know that the nextLine function is running. If that didn't show you, I would have a better idea of where to look for an error.
I'll have a look at ur .fla and see if i can pinpoint the speed issue
Medyman
06-29-2007, 03:34 AM
I couldn't open the .fla. Are you using CS3? I haven't upgraded yet. If you still want me to look at it, back save it and reupload it.
FYI, though:
The speed is controlled in the scrollText() function
function scrollText() {
Text.xSlideTo(0, 5, "linear")
Text.onTweenComplete = nextLine
}
This controlls the speed of the entire animation. It shouldn't render different speeds after each time it loads, unless there is something overriding it.
The mcTween sytax is such:
Text.xSlideTo( _x, time (secs), transition, delay, call back function)
chrizzle
06-29-2007, 05:01 AM
try that same link again, i replaced with a new file. Im going to play with that syntax in the meantime. I am interested to see if you get the same results i'm getting with the speed.
Medyman
06-29-2007, 04:37 PM
Hey...
I'm actually not experiencing the same speed problem. Everything is running at the same speed as it should be.
I'm not sure what could be happening.
One suggestion though, you might want to slow down the animation because at it's current speed the animation is kind of hard to read.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.