A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: What's with buttons?!?

  1. #1
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834

    What's with buttons?!?

    Could someone explain to me what's the point of even considering using buttons over movieclips. With the movieclip you can incorporate the same functionality.
    For a button it's this: on (press) {
    For a movieclip it's this: onPress = function(){
    The only reason I can see for it's existence is for newbies because of the lessened code requirement. Other then that I don't see any advantage.
    .

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    I agree with you. When I have to create something more complex, using ActionScript, I always use Movie Clips.
    For example, using a Movie Clip, I can maintain a "down" state.

    But, Buttons are great for simple tasks and simple animation, as they have the 3 states predifined, and you don't need to create your own code to control them.

    Notice that using on (something) VS onSomething() is not really a difference. It's not true. You can use both in each case.
    The thing is on (something) is attached to the Object (Button or Movie Clip) - Flash 5 style - while onSomething() is attached to the timeline - Flash MX style.
    Take into account that using methods onSomething() is considered a better practice. You don't have to spread code all over your Objects. You can have all the code attached to a timeline.
    Last edited by nunomira; 02-23-2007 at 10:01 AM.

  3. #3
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Well Buttons are simple templates with 4 defined states (3 visible). If you do this with a movieclip, you have to handle the states. Also, a button acts like it is on the same level, so lets say we have one button and one movieclip on the main time line.

    Button:
    on(release){
    gotoAndStop(5)
    }
    will cause the main timeline to go to frame 5.

    Movie Clip:
    on(release){
    gotoAndStop(5)
    }
    would cause that movieclip to go to frame 5. to do the root, you would have to:
    Movie Clip:
    on(release){
    _parent.gotoAndStop(5)
    //or
    _root.gotoAndStop(5);
    }

    So the short answer is buttons are just a simple control mechanism, movieclips require a bit more work.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    I guess that shows about how much my usage of templates has been. In other words, I don't really use templates or buttons. Can anyone blame me for seeing button usage as a newbie thing?
    .

  5. #5
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    Do what ever you are comfortable with.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  6. #6
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    It's not exactly a newbies thing.
    Buttons and Movie Clips have their own use. Why would I waste time doing something with a Movie Clip when only a Button is required?

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