dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [F8] Adding button behavior on the fly

Hybrid View

  1. #1
    Senior Member
    Join Date
    Aug 2000
    Location
    Seoul, South Korea
    Posts
    1,310

    [F8] Adding button behavior on the fly

    Hi all,
    Can anyone suggest the best way to approach the following?
    I currently am trying to load an array of movieclips (one on top of the other):
    Code:
    createEmptyMovieClip("content_holder_mc", this.getNextHighestDepth());
    content_holder_mc._x = 21 
    content_holder_mc._y = 121
    
    for (var i = 0; i<return_query.length; i++) {
        content_holder_mc.attachMovie("blueMovie", "blue"+i, content_holder_mc.getNextHighestDepth(), {_y:content_holder_mc._height+5, _x:5+i});
    }
    This all works fine however is there away of adding an onRelease method to the newly attached movieclips rather than adding the code inside the movieclip itself?

    Cheers
    !.....................................COMING SOON

  2. #2
    All 1s and 0s dmonkey's Avatar
    Join Date
    Nov 2005
    Location
    Leeds, UK
    Posts
    606
    Hi,

    There ceratainly is. When you use 'attachMovie', Flash returns a reference to the clip so that you can assign things to it:

    code:

    var newClip:MovieClip = content_holder_mc.attachMovie("blueMovie", "blue"+i, content_holder_mc.getNextHighestDepth(), {_y:content_holder_mc._height+5, _x:5+i});

    newClip.onRelease = function() {
    //your code here
    }



    Hope this helps.
    "If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton

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