dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Movie Clip Button With Changing Hit Areas?

  1. #1
    Sponge brain square head
    Join Date
    Nov 2005
    Location
    Northwestern New Jersey
    Posts
    8

    Movie Clip Button With Changing Hit Areas?

    Hi all,

    The title pretty much describes the basics of what I'm trying to do. More specifically, I want to make a movieclip button that can have either 4, 3, or 2 hit areas depending on the state the button is in.

    For a visual, if you can imagine a small personal pizza cut into either 4 slices, 3 slices, or right down the middle into 2 slices, and each of the slices is clickable, that's more or less what I'm trying to do.

    I was able to get the multiple hit area scheme to work for the 4 hit area version by making 4 movie clips shaped like the slices and naming them hitNorth_mc, hitEast_mc, etc., and each of them in a parent movieclip. I used _parent.hitArea = this in each one. I then embeded all 4 in one parent movie clip, just like you would put the 4 slices of pizza back in the box. The end result is a movieclip button with 4 hit areas.

    So now the delemma is getting that button to switch to a 3 hit area version and a 2 hit area version. Should I make separate 3 and 2 hit area movie clips and swap them around? Or is there a way to define all of that in one movie clip? maybe different states named _up1, _over1, _down1, _up2, _over2, _down2, _up3, _over3, and _down3? Any ideas as to the best approach?

    Thnaks to anyone who can help!

  2. #2
    Not really Fat... or a Cat ^_^
    Join Date
    Feb 2006
    Posts
    63
    You know, just by thinking about the pizza slice buttons made me hungry...

    The idea is way cool, but to make it work by code only will be a ***** -at least for me 'cuz I'm no code warrior.

    The way I see it, is to use several button versions and swap them arround like you said.

    But instead of using hitTest code use plain old buttons, make one button for each slice and then put those button together in a "pizza box" mc like you did.
    The buttons will work just as fine from inside the box.

    Now if you have slices a, b, c, d, and e (for example)

    You can make "pizza box a" with slices a,d and e. "pizza box b" with slices a, c, and d and so on.

    Beware that if you are anything like me you'll probably want to make shure that every pizza inside a box is full and without empty spots.

    So you may want to think of every pizzabox as a button itself and design it so it's a circle divided in thirds or fifths or whatever and then put each slice into a separated button inside the pizzabox.

    At the time of coding each idividual button you can make it point to wherever you want so individual shapes have no relevancy.

    This way is more work and less lean in terms of Kb, but produce full pizzas everytime.

    ---Hope this helps.
    What are you going to do about it?... There's gotta be people for everything --Joan Manoel Serrat

  3. #3
    Sponge brain square head
    Join Date
    Nov 2005
    Location
    Northwestern New Jersey
    Posts
    8
    Quote Originally Posted by FatCat
    The way I see it, is to use several button versions and swap them arround like you said.

    But instead of using hitTest code use plain old buttons, make one button for each slice and then put those button together in a "pizza box" mc like you did.
    The buttons will work just as fine from inside the box.

    Now if you have slices a, b, c, d, and e (for example)

    You can make "pizza box a" with slices a,d and e. "pizza box b" with slices a, c, and d and so on.
    So there's basically two approaches:
    1. I can either make 3 separate "pizza box" movie clips with 4, 3, and 2 buttons respectively and then use code to swap them around as needed.
    2. I can make a movie clip with 3 named sections of frame and put 4 buttons in the first set, 3 in the second, and 2 in the last and then use some sort of goToAndStop() or goToAndPlay() or whatever code to chage the portion of the movie clip that is showing.

    Ok, so I think I can handle 1, but 2 just seems so much more elegant. Any ideas why it wouldn't work?

  4. #4
    Not really Fat... or a Cat ^_^
    Join Date
    Feb 2006
    Posts
    63
    Hi snarklops, hope you are well:

    If I were you I'd go for case 1 (in code: less is more)

    Case 2 seems to me more troubling than elegant because you'll have to juggle the code for the buttons and the code to move the pizzabox_mc timeline around, it sure can be done, but sounds like it's easy to get messy.

    It's your call in any case.

    --Ganbare
    What are you going to do about it?... There's gotta be people for everything --Joan Manoel Serrat

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center