Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrolling text solution

Status
Not open for further replies.

Leozack

MIS
Oct 25, 2002
867
GB
I'm using Flash MX6.
It seems if you want to scroll text in a box you have 2 options

1 - use a DTB and get some scroll buttons working (and maybe a slider too). But this makes the text aliased and ugly, and scrolls too fast usually

2 - use a TB full of any text you like, and mask only the area you want to read, and scroll the TB up/down behind the mask hole.

I've tried going for 2, but 1 - the textbox is visible completely, not masked, and worse than that 2 - my resizeStage function that runs at the beginning after loading the settings for the presentation, seems to take into account the big textbox despite the face the unseeable area that's masked shouldn't count towards the stagesize - as it is currently the stage is considered much bigger to accomodate the textbox you can't even see (should onyl see the bits scrolling past the masked hole area)

The resize function is this
Code:
function resizeStage() {
    var stageW = Stage.width;
    var stageH = Stage.height;
	stageH = stageH - (imgHeight)
    if (stageW/stageH>ratio) {
        containerMC._height = stageH;
        containerMC._width = containerMC._height*ratio;
    } else {
        containerMC._width = stageW;
        containerMC._height = containerMC._width/ratio;
    }
    containerMC._x = Math.floor((stageW-containerMC._width)/2);
};
This is where I draw the box area I want the text to appear in, along with the masks and borders etc
Code:
infoMC = containerMC.createEmptyMovieClip("infoboxMC_mc", 5);
infoMC._x = margin;
infoMC._y = imgHeight + (margin * 2);
infoBG = infoMC.createEmptyMovieClip("infobox_mc", 1);
;Draw a box on infoBG with the background colours
infoHolderMC = infoMC.createEmptyMovieClip("infoboxholder_mc", 2);
infoMaskMC = infoMC.createEmptyMovieClip("infoboxmask_mc", 4);
infoBorderMC = infoMC.createEmptyMovieClip("infoboxborder_mc", 5);
infoMaskMC._visible = false;
;Draw a box on infoMaskMC to be a hole for the textbox area
;Draw a box on infoBorderMC with the border around it
Now I draw the textbox and the masks for it
Code:
infoHolderMC.createTextField("info_text",102,infoBorderWidth,infoBorderWidth,imgWidth,imgHeight);
infoHolderMC.info_text.multiline = true;
infoHolderMC.info_text.border = 1;
infoHolderMC.info_text.wordWrap = true;
infoHolderMC.info_text.html = true;
infoHolderMC.info_text.text = SampleText;//"Here's some info";
infoTF = new TextFormat();
infoTF.font = "Verdana";
infoTF.size = infoTxtSize;
infoTF.align = infoTxtAlign;
infoTF.color = infoTxtColour;
infoHolderMC.info_text.setTextFormat(infoTF);
infoHolderMC.setMask(infoMaskMC);
Some of this code may be using variables I read in previously so if you wanted to test it you'd have to set them yourself.

But hopefully someone just knows a solution or a better way to have a scrolling textbox/textarea :)

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
After reading around, it seems the reason the masking wasn't working for the textarea was you need to anable font embedding for dynamic text to be masked. So I tried setting it with
infoHolderMC.info_text.embedFonts = true;
and now the text is masked! ..... too much. the border around the text (only on for debugging) correctly shows/hides in the right places. But the TEXT in the box is now totally gone, it doens't show up at all despite the border around it going up and down in and out of the masked area. What can I do to fix it? :(

Once this is sorted the only issue will be how to have a big textbox invisible on the stage and to do my stage calculations for sizing etc IGNORING it since it's not visible other than in the main stage area where it's masked?

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Ok so I found this line was an issue
infoHolderMC.info_text.embedFonts = true;
Without it, the text showed and wasn't masked. With it, the text totally disappeared. Reading through
I found it say that the .embedFonts is possibly true by default anyway - but more importantly - that you STILL need an actual textbox ONSTAGE (not scripted) where you open the character window and select to embed all fonts, making sure to use the same fontname and weight (bold/normal/italic) that your dynamic textbox will use.

Then, miraculously, just by placing an empty verdana nonbold textbox onstage and selecting to emebd all characters, now my dynamic textbox using the same font works

:)

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
As it happens, I also see now on
that "with all Flash Players after 6.0.40 you don't need to embed the font for text to show through a mask. Make sure you've downloaded the latest Flash Player (6.0.79.0) for both your authoring tool and web browser"
So off I went to
and grabbed
and I replaced the old flash 6 player I have in my flashmx/players subdir and assigned .swf filetypes to this new player. It all works a dream! Non embeddedtext now masks fine. Sorted, no need to embed anymore?
Well - in flashmx if I hit ctrl+enter to preview, it's still using some (I gues builtin) version of 6 player before 6.0.40 because it doesn't mask :( Dunno how to update what it uses to preview but guess I can't :/

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top