A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: dragging a symbol (flash 8)

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Posts
    25

    dragging a symbol (flash 8)

    I've created a movie in which a graphic symbol appears when I press a button, and I was wondering what the code would be that would allow someone to drag the graphic around the screen and place it in a certain spot.

  2. #2
    Island Boy
    Join Date
    Apr 2006
    Posts
    655
    Code:
    myMovieClip.onPress = function(){
       startDrag(this);
    }
    
    myMovieClip.onRelease = function(){
      stopDrag();
    }

  3. #3
    Junior Member
    Join Date
    Oct 2006
    Posts
    25
    I tried using this code but I couldn't get it to work, are there any specifics I need to be aware of? Like where to put it in relation to the image that I want to move around the screen, etc.

  4. #4
    Island Boy
    Join Date
    Apr 2006
    Posts
    655
    it needs to be on the timeline where the image movieclip is. You will need to have instance name on the movieclip and use that instance name in place of the myMovieClip in the code above

  5. #5
    Junior Member
    Join Date
    Oct 2006
    Posts
    25
    I still can't get it to work, and I'm receiving this error message:

    **Error** Symbol=incense, layer=Layer 1, frame=1:Line 1: Statement must appear within on/onClipEvent handler
    incense.onPress = function(){

    **Error** Symbol=incense, layer=Layer 1, frame=1:Line 5: Statement must appear within on/onClipEvent handler
    incense.onRelease = function(){

    Total ActionScript Errors: 2 Reported Errors: 2

  6. #6
    Island Boy
    Join Date
    Apr 2006
    Posts
    655
    can you post your fla so i can look at it? You are probably putting it in the wrong place.

    the code needs to be on the main timeline not attached to the item itself
    Last edited by VI Knight; 10-11-2006 at 01:30 PM.

  7. #7
    Junior Member
    Join Date
    Oct 2006
    Posts
    25
    I tried to upload the fla file but it was way too big. Then I figured out how to get it to work anyway:

    mc.onMouseDown = function()
    { this.startDrag(); }

    _root.onMouseUp = function()
    {
    stopDrag();
    }

    was the code I needed to put on the symbol, but thank you for your help as well.

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