A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Controlling multiple movie clips with 1 set of code on the main timeline

  1. #1
    Spit
    Join Date
    Oct 2008
    Location
    Philly, PA
    Posts
    51

    Question Controlling multiple movie clips with 1 set of code on the main timeline

    So I have been trying to figure out a way to control multiple clips using the same "on press" & "on release" statements located on 1st frame of main timeline. A variable is being set to a value that correlates to the name of each movie clip as an interaction occurs.

    Ex: user clicks from a selection of buttons & depending on the button clicked it sets clipNum = "1" through "21".

    What I want is to have something like the following code that will give the user the ability to click and drag the clip with code on the main timeline similar to the following:

    _root["drag_" + clipNum].onPress = function () {
    startDrag (_root["drag_" + clipNum]);
    };

    _root["drag_" + clipNum].onRelease = function () {
    _root.ZoneLocking ();
    };

    This code however only works on the buttons and not from the main timeline.

    Any ideas on how I can make this work?

    Thanks,

    Spit

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    The reason it doesn't work is because without a loop, that code only checks clipNum, once. You'll have to assign a loop, to keep checking the clipNum value

    Actionscript Code:
    onEnterFrame = function(){
        _root["drag_" + clipNum].onPress = function () {
            startDrag (_root["drag_" + clipNum]);
        };

        _root["drag_" + clipNum].onRelease = function () {
            _root.ZoneLocking ();
        };
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Spit
    Join Date
    Oct 2008
    Location
    Philly, PA
    Posts
    51
    Thank You!!!

Tags for this Thread

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