A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Dynamicaaly create button/movieclip

  1. #1
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234

    Dynamicaaly create button/movieclip

    Hi,

    I was wondering if the next is possible and how it would be possible. I want to create buttons dynamically with code. So not attaching a mc form the library but create one! Well there is no such thing as createButton() right? So I thought maybe with createEmptyMovieClip. But is there a way to 'fill in' multiple frames with dynamic created stuff...? I want to create a movieclip in which the first frame is the up state, the second is the over state etc etc...

    Cheers,
    Bart
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  2. #2
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    Just something I came up with quickly that could probably be improved...

    Single button....
    code:

    myButton = _root.createEmptyMovieClip("button", 10);
    with (myButton) {
    lineStyle(2, 0xFF0000);
    beginFill(0xFF0000, 50);
    moveTo(200, 200);
    lineTo(250, 200);
    lineTo(250, 250);
    lineTo(200, 250);
    lineTo(200, 200);
    endFill();
    }
    myButton.onRollOver = function() {
    trace("Mouse is on me!");
    myButton.clear();
    with (myButton) {
    lineStyle(2, 0xFF0000);
    beginFill(0x0000FF, 100);
    moveTo(200, 200);
    lineTo(250, 200);
    lineTo(250, 250);
    lineTo(200, 250);
    lineTo(200, 200);
    endFill();
    }
    }
    myButton.onRollOut = function() {
    trace("Mouse is off me!");
    myButton.clear();
    with (myButton) {
    lineStyle(2, 0xFF0000);
    beginFill(0xFF0000, 50);
    moveTo(200, 200);
    lineTo(250, 200);
    lineTo(250, 250);
    lineTo(200, 250);
    lineTo(200, 200);
    endFill();
    }
    }
    myButton.onPress = function() {
    trace("I was pressed");
    }
    myButton.onRelease = myButton.onReleaseOutside=function () {
    trace("I was released");
    }



  3. #3
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    Very nice... this will work perfectly for me!

    Thanx a million!!!
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  4. #4
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    Is there a way to do a line2fill with coding? The corners are rounded with lineTo...
    I know I know... mr pixel perfect but just wondering!

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  5. #5
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Not sure what your referring to. Maybe try a thinner lineStyle....

    lineStyle(1, 0xFF0000);

    The value 0 indicates hairline thickness; the maximum thickness is 255.

  6. #6
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    Alright thanx, I treid with 1.... but ofcourse didn't think of 0!

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

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