Scrollbar with Sprite and Rectangle won't move text, just the Rectangle it's painted on
Warning: school assignment.
For those of you still with me, I am tasked with making some scrollable content in Flash. Load in a TextFile using LoadURL(), then display it. To get the text, we've written our own class TextFieldExtended, which is basically just there to give the textfile location to the constructor and then have the class do the various steps of getting it and loading it for you.
So I needed to get a Scrollbar, which I got here: http://kirupa.com/forum/showthread.php?t=245468
(all files in a zip linked at the end of this text)
The thing is, it works with Sprites. After trying to get it to accept TextFieldExtended, I bumped into a block, since the scrollbar relied heavily on a Sprite property that TextFieldExtended didn't have or could have.
So I tried adding the TextFieldExtended instance to a Sprite instance usi开发者_如何学Cng addchild. A problem occurs here that I do not know how to handle. It seems that a Rectangle is drawn and the Text is drawn on that. I say this because the scrollbar moves the Rectangle up and down a bit, but the text doesn't scroll, just the Rectangle it is positioned in and the text then moves along with it.
My question: can this be fixed, or is does this implementation of scrollbars need a lot of adaptations before this is possible?
If so, any scrollbars you can recommend, because it's too extended for me at this point.
All files: http://www.mediafire.com/?q2ium22gmox This was made in Flash CS4 using ActionScript3. The Example class is the final implementation
Sounds like an odd problem; I was reading up to the point where you say you put your TextField in a Sprite thinking "he just needs to put that TextField in a Sprite", so I'm not quite sure how to fix the specific problem you've got. I'd guess it's the Scrollbar you're using. So here's another one that's fairly straightforward to use:
http://www.warmforestflash.com/blog/2009/04/free-as3-scrollbar-fullscreen-and-resizable/
Give that a whirl. Scrollbars can be fiddly in my experience, but it's just a matter of finding an implementation that suits you. Hope it helps.
精彩评论