Axelology
Posted At : May 15, 2007 5:01 PM | Posted By : Axel Jensen

Expanding and Contracting Animated Menu In Flex

Space is a big deal in flex... or any kind of interface development. A lot of times you have a menu, with navigation, that takes up a good portion of your screen, and frankly... it sucks... it's like... "where did all my space that I started with go? How did I end up so constrained?"

One thing that you can do is create a Menu using the mx:Menu tag or the Menu() class in flex. It's very nice, and convenient, and I have a couple blog entries on how to use the menu, that I've linked in at the bottom.

VIEW EXAMPLE - SOURCE

But what about when you want to conserve space, and you want your menu to just hover over everything else, but you don't want the same look and feel of the regular Menu Class?

The First thing you need to understand is the Timer Class... the timer class is a fantastic class. You can set repeat counts, delay it, you can find out the current Count... you can do allllll sorts of stuff with the Timer class...

Everything you need to know about the timer class is on live docs... CLICK HERE FOR LIVEDOCS

There are far far too many steps that I would have to write about in writing a tutorial for creating a menu, so i'm just giving you the source, and I'm going to let you go through it. but some of the important things I learned in this were that, you can't focus your mouse events on the menu, you have to focus them on your application. You need a couple of events in your application tag, rollOut, and rollOver, I use those events to tell what object in the application I'm rolling over. To find out what you are rolling over, you can trace(event.target) on those events... rollOut="trace(event.target)" this will tell you what the objects in your application are... I found my ROOT object which happens to be called 'animatedMenu0' in this example application. I can now determine what to do with my timers, and create more logical events in my application...

I created four instances of the sequence class, and they are all the animation I need.

  • initMenuMoveOn
  • initMenuMoveOff
  • initContentMoveOn
  • initContentMoveOff

Each one of these will animate the targets they are bound to.

Conserve Space

The goal of what we want is to CONSERVE SPACE.

How do we do that?

One answer, is to overlay your menu on top of your content and to make it disappear when your not using it.

NOTE: if you try to do this on your own, and notice that background forms, and labels are showing throw your menu, you can just open up your code, and take your menu, and initializer button (the button I use use for my rollOver, to get my Menu visible), take that code, along with the menu, and make sure to place it at the end of your main application page, or at the end of whatever component you want it to show up on top of... this happens because of the AddChild Method... if you put the menu components above the viewstack in your application, the viewstack is added AFTER the menu.

