1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Adobe Flash "Lock-on" question

Discussion in 'Graphics & Multimedia' started by Tudi, Jan 11, 2008.

  1. #1
    Does anyone here know how to create a lock-on effect in Flash?

    I'm talking about dragging an object with the mouse and if you release it over a specific area, it would lock on in the right position.

    Here's an example of what I'm talking about (the way the clothes stick to the girl):

    http://www.onlydressupgames.com/dress-up-raya.php

    Any suggestions on how I should script this, what predefined functions to use, etc. are more than welcome :) Thanks.
     
    Tudi, Jan 11, 2008 IP
  2. wassim

    wassim Well-Known Member

    Messages:
    322
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Hi,

    the ._droptarget property is what you need:

    Here's a code snipet :

    The following example evaluates the _droptarget property of the garbage_mc movie clip instance and uses eval() to convert it from slash syntax to a dot syntax reference. The garbage_mc reference is then compared to the reference to the trashcan_mc movie clip instance. If the two references are equivalent, the visibility of garbage_mc is set to false. If they are not equivalent, the garbage instance resets to its original position.

    origX = garbage_mc._x;
    origY = garbage_mc._y;
    garbage_mc.onPress = function() {
    this.startDrag();
    };
    garbage_mc.onRelease = function() {
    this.stopDrag();
    if (eval(this._droptarget) == trashcan_mc) {
    this._visible = false;
    } else {
    this._x = origX;
    this._y = origY;
    }
    };


    You are welcome :)
     
    wassim, Jan 12, 2008 IP
    Tudi likes this.