2008
accordion class – flash actionscript3 (as3)
in flash as3 you don’t have any accordion component, not that i like using those components,i’d prefer use a nicely written code instead :)
so there i was looking for a vertical accordion for one of my works, i came accross this nice class, that does everything in a very simple code. the only problem i found it that it had only a horizontal version…
looking at the comments i saw there is a need for a vertical one,
so i fixed the code in a way that it can work both ways.
the new accordion constructor has an extra of 2 parameters :
public function accordion($width:Number, $height:Number, panelNumber:Number=0, navWidth:Number=0,navHeight:Number=0,allignment:Boolean=false)
the navHeight – represent the height of the navigation panel for Vertical mode,
and the alignment flag – false is for horizontal, and true … welp you’ll figure that out yourself.
the only thing left open in working with 2 accordions one inside the other :), i’ve managed to get that one going, but there is a problem with something not allowing the inner accordions btns to work as supposed. i’ll try to give it my time soon.
anyway great thanks to the one who wrote it, feel free to give the original page a visit.
download the sourcecode for my version : vertical and horizontal accordion source code











Thank you very much for this blog post this is a great accordion the best one Ive found online thats easy to use.
Great work. Stupid question, but how do you actually customise it to have your own content on each slide?
inside your flash , in the library section you can see 2 sample movieclips
one for the panel, and one for the content.
build your own movieclips, name them and then in the code file , place your names instead of the samplePanel and sampleContent movieclips.
at the moment, this accordion actually kinda fixed to the sizes mentioned on the constructor (when you first create a new instance)
i have a minpulated version of it, more user friendly one, i need to fix some last issues on and post it here.
let me know if you handled it.
Don’t you into problems naming your classes without a Capital letter at the start? That’s one of the first basics of object oriented programming.
Thanks very much! Should have known that really… or at least fiddled a bit more before asking. But this time I have a question I am truly stumped on.
I am trying to add a hover button inside the navigation buttons – a simple little thing so that when I move my mouse over the buttons the text changes colour. A simple button symbol doesn’t work which I expected – but I am also having quite a bit of trouble doing this with code.
Any ideas?
Thanks a lot in advance.
Pat.
Thank you very much! Need this one for a project, I’m happy finding scuh nice solution in here! :_)
Excellent script m8 thanks for sharing.
Hi, first I have to thanks for this gr8 script.
I am just a beginner for actionscript. Could you pls explain how to give a link (get url) for each panel images?
Excellent template to work from – thanks a bunch! Hope to return the favor sometime.
Very good working, i will say such should be encouraged.
thnkx
Thank You. It’s very good.
Great accordion, good work!
I’m fairly new to AS3, could you let me know how I would make a panel content close if I click on the same panel that opened it…
If thats possible
Thanks
Chris
man i havn’t touched that script for ages,
i started working on an improved version months ago, but its still a work in progress, so i guess you will need to solve that one by your self.
You my friend have just saved me a lot of time, thank you!
hey there,
was just messing with your script and was wondering..where is the part where you’re duplicating the menus? Can’t seem to figure it out.
thanks!
-aof