FORUMS: list search recent posts

Making an expanding and collapsing box

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ben Mettler
Making an expanding and collapsing box
on Apr 24, 2013 at 6:31:07 pm

I'm trying to figure out how to create a simple box that has text in it that opens when a button is clicked and then closes when a close button is clicked. I thought this would be easy to research online but I haven't found any tutorials or direction that shows me how to do this. Does anyone have any links or step by step directions.

I attached an image to get a better idea of what I'm talking about.



Return to posts index

demetri tashie
Re: Making an expanding and collapsing box
on Apr 24, 2013 at 8:52:57 pm

This is most easily done with a Tweening engine, like greensock's TweenLite.

There has to be some strategy to how to approach this. Of course there are different ways.

One way is to make your text box, and turn it into a movieclip symbol, and give it an instance name of, say 'textBox_mc'. Make another moveclip symbol to act as your open button, and give it an instance name of, say. 'open_btn_mc', and make another for your close button with the instance name 'close_btn_mc'

you need to import the TweenLite class ( follow the easy instructions on their site).

if the 'textBox_mc' when created has a height of, say 200px, you should set its initial height to maybe 0.

then addEventListeners to 'open_btn_mc' to initiate a function to:
- tween the height of the textBox_mc back to 200px over, say .5 seconds.

add another EventListener to 'close-btn-mc' and have its function tween the height back to 0

that's it in its simplest form, and should be enough to play around with.


Return to posts index

Ben Mettler
Re: Making an expanding and collapsing box
on Apr 24, 2013 at 9:27:35 pm

I actually figure out the first part and got the box to load but now I'm having trouble close the box again. So I have the Popup MC load in to an empty MC in the main scene. In the Popup MC I have another MC "ClosePop1" with the AS:

on (release) {
this.removeMovieclip("Popup");
}

It's not closing the Popup MC. What am I missing?


Return to posts index


demetri tashie
Re: Making an expanding and collapsing box
on Apr 25, 2013 at 2:57:06 am

Hi, sorry, i see you are using AS2, which i do not support. Hopefully someone else can help you with that.
good luck.

ps: do give as3 a try


Return to posts index

Ben Mettler
Re: Making an expanding and collapsing box
on Apr 29, 2013 at 4:27:10 pm

So I found a tutorial (http://www.danfergusdesign.com/classfil ... ildren.php) on adding and removing children. I got the first part to work when the MC just loads to the stage. When I tried adding the button to add the MC to the stage I got two errors:

Scene 1 1046: Type was not found or was not a compile-time constant: loadMC_btn.
Scene 1, Layer 'as', Frame 1, Line 4 1120: Access of undefined property removeMC_Btn.

This is my AS:

var Popup1Instance:Popup1 = new Popup1();
var mcOnStage:Boolean=false;
loadMC_btn.addEventListener(MouseEvent.CLICK, loadMC);
removeMC_btn.addEventListener(MouseEvent.CLICK, removeMC);

function loadMC(MouseEvent):void {
addChild(Popup1Instance);
Popup1Instance.x=790;
Popup1Instance.y=350;
mcOnStage=true;
}

function removeMC(MouseEvent):void {
if (mcOnStage ) {
removeChild(Popup1Instance);
mcOnStage=false;
}
}


Return to posts index

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