A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: StartDrag=WTF?

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Location
    Asstown
    Posts
    107

    StartDrag=WTF?

    ERm...
    I dont see ANYTHING wrong with this fla. For some reason i put this on a button:
    code:

    on (press) {
    startDrag(this);
    }
    on (release) {
    stopDrag();
    }


    And everything in the movie starts dragging, even thigns that arent symbols. Please help this has to be the biggest WTF question.

    please help this is a huge headache.
    I attached the fla with it (MX format)
    Attached Files Attached Files
    What's a siggy?
    /oh...

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

    There is the startDrag(), a global function, that receives the target path to a movie clip as the first argument (movie clip, not button!).

    And there is MovieClip.startDrag(), a method of the MovieClip class (not button!).

    So, that will never work with buttons, unless you add the startDrag() method to the Button class:
    code:

    Button.prototype.startDrag = MovieClip.prototype.startDrag;



    Now there is still another problem:
    movie clips and buttons have different scopes, and this attached to a movie clip refers to it, but attached to a button refers to the timeline the button is in. (that's why everything moves, you're dragging the movie clip the button is in, (possibly the main timeline))

    There is a workaround: using flash MX method's syntax:
    code:

    my_btn.onPress = function()
    {
    this.startDrag();
    };


    because this, in this case, refers to the object the method is applyed to.

  3. #3
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    I changed your 'dragger' from a button to a movieClip symbol and it works fine then.

    Dallas

  4. #4
    Senior Member
    Join Date
    Feb 2003
    Location
    Asstown
    Posts
    107
    Originally posted by DallasNYC
    I changed your 'dragger' from a button to a movieClip symbol and it works fine then.

    Dallas
    since when do on(press), on(release) actions work with MCs?
    What's a siggy?
    /oh...

  5. #5
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    are you using MX? did you try it?

  6. #6
    Senior Member
    Join Date
    Feb 2003
    Location
    Asstown
    Posts
    107
    Originally posted by DallasNYC
    are you using MX? did you try it?
    It works on 2k4...I was just wondering because i remember i think flash mx (not 2004) did not support on actions on MCs. Just onClipEvent() actions.
    O well i learned something.
    What's a siggy?
    /oh...

  7. #7
    FK's Giant Steve_w_V's Avatar
    Join Date
    Mar 2003
    Location
    San Jose, California
    Posts
    2,113
    You can use on() events on the MC:
    code:
    //on the clip
    onClipEvent(load){
    onPress()
    onRelease()
    onRollOver()
    onRollOut()
    }
    //now you can use the on() events directly on the MC.
    on(press){
    startDrag(this, true)
    }
    on(release){
    this.stopDrag()
    }

    The other day, I bought a box of animal crackers. On the side, it said "Do Not Eat if Seal is Broken". I opened the box and sure enough...

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