|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How 2 Dynamic size MCs
I'll try to make this as clear as possible without entering actual code. Not sure if this is an Flash or PHP forum post. I'm pretty sure it's flash.
I am able to load dynamic text from an external php script. I'm using a template system and my variables load fine. The problem I'm having is with the WIDTH. I have a Graphic symbol on the main\top scene and within it (This changes as I work with it) I have movie clips and buttons. I am able to load the data just fine. The WIDTH is my back-stabbing problem. Currently I must make the whole button's width long enough to hold the text that is dynamically loaded. If the text loaded is too small then the whole area of the button is clickable. I want to dynamically resize the width of the button\MC so that all sizes of text are shown and buttons still work. I can't break down the button as it's text that's being loaded. I'm trying to figure out a 'textfield.property' command but not sure what property and where I need to do this at. I've gotten so far and this seems to be the last thing I need to figure out. Thanks in advance to those that can help. Some1 Please help btw |
|
#2
|
|||
|
|||
|
Also, If i make the textfield selectable, i can see that the entire text is loaded from the php. I'm just unable to resize the MC to the correct size to show all of the loaded content.
Any info can help..... |
|
#3
|
|||
|
|||
|
I just spent a good 30 minutes typing up an elaborate post and for some reason DevShed told me I wasn't logged in....enough complaining from me.
If this isn't enough for you, just let me know and I can post more. (I have two possible hacks that I can think of right now) but this little bit of advice should suffice... If the dynamic text box is not in a movie clip, put it in one and control the width that way. From the mc for the text box get the width. (_textBox.width) and create a movie clip with a button in it and set that mc's width to the width you got from the textbox. You can also set the mc's alpha to 0 so it's invisible. I wouldn't do it until you know it's working. Having the alpha at 100 will help you debug. Hope this helps and if you want more let me know I'm too lazy to type out what I had earlier... I know this is a bit general but you seem to know what you are doing so I think my explanation will suffice. If not, just let me know and I can a bit more thorough in my explanation. ~panhead490 |
|
#4
|
|||
|
|||
|
Thanks for the help...big time!
Ok, I 100% understand what I can try to do, I think right now my biggest problem is syntax and getting the vars to set right. some info of what I have right now: my textbox (where text attributes are set): instance name is IndexText, var is _level0.Index Button Above IndexText: Instance name: IndexButton MC above IndexButton: Instance name: Index I'm going to make a textbox (IndexWidth), try to get the value from that (if you don't mind showing an AS example of the right way to do this), Then pass IndexWidth's value to Index. Thanks GREATLY just for tryin to help me with this. |
|
#5
|
||||
|
||||
|
Quote:
Dynamic text box is in Index MC. Quote:
From Index MC get the width (where I think my syntax is fubar, can u show how?), Create Another seperate MC? or another MC within Index MC? Sorry if I'm sounding Real NEWBIE here but I 100% understand the theory of what I'm tryin to do, it's the AS that im learning as i go. Thanks again |
|
#6
|
|||
|
|||
|
Don't sweat the questions...I struggled (and still do) long and hard working with Flash. It's an amazing program but you learn quickly that it's not perfect and requires gentle caressing at times.
I've had to do things 2 or 3 different ways (though from the theory the first way should have worked) before it worked...Anyways, in regards to your question. I had a bit of a difficult time following your description of objects, so if you don't mind I'll rework it here and hopefully explain things well enough. If not, post away Oh real quick, this *assumes* somewhat ignorantly that the mc will be the size of the textbox. If it's the only thing you have in it...then it should work. I think though this is all easy enough to try to make the above assumption.For this you need two movie clips: (I'm going to assume all clips are on the root timeline, mess with it all this way and once it's working , fudge around with it if you want to embed them in other mc's) _textbox - This movie clip only has the dynamic text field in it. However you get the string in there is fine. It shouldn't apply to what we are trying to do here and thus the name of the textbox is irrelevant. _button - This movie clip only needs a button in it. Create a button and fill the over/submit/hit frames and assign whatever action you want to the button. Then on frame 1 of the root timeline get the text in the dynamic text field (however you are doing it) And then in frame 2 (to make sure the text is present in the textfield) add this simple actionscript: _root._button._width = _root._textbox._width; That should do it...test it out and let me know how it goes. If it doesn't work I may have an alternative but it's quite a hack. ~panhead490 |
|
#7
|
|||
|
|||
|
Thanks, Gives me a much better look at things and i'm messin with it now and will give an update.
u mean instance names for _textbox and _button including the _ right? does the _ play a role or that your preference? Big Question of mine. What size should I make the inital _textbox and _button ? Last edited by NooRotic : July 25th, 2003 at 06:55 PM. |
|
#8
|
|||
|
|||
|
Yes they are instance names. The _ is from other programming disciplines. In C++, the _ usually proceeds an instance variable name for a class. Make sure you use the _ for _root and _width...it's required. Otherwise it will think you are referencing some other variable.
Cheers, panhead490 |
|
#9
|
|||
|
|||
|
I'm going to take a 10 min break. Have a few questions i'm running into.
I got the button to resize according to the textbox size. If i'm making the MC's, the 1 with the dynamic var in it, instance name = _textbox , then whatever size I make that MC is what is sent over to _button. I'm still messing with it but issues at hand: What inital height and width to make the MC _textbox and Mc for _button in Flash? I'm assuming I can make the textbox long as the area I'm working with and once the data loads *That* width is what is sent to _button. Right now it's loading whatever size I made the textbox MC. Once again thanks a ton. |
|
#10
|
|||
|
|||
|
It shouldn't matter what size you make them at first...just make sure that once the dynamic text is given to the textfield, that you set the size of button then.
You are noticing a few more assumptions that this hack requires...hopefully in the end you'll be where you want to be =) ~panhead490 |
|
#11
|
|||
|
|||
|
Well, I've got it to resize based on the _textbox field. Problem is that it'll resize it but where it places it is off. The _x and _xscale fields i'm having problems with. The inital size of the clip then it changing it, _button will keep the _xscale value and resize the _width, thus throwing it all off.
I tried to use the createtextfield to create it and it works for plain movie clips. It resizes and places it where I want it to. However, this doesn't help me when it comes to buttons. I hope my explaination is clear. I'll explain more if needed. Thanks |
|
#12
|
|||
|
|||
|
Go ahead and explain a bit more if you don't mind. BTW, why are you using the _xscale value?
I believe you should only be using _width & _height and _x and _y for placement. ~panhead490 |
|
#13
|
|||
|
|||
|
Sorry for the delay.....
Actually I'm not adjusting the _xscale value. I'm only adjusting the _width value right now. I had to make sure that the "focus point" (not sure what it's called in flash) for both the textbox and the button MCs are in the same point. The FP ("focus point") seems to determine the direction that the button extends to (if FP is on the left, button expands to right). I have it opening but for some reason i'm having problems getting the button text to completly fit. Right now there seems to be a margin on both sides of the text that's placed. I hope this is a better explaination. Thanks again for the help. |
|
#14
|
|||
|
|||
|
I noticed that the _textbox._width is not resizing according to the length of the text entered. It's taking the width that the intial frame is set at. I tried again to try using createtextfield but there also it takes the intial size set of the MC not according to the width that is needed to fit the amount of text.
|
|
#15
|
|||
|
|||
|
/me started trying to get to know the Debugger...
I also noticed (not sure how much this matters or if I'm just not reading the results from the debugger correctly)...... I can't get a value to show for _textbox._width or a few other variables\Values if i load them in the "Watch" tab. Added: Also I can edit the color of the _textbox MC and it works, alpha does not.... Last edited by NooRotic : July 28th, 2003 at 10:36 PM. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > How 2 Dynamic size MCs |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|