FORUMS: list search recent posts

Smarter way of creating instances of buttons with animation

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sergio Pol
Smarter way of creating instances of buttons with animation
on Mar 30, 2017 at 2:54:11 pm

Hi there, I'm currently struggling with this issue. I have buttons that consist of a rectangle and text. On the "over" state the rectangle has a movie clip where the rectangle jumps and grows in height. In the process the text inside does the same but changes layout. At first it's written in a single line horizontally but when the rectangle grows the text divides in two lines. The thing is that I need to duplicate the button so I change the text and the color of the rectangle but the process is really tedious. I have to create instances of every object inside the button. That is a copy of the "over" movie clip and copies of the two tweens that are needed for the text to behave like that. All that for every button in the scene -I will need from 8 to 10 buttons-. I was wondering if there would be a more practical way to do this. At first I thought of having the text inside the movie clip be dynamic and that thru code I could tell it to change to mimic the text on the "up" state. Is that too absurd? Thanks for your help.


Return to posts index

Sam Mattern
Re: Smarter way of creating instances of buttons with animation
on Mar 31, 2017 at 1:23:38 pm

I may be misunderstanding the issue, but as long as all of the objects inside of your button have an instance name and your button has an instance name, you should be able to duplicate your button, change the instance name of that new button, and be able to address them separately.

You'll know if the instance name is set on the text box inside the button right away if you duplicate the button and try to change the text. If it changes it on both buttons, the instance name on the text box is not set. You select the text box and set it in the properties panel. I think the property is called instance name, could be something else. It's been a while. The only "gotcha" is that if you draw a box, for instance, you need to convert it to an object like a graphic or movieclip in order to give it a unique instance name.

I found that addressing everything from code, although more setup, gives you better control in the long run. You could set up a button class with variables to hold your different button texts. Then set it in code when creating the buttons.

button0 = new myButton();
button0.state0 = "First Text State";
button0.state1 = "Second Text State";


-Sam


Return to posts index

Sergio Pol
Re: Smarter way of creating instances of buttons with animation
on Apr 1, 2017 at 12:09:54 am

Ok Sam I see where you are going there, that's more or last what I was looking for. However I still don't get the idea of generating interface elements with code. I know you can place them where you need them via code too but it can be a lot of work determining exactly where I need them to be. Or maybe I'm not understanding the process. As I understand those buttons would be created on the run not while authoring right? I would need to test the movie and check whether they were created and if they were created correctly, and then getting into the code and change their properties so they have the color, position, etc that I need, is that right?


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]