A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: attach to mouse within specified coordinates

  1. #1
    Flashkit Witch Azaraelle's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    123
    I have created a scratch card and now want to attach a coin to the mouse if the mouse is within certain coordinates and have the coin un-attach itself once the mouse leaves the specified coordinates. How do i do this?

    I used startDrag ("coin", true, 56.0, 118.0, 272.0, 330.0); but then the user can't click on anything outside of this block.

    Please help!

  2. #2
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    try this;
    1. make sure the coin is in an MC;
    2. place the MC on the main stage.
    3. right-click on the MC and select actions
    4. enter;
    Code:
    onClipEvent(load) {
       leftMargin = 100;
       rightMargin= 300;
       topMargin = 100;
       bottomMargin = 400;
    }
    onClipEvent(enterFrame) {
      if (_parent._xmouse > leftMargin &&
          _parent._xmouse < rightMargin &&
          _parent._ymouse > topMargin &&
          _parent._ymouse < bottomMargin ) {
         _x = _parent._xmouse;
         _y = _parent._ymouse;
      }
    }
    change the margin values to suite your needs
    hope this helps
    BlinkOk

  3. #3
    Flashkit Witch Azaraelle's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    123
    The coin is in a movie clip called coin but the script is giving me this error...

    Scene=Scene 1, Layer=Layer 10, Frame=1: Line 1: Clip events are permitted only for movie clip instances
    onClipEvent(load) {

    Scene=Scene 1, Layer=Layer 10, Frame=1: Line 7: Clip events are permitted only for movie clip instances
    onClipEvent(enterFrame) {

    Generator is not enabled for this movie. C:\Projects\flash\scratch card\scratch2.swf

    also, I expect I will have to specify a startDrag on the movie clip, where does this go in the code and what is the syntax?

  4. #4
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    3. right-click on the MC and select actions
    you need to right-click (not left-click) on the movie on the stage. one of the options from the pop-up menu will be Actions. Select Actions and paste the code there not in a frame. you don't need to use startDrag() the movie's _x/_y will change every time ther is a new frame.
    hope this helps

  5. #5
    Flashkit Witch Azaraelle's Avatar
    Join Date
    Nov 2000
    Location
    South Africa
    Posts
    123
    Thankyou! Thankyou! Thankyou! It works!



    I was putting it on a frame.

  6. #6
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    i think ed_mack and phreax are the real heros but i'll take what i can get. now don't go mad with all that scratching, you'll get a rash!

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