A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: attaching scripts to duplicate movies

  1. #1
    Senior Member
    Join Date
    Dec 2001
    Posts
    169

    attaching scripts to duplicate movies

    im wondering if theres a way to attach a this.onEnterFrame blah blah blah script onto duplicated movieclips..

    dont really like to spread my scripts around to keep my stuff neat, but i cant get a way round duplicated movieclips..
    -s7N
    ___________________________________
    time you enjoy wasting, isnt wasted

  2. #2
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    try this:
    PHP Code:
    var dupl:MovieClip=org.duplicateMovieClip("new",1);
    dupl.onEnterFrame=myFunction;
    function 
    myFunction () {
        
    trace("bla");


  3. #3
    Senior Member
    Join Date
    Dec 2001
    Posts
    169
    hi, thanks for replying.
    hmm.. i think the way you suggesting is the same way i tried in the first place.. but for just one movieclip its okay, but i am planning to duplicate like 100s of movieclips, thats why i am looking for a way to -attach- a this.onEnterFrame script to them.. =o i mean, i can't possibly give an instance name to everyone of them then every enter frame run a loop to all the instance names right?
    -s7N
    ___________________________________
    time you enjoy wasting, isnt wasted

  4. #4
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    Not really..
    When you duplicate the movieclip, you attach the onEnterFrame action.
    Why would you need that instance name again, as the function is
    already applied?
    Like for removing the onEnterFrame command?

    For reusing hundrets of MovieClips i would suggest the following:
    PHP Code:
    var myMCs:Array = new Array();
    for(var 
    i:Number=0i<100;i++){
      var 
    dupl:MovieClip=org.duplicateMovieClip("new"+i,i);
      
    dupl.onEnterFrame=myFunction;
      
    myMCs.push(dupl);
    }
    function 
    myFunction () {
        
    trace("bla");
    }

    // reuse:
    var tmp:MovieClip;
    for(var 
    s:String in myMCs){
      
    tmp=myMCs[s];

    Is that more like you are looking for?

  5. #5
    Senior Member
    Join Date
    Dec 2001
    Posts
    169
    thanks. i guess thats the only way to do this.. thou i still got abit of problems with it, lemme play around with it
    -s7N
    ___________________________________
    time you enjoy wasting, isnt wasted

  6. #6
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    Just keep asking if you're stuck.
    Maybe showing your source might help to understand
    what you are trying to achieve.

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