Jump to content


Photo

auto scrolling dynamic text from external text file


  • Please log in to reply
6 replies to this topic

#1 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 18 July 2007 - 06:57 PM

Hi guys,

I'm loading a text file into a dynamic text box using LoadVars, and I've got it to scroll using this code:

var myInterval = setInterval(scrollUp, 500);
function scrollUp() {
_root.text_mc.textbox.scroll += 1;
}

...but there are two problems. One, the client says it's too jerky (as it's doing it a line at a time, rather than a smooth scroll), and two, the client would like it to be like a news scroller, meaning it automatically scrolls to the bottom of the text, and then the start of the text appears underneath and keeps scrolling continuously. I hope I've explained myself reasonably well!

I've been thinking that one way to do this would be to load the text into TWO text boxes, which are in separate mc's, and then animate them so that when one reaches the top of a mask, it jumps back underneath - really not sure how to do that, though...

If someone could help me out with these two things, I'd really appreciate it - cheers!

Boog :closedeyes:

#2 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 19 July 2007 - 08:53 AM

Hey Boog, couple things for you here.

1) Slowly animating text in Flash looks kinda crummy. (Flash just seems to have a problem with it)
2) Your logic on the looping is perfect. Just use the y val +height of the lower clip to reposition the top clip when it scrolls off the screen. A simple if statement to check if the y + height > y of the scroll area will wrap your text boxes.

Let me know how it goes.

#3 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 19 July 2007 - 10:52 AM

Hey Pax,

Thanks heaps mate - makes so much sense when someone else explains it! I was pretty close, anyway :(

I'll fiddle tomorrow and see what I come up with - will be back here to either post my success or beg you for help again B)

Edited by boogooloo1, 19 July 2007 - 10:53 AM.


#4 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 19 July 2007 - 11:27 AM

Oh, Pax, it just occured to me that there's one problem with the above plan. I'm using a few different text files with this beast, so the text box will need to change size depending on which text file is being loaded - is there some way of getting Flash to calculate how many lines it will need for the text, and resize the text box (and the mc holding it) accordingly? Otherwise, if you have a text box which is 100 lines long, and your text is only 20, there'll be a long gap between repeats...

:)

#5 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 19 July 2007 - 01:15 PM

textboxname.autoSize = true;

A movie clip should be the size of its content. Just assign a width to your text box and let it go vertically.

#6 boogooloo1

boogooloo1

    Young Padawan

  • Members
  • Pip
  • 116 posts

Posted 19 July 2007 - 08:36 PM

I just realised - I don't need to worry about putting the textboxes in a movieclip, as textboxes respond fine to tweening etc. I've got this so far for my LoadVars:

loadText = new LoadVars();
	loadText.load("text/gear.txt");
	loadText.onLoad = function(success) {
		if (success) {
			// trace(success);
			text_mc.textbox.html = true;
			text_mc.textbox.htmlText = this.myText;
			text_mc.textbox.autoSize = true;
			text_mc.textbox2.html = true;
			text_mc.textbox2.htmlText = this.myText;
			text_mc.textbox2.autoSize = true;
}
}

...but the autoSize code makes the text disappear. I've got this for my tweening:

import com.mosesSupposes.fuse.*;
ZigoEngine.simpleSetup( Shortcuts, PennerEasing, Fuse );

var a:Fuse = new Fuse();
a.push({y:-50, seconds:5, ease:"linear"});
a.target = text_mc.textbox;
a.start();

var b:Fuse = new Fuse();
b.push({y:30, seconds:5, ease:"linear"});
b.target = text_mc.textbox2;
b.start();

...but having a specific value for y is not going to work, as it'll depend on the size of the textbox (which will depend on the amount of text, if I can get autoSize working). I've made my mask an mc, and I'm assuming rather than the above tweening, we need to tween until the first text box is off the mask mc, and then tween the second up while putting the first underneath...?

Sorry to bother you again, mate - if it wasn't for the text boxes needing to resize, I probably would be able to figure it out by myself, but I'm not very good at variables etc yet, so would appreciate a hand if you can spare it ;)

#7 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 19 July 2007 - 08:54 PM

For the autoSize, put it before you put text in the text field, and make sure you have the characters embedded somewhere in your fla.

And you're bang on with the logic for the text fields tweens. Give it a go and see how it works out. Can't give too much away to you otherwise you won't learn it ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users