Imagine working with glass, and you lay a BIG SQUARE piece down that is 8 inches by 6 inches (800 x 600 resolution, is what i'm getting at, but lets talk in real world terms)

So you have this big piece of glass, and you have small piece of paper representing your MENU COMPONENT, and you place that ON THE GLASS wherever you would like. By you putting the piece of paper on top of the glass, you are using your own version of the addChild method...

So you take another piece of paper (pretty decent in size, because it represents your CONTENT) and you lay it down on the glass (don't move the menu piece of paper). Now if the two don't occupy the same space, or they happen to be well enough sized that they both fit on the piece of glass, then you don't have a problem. The problem is when they overlap in size, and your content covers your menu. What you have to do is make sure and lay down all of your content first, and then lay down your menu, to make sure it ends up on top of everything else... in hence PUT THE MENU COMPONENTS LAST if you want them to hover over other things in your application. The addChild method will take care of the rest...

Remember the addChild method is you laying down your pieces of paper, to make sure the menu is on top, add it last....

There is one other thing that you might immediately notice with the menu that I'm using. It bounces! What makes it Bounce like that? There is a very simple class (set of classes) that you can use, they are called easing functions.

what you do to use them, is first import the class you want to use, then the effect Object (class) you are using, may or may not have an easing function... All you do is give that easingFunction the Name of the Class You want to use...

import mx.effects.easing.Elastic;

<mx:Resize
widthFrom="0" widthTo="220"
easingFunction="Elastic.easeOut"
/>

It's a little hard to figure out, but documentation is starting to catch up with this one... I know I'm not the first to do it... I think I learned about it from a post on Adobe quick starts.

You can actually open up the source to those classes, and the math is very awesome to see... I just wanna meet the person who originally wrote the stuff... just to call them a genius...

Luckily someone posted a comment this entry, saying who to thank! so I wanted to link to them, they are an absolute genious

Robert Penner!

VIEW EXAMPLE - SOURCE

Related Blog Entries

Comments
I'm guessing you can thank Robert Penner for that.
# Posted By Ryan | 5/18/07 10:57 AM
Absolutely! Thank you for mentioning his name, I ran across it once, but couldn't remember it!

http://www.robertpenner.com/easing/

I will surely add the link to the blog as well!

again thank you
# Posted By Axel | 5/18/07 11:04 AM
http://www.batterylaptoppower.com/sony/pcga-bp2t.h... sony pcga-bp2t battery ,
http://www.batterylaptoppower.com/sony/pcga-bp3t.h... sony pcga-bp3t battery ,
http://www.batterylaptoppower.com/sony/pcga-bp1n.h... sony pcga-bp1n battery ,
http://www.batterylaptoppower.com/sony/pcga-bp7.ht... sony pcga-bp7 battery ,
http://www.batterylaptoppower.com/sony/pcga-bp71.h... sony pcga-bp71 battery ,
http://www.batterylaptoppower.com/sony/pcga-bp71a.... sony pcga-bp71a battery ,
http://www.batterylaptoppower.com/sony/pcga-bp2e.h... sony pcga-bp2e battery ,
http://www.batterylaptoppower.com/sony/vgp-bp2ea.h... sony vgp-bp2ea battery ,
http://www.batterylaptoppower.com/sony/pcg-gr100.h... sony pcg-gr100 battery ,

http://www.batterylaptoppower.com/sony/pcg-gr150.h... sony pcg-gr150 battery ,
http://www.batterylaptoppower.com/sony/pcg-gr250.h... sony pcg-gr250 battery ,
http://www.batterylaptoppower.com/sony/pcg-gr270.h... sony pcg-gr270 battery ,
http://www.batterylaptoppower.com/sony/pcg-c1.htm sony pcg-c1 battery ,
http://www.batterylaptoppower.com/sony/pcga-bp51.h... sony pcga-bp51 battery ,
http://www.batterylaptoppower.com/sony/pcg-505.htm... sony pcg-505 battery ,
http://www.batterylaptoppower.com/sony/pcga-bp2s.h... sony pcga-bp2s battery ,
http://www.batterylaptoppower.com/sony/pcga-bp2sa.... sony pcga-bp2sa battery ,
http://www.batterylaptoppower.com/sony/pcga-r505.h... sony pcga-r505 battery ,

http://www.batterylaptoppower.com/sony/pcga-z505.h... sony pcga-z505 battery ,
http://www.batterylaptoppower.com/sony/pcga-bp4v.h... sony pcga-bp4v battery ,
http://www.batterylaptoppower.com/sony/pcga-bp2v.h... sony pcga-bp2v battery ,
http://www.batterylaptoppower.com/sony/pcga-bp505.... sony pcga-bp505 battery ,
http://www.batterylaptoppower.com/sony/pcg-x505.ht... sony pcg-x505 battery ,
http://www.batterylaptoppower.com/sony/vgp-bps2.ht... sony vgp-bps2 battery ,
http://www.batterylaptoppower.com/sony/vgp-bps2a.h... sony vgp-bps2a battery ,
http://www.batterylaptoppower.com/sony/vgp-bps2b.h... sony vgp-bps2b battery ,
http://www.batterylaptoppower.com/sony/vgp-bps2c.h... sony vgp-bps2c battery ,

http://www.batterylaptoppower.com/sony/pcga-bp2r.h... sony pcga-bp2r battery ,
http://www.batterylaptoppower.com/sony/pcga-bpz52.... sony pcga-bpz52 battery ,
http://www.batterylaptoppower.com/toshiba/pa3285u.... toshiba pa3285u battery ,
http://www.batterylaptoppower.com/toshiba/pa3284u.... toshiba pa3284u battery ,
http://www.batterylaptoppower.com/toshiba/qosmio-g... toshiba qosmio g25 battery ,
http://www.batterylaptoppower.com/toshiba/qosmio-g... toshiba qosmio g20 battery ,
http://www.batterylaptoppower.com/toshiba/pa2510ur... toshiba pa2510ur battery ,
http://www.batterylaptoppower.com/toshiba/pa3010u.... toshiba pa3010u battery ,
http://www.batterylaptoppower.com/toshiba/tecra-80... toshiba tecra 8000 battery ,

http://www.batterylaptoppower.com/toshiba/pa3154u-... toshiba pa3154u-1brs battery ,
http://www.batterylaptoppower.com/toshiba/portege-... toshiba portege 2000 battery ,
http://www.batterylaptoppower.com/toshiba/portege-... toshiba portege r100 battery ,
http://www.batterylaptoppower.com/toshiba/pa3098u.... toshiba pa3098u battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite 1200 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite 3000 battery ,
http://www.batterylaptoppower.com/toshiba/pa3331u.... toshiba pa3331u battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite m30 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite m35 battery ,

http://www.batterylaptoppower.com/toshiba/pa3009ur... toshiba pa3009ur-1bar battery ,
http://www.batterylaptoppower.com/toshiba/tecra-81... toshiba tecra 8100 battery ,
http://www.batterylaptoppower.com/toshiba/pa3465u-... toshiba pa3465u-1brs battery ,
http://www.batterylaptoppower.com/toshiba/pa3399u.... toshiba pa3399u battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite m40 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite m45 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite m50 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite m55 battery ,
http://www.batterylaptoppower.com/toshiba/pa3166u-... toshiba pa3166u-1bas battery ,

http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite 1900 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite 1905 battery ,
http://www.batterylaptoppower.com/toshiba/pa3383u-... toshiba pa3383u-1brs battery ,
http://www.batterylaptoppower.com/toshiba/pa3383u.... toshiba pa3383u battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite a70 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite p30 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite p35 battery ,
http://www.batterylaptoppower.com/toshiba/pa3382u-... toshiba pa3382u-1bas battery ,
http://www.batterylaptoppower.com/toshiba/pa3384u-... toshiba pa3384u-1bas battery ,

http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite a60 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite a65 battery ,
http://www.batterylaptoppower.com/toshiba/pa33842u... toshiba pa33842u-1brs battery ,
http://www.batterylaptoppower.com/toshiba/pa3384u-... toshiba pa3384u-1bas battery ,
http://www.batterylaptoppower.com/toshiba/pa3356u-... toshiba pa3356u-1brs battery ,
http://www.batterylaptoppower.com/toshiba/portege-... toshiba portege m300 battery ,
http://www.batterylaptoppower.com/toshiba/portege-... toshiba portege m500 battery ,
http://www.batterylaptoppower.com/toshiba/pa3128u.... toshiba pa3128u battery ,
http://www.batterylaptoppower.com/toshiba/pa3191u.... toshiba pa3191u battery ,

http://www.batterylaptoppower.com/toshiba/portege-... toshiba portege m200 battery ,
http://www.batterylaptoppower.com/toshiba/portege-... toshiba portege m205 battery ,
http://www.batterylaptoppower.com/toshiba/pa3123-1... toshiba pa3123-1bas battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite 5000 battery ,
http://www.batterylaptoppower.com/toshiba/pa3291u.... toshiba pa3291u battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite p20 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite p25 battery ,
http://www.batterylaptoppower.com/toshiba/pa2487ur... toshiba pa2487ur battery ,
http://www.batterylaptoppower.com/toshiba/pa2487u.... toshiba pa2487u battery ,

http://www.batterylaptoppower.com/toshiba/pa3250u.... toshiba pa3250u battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite 2430 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite a30 battery ,
http://www.batterylaptoppower.com/toshiba/pa3356u-... toshiba pa3356u-1bas battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite a50 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite a55 battery ,
http://www.batterylaptoppower.com/toshiba/pa3399u-... toshiba pa3399u-1bas battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite a100 battery ,
http://www.batterylaptoppower.com/toshiba/satellit... toshiba satellite m100 battery ,
# Posted By acer battery | 10/7/08 4:30 AM



Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.