TwelvestoneFlash

getBounds and masked text


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
DontBogartMe
 
2007-09-24

The problem I have is that getBounds and getRect don't take into account the mask on my textfield that hides some of it - and they return the yMax always as being the bottom of the textfield.

Here's a little test script to show what I mean:

masked_text_getBounds.html masked_text_getBounds.fla

I want the tracking dots to go to the bottom of the VISIBLE text, not the whole text. Move the mouse up and down to hide/reveal the text, and observe where the dots end up.

The reason I'm having this issue is because my masked text clips are in scrollable blocks, and the scrollbar I'm using uses getBounds to find what the height of the visible content is - and because of this problem it thinks the content is much higher than it really is.

Is there a way around this to make getBounds behave how I want it to? Or will I have to do some dirty hacking of my own to get it working?

JLM
 
2007-09-24

you can use the scroll hacks to get text height. But i would think that autoSize a hidden version would be the simplest. If your using a mask on the text you can use Math.min(Mask._height,txt._height); With autosizing sometimes (flash6 especially) does not update the getter value for the new value of the _height unless you explicitly use trace or assign it to a variable and then set the height as the new variable + 0.1 or something. Please bear in mind without me opening flash I have no idea if this is helpfull or just a mixture of distant memories.

DontBogartMe
 
2007-09-24

here's some code for what it's worth:

txt2.multiline = true; txt2.autoSize = "left"; txt2.text = testCopy;

block_1.txt1.multiline = true; block_1.txt1.autoSize = "left"; block_1.txt1.text = testCopy;

this.onEnterFrame = function():Void { block_1.mask._height = block_1._ymouse;

var objBounds:Object;
objBounds = block_1.getBounds(this);
this.ball_1._y = objBounds.yMax;

this.ball_2._y = block_1._y + block_1._height;

}

txt2 is the non-moving textfield, block_1 is a library clip on the stage that contains the moving mask and the other textfield. testCopy is just a string containing that text, which I omitted from the code.

I've changed this code slightly to test results using _height to find the bottom of the block instead of getRect as it is in the test example I posted. The result is the same though, and equally useless.

I did try messing with the _height value like you suggested, but couldn't get it to make any difference.

I've googled a fair bit too, but can't find any solutions, nor much indication that many people have had this problem, unfortunately for me.

JLM
 
2007-09-24

more along the lines of...

block_1.txt1.multiline = true; block_1.txt1.autoSize = "left";//check case block_1.txt1.text = testCopy;

this.onEnterFrame = function():Void { block_1.mask._height = block_1._ymouse; var relative = (block_1.getBounds(this)).yMin; var txtY=relative+block_1.txt1._y+block_1.txt1._height; var maskY=relative+block_1.mask._y+block_1.mask._height;
this.ball_1._y = Math.min(txtY,maskY);

}

DontBogartMe
 
2007-09-24

yes I could do that here, but this is just an example to prove the ... dare I say ... Flash Bug?

In my real case, I have a scrollbar class that won't, and shouldn't, know all these details about how the scrolling contents are constructed. It is just looking at the _height of it, and working out the scrollbar from there.

I'm currently taking your first suggestion of using a hidden version, will have to add a little code to the class I think, but hopefully it'll be ok. My only problem with that is that it add a load of strange looking code and on stage objects to my app.

JLM
 
2007-09-24

Not looked at your fla yet, but if you roll your own scroller you can hide lots of the details from the designers either in template movieclip structures passed to a composite class or in your class so it is down to you in the way you implement. you can always wrap a component in your own component.

DontBogartMe
 
2007-09-24

yup got it working nicely with a hidden content panel, where I just clear() and re draw a block the size of the real height of the content.

I wish Flash would get this sort of thing right though, and not make me waste my time with all this crap.

:crash: :crash:

DontBogartMe
 
2007-09-24

oh all I had to change in the scroll bar was to add a dispatch event call to allow the calling code to listen for a 'move' event, and then move the real content accordingly - that way when the user scrolls the fake hidden content, the real content moves with it.

I like my scrollbar class and want to be able reuse it in other projects, so I didn't want to have to add code in there that was specific to this little situation. And I've managed to do that, so all's well.

DontBogartMe
 
2007-09-24

and thanks for the help JLM k

JLM
 
2007-09-24

are you posting an example to save others the stress?

DontBogartMe
 
2007-09-24

I'm hoping the notes above will do that much without me having to. I can't post the real project, and not sure I want to go into making a proper prototype just for this.

JLM
 
2007-09-24

No worries glad you got it working.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

getBounds and masked text