View Full Version : auto resize a caption
lunatic
May 6th, 2004, 03:18 PM
Yes another bloody auto resize question. :sigh:
I'm hoping this one will be fairly simple though - I just can't see it. I took a resizing prototype function from the compiled fla in the resizing slideshow thread (found here (http://www.kirupaforum.com/forums/showthread.php?t=51430&page=12&pp=15&highlight=resizing), post #171) and combined it with the concepts from the hover caption tutorial on kirupa. But instead of creating a dynamic text box in the hover movie clip I am creating the text dynamically using createTextField and then autosizing it using textfield.autoSize = true (didn't seem to work when I used "left"). When you use createTextField you have to specify a width and height. The autoSize command seems to dynamically resize the textfield in height but not in width. When running a trace the width is always the same though the height changes.
Is there any way around this? Some of my captions will be quite short and will look really stupid sitting in a long colored box it doesn't need.
An fla is available for anyone who needs to take a peek!
Thanks much -
:hr:
lunatic
May 6th, 2004, 03:36 PM
Never mind! I just discovered the textWidth and textHeight properties for textfields. :sigh: :trout:
Once I stop feeling like a total moron I'd be happy to share the fla if anyone thinks it would be useful. In a nutshell it's a dynamically resizing hover caption.
Cheers
:hr:
sipher
May 7th, 2004, 09:52 AM
yeah post it...
thanks
Never mind! I just discovered the textWidth and textHeight properties for textfields. :sigh: :trout:
Once I stop feeling like a total moron I'd be happy to share the fla if anyone thinks it would be useful. In a nutshell it's a dynamically resizing hover caption.
Cheers
:hr:
lunatic
May 7th, 2004, 11:46 AM
Unfortunately it's on my work computer and I'm home for the weekend. But I will do so on Monday! :D
lunatic
May 10th, 2004, 10:42 AM
As promised, here is the fla if anyone wants it.
:hr:
silencematters
June 21st, 2004, 06:49 PM
hey there.
i do have to say that this helped me out soooooooooooo much! I was able to look at the code in the file you gave and somewhere along the line it made much more sense to me than it has in the past.
here is my question:
You applied the hover text to appear on rollover to a GRAPHIC.
how can i apply this to an exsisting button?
lunatic
June 21st, 2004, 07:00 PM
Not to a graphic, but to a movie clip with button properties. ;)
In the actionscript layer you see the following:
one.hover("An example of more text");
two.hover("An example of some bloody long text")
three.hover("A bit of text")
'one', 'two', and 'three' are the instance names of my movie clips. The prototype function is setup to work with movieclips (that is also defined in the actionscript layer).
To use buttons symbols instead of movieclips change the second prototype function from this:
MovieClip.prototype.hover = function(refuge) {
this.onRollOver = function() {
_root.x = 1;
//etc. etc. etc.
to this:
Button.prototype.hover = function(refuge) {
this.onRollOver = function() {
_root.x = 1;
//etc. etc. etc.
Be sure to give your buttons instance names and reference those when you call the hover function.
:hr:
silencematters
June 21st, 2004, 08:56 PM
yes i see more clearly thank you!
it is not working quite yet,. and i was thinking that i need to change the script on the 'box" that gets resized as well... it says onClipEvent -
onClipEvent (enterFrame) {
if (_root.x == 1) {
this._alpha = 50;
} else {
this._alpha = 0;
}
}
i am slowly getting the logic behind the madness...
am i right? does this need to be changed to make it work? and if so,... to what? :tb: -me
lunatic
June 21st, 2004, 09:20 PM
Well I guess it depends on your setup. The fla I posted works for me so if you have the same setup it should work (works for buttons as well as movie clips as long as the prototype function is changed that calls the onRollOver event). If your setup is different then yes you may have to change some things. What isn't working exactly? Maybe post your file so I can take a look?
:hr:
silencematters
June 22nd, 2004, 12:08 PM
Yeah, i would appreciate it if you took a look at this.
I have been sitting here going over every little bit,. and i feel like i have ruled out all things that i know. So i am guessing that there is some bit that needs to be changed here that is above my head.
I copied it almost exactly as your tutorial... and modified the prototype function that calls the onRollOver event, - but the box is not resizing. hmmm.
I would like to know what you think it might be.
thank you
-me :tb:
lunatic
June 22nd, 2004, 02:35 PM
You changed both prototype functions to button when only one of them had to be changed. The hover prototype function had to be changed because that is the one that defines what happens when a button is rolled over (as opposed to a movie clip which is what the button one was originally).
But the resize prototype function acts upon the box, which is still a movie clip, so that one has to stay a movieclip prototype function.
:hr:
silencematters
June 22nd, 2004, 04:13 PM
ahhhhhhh thank you! wow yes....
Hopefully i will learn to check my work differently through this. I really appreciate you help.
I guess my next step from here will be to make a smaller text rollover appear when you first hover the button, then then upon clicking,... a larger amount of text appears in the hover caption, and when you click again,. it goes back to it's original state.
I will post a new question containing this, I dont want to keep pestering you with my questions.
Thank you for your help!
lunatic
June 22nd, 2004, 04:18 PM
No worries - that's what we're here for. :)
Now if I could only get my own more complicated version working . . . :sure:
nicky g
October 20th, 2004, 10:38 PM
Never mind! I just discovered the textWidth and textHeight properties for textfields. :sigh: :trout:
Once I stop feeling like a total moron I'd be happy to share the fla if anyone thinks it would be useful. In a nutshell it's a dynamically resizing hover caption.
Cheers
:hr:
You mentioned above that you discovered textWidth and textHeight. Can you point me in the direction of these. When I adjust the width of my dynamic text box it simple stretches the text rather than making the text box bigger. As I didn't originally create the dynamic text box I don't know how to make it wider to allow for more text.
cheers
g
lunatic
October 20th, 2004, 11:09 PM
Welcome to the forums! :D
Are you doing it dynamically or do you just want to make it bigger on your stage? If the latter - simply click inside the text box like you were going to type in it. You'll see a little white box appear at one of the corners. Simply grab that and resize the box.
If you want to do it dynamically with actionscript then you want to check out your actionscript reference (in the action panel). Go to Objects --> Movie --> TextField --> Properties and you'll find the textWidth and textHeight properties. Basically though you can grab them just by using the instance name of your textfield:
trace("mytext.textWidth");
etc.
:hr:
FlashPlaya
January 11th, 2005, 05:39 PM
Hey guys!!!
Is there a way to put an image and some text in there... Man that would be nice..
:thumb:
lunatic
January 11th, 2005, 05:45 PM
Sure! It's called the resizing slide show thread! Look for it under Best of Kirupa! :lol:
FlashNewby
January 11th, 2005, 05:53 PM
Man, that caption resizing is sweeeet!http://www.kirupa.com/forum/images/smilies/hugegrin.gif
lunatic
January 11th, 2005, 06:03 PM
Thanks! :blush:
It's probably the only thing I've figured out all by myself that I am proud of! =)
FlashPlaya
January 11th, 2005, 06:30 PM
O.. come on lunatic!!
I know that tread!! I just wanted to see if there was a way to have a thumbnail not a full image.. I guess it would not even need to resize. It would be cool to just have a thumbnail and little text..
:thumb:
lunatic
January 11th, 2005, 06:38 PM
Oh, gotchya.
Actually, a while back Senocular was trying to help me get this to work through an xml file, which would be an excellent vehicle for text or photos or what have you. But we got stalled on it and never did get it to work. :(
If someone wants to take another shot at it feel free!
:hr:
scotty
January 12th, 2005, 04:30 AM
Something like this?
scotty(-:
lunatic
January 12th, 2005, 11:06 AM
Darn you! :d: Do you EVER turn off your brain? Do you even sleep anymore? How dare you be so good when others of us are actionscript morons?!
Well, thank goodness you use your powers for good. Beware the dark side Scotty :evil2:
Man that's awesome - thanks for that. :beer:
Now go incorporate it into the resizing slideshow thread. :P
(or figure out how to make it work with xml) :whistle:
FlashPlaya
January 12th, 2005, 12:48 PM
Holy crap!!
Man, you are good.. Thanks so much for this!!!!!! :thumb:
scotty
January 12th, 2005, 02:17 PM
:lol: thank you both :blush:
FlashPlaya
April 5th, 2005, 08:23 PM
Hey Scotty,
I am trying to change the text for each image and I can't figure how to change the text??
I can add one word and works ok, cause of the linkage. But i need to add some different text for each image. Thanks scotty!!:thumb:
FlashPlaya
April 5th, 2005, 08:26 PM
NeverMind:)
I just added a itemText =
and it works great.. Thanks anyways!!
scotty
April 6th, 2005, 03:33 AM
:thumb:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.