A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Draggin MC's

  1. #1
    Member
    Join Date
    Feb 2001
    Posts
    43
    flash 5 question. I went to the tutorials and saw one drag and drop tutorial and it absolutely sucked. So if any of you can give me easy to understand directions on how to drag and drop a movie clip please let me know. What im trying to do is have a movie clip that plays within my main movie and the user should be able to click on the MC and drag it and drop it wherever they want.....thnx in advanced

  2. #2
    Old dog learning new tricks

    Join Date
    Dec 2000
    Posts
    1,498
    Allright, r u completely awake? (lol)
    At first we create the mc. Example: a pink rectangle 100x200 with text in it. Somewhere (let's say on the top left corner) we place a button. It can be invisible or not.
    We asign an action:
    on (press) {
    startDrag ("_root.aclipname");
    }
    on (release) {
    stopDrag ();
    }

    We place the clip in the main timeline and name it "aclipname".
    The sensitive draging area depends on the size of the button
    This is it.
    Peace

  3. #3
    Member
    Join Date
    Feb 2001
    Posts
    43
    Well I followed your directions VERBATIM, and have just a few questions.. You say create a new movie clip and put some text on it and a button. Now does my text and button need to be on seperate layers or can they all be on the same layer. I gave the button that i placed on the MC the actions you described but did not see the _root command anywhere so i just typed it in. "could that be a part of the problem??" Secondly, once i place the MC on my main movie and try to test teh movie it like resizes the movie to HUGE porportions. I sized the MC to 100x200 but it doesnt seem to change the size on the work area, so therefore im to assume it is actually not changing. How do i change the size of the MC once i start to create it. I hope im making sense because i recall your help with the sound movie clip i made and the directions were RIGHT ON... thnx for the help in advance

  4. #4
    Old dog learning new tricks

    Join Date
    Dec 2000
    Posts
    1,498
    OK,
    at first it's good to put different objects in separate layers. An object in a layer can be turned off, locked, go behind and front and deleted without affect the others.
    Secondly the _root is the main timeline as a path. It can be found if u press the target symbol. The target symbol is activated when a target needed to be defined.
    So when we want to define which clip must be draged we use _root(the main timeline).theclip(the name of the clip contained in the main timeline). It's like directories.
    Now let's start from the begining.
    In the maintimeline:
    Create a rectangle 100x200 in a new layer. The dimensions can be defined by the info panel.
    Press F8 to convert it to a movieclip symbol with the name "rect".
    From the Instance panel name it "myclip".
    Open the Library and doubleclick the "rect" in order to edit it.

    Now we are in the rect's timeline:
    Create a new layer.
    Draw a reactangle with a different color in the upper left corner.
    Press F8 and convert it to a button.
    Select the button NOT THE FRAME and add the script:
    on (press) {
    startDrag ("_root.myclip");
    }
    on (release) {
    stopDrag ();
    }

    (When u select the start drag action, in the bottom right corner of the actions panel, u see the target symbol activated. Press it and from the new panel select dots and absolute path. U'll see the structure of the mc's in the timeline).
    Return to the main timeline.
    U r ready.
    As far as the huge dimensions of the clip, learn to use the info panel. There u can see the actual dimensions and the position of an object.
    Take care and if u have another question feel free to ask

  5. #5
    Member
    Join Date
    Feb 2001
    Posts
    43
    OK, i got it to work but still had to type out the _root. I dont think i quite understood you on where the target symbol thing was so if you could tell me again that would be great so i dont have to type it out all the time and im sure there will be other commands there im missing as well. And I really do want to thank you for the time you have put into answering my questions out of all the answers ive gotten you are the one that has been right on with my questions. Ty so very much and im sure ill have a posting everyday..Newbies are sometimes a pain but we all appreciate what you do for us

  6. #6
    Old dog learning new tricks

    Join Date
    Dec 2000
    Posts
    1,498
    U know, when I discovered Flashkit I had a little expirience in using Flash, so I didn't use it much. But each time I was stuck and sent a question, there was always someone to answer. And I feel obliged to do the same. And the wonderful thing is that there r many others who feel the same. So don't worry, u'r among friends.
    Now,
    Create a new file and in the first frame draw a rectangle.
    Press F8 and convert it to a movie clip.
    Open the Instance panel, select the mc in your stage and name it "clip".
    Create a new layer, draw acircle and convert it to a button.
    Select the button and open the action panel.
    Asign the onrelease action and then the telltarget.
    At the bottom right corner u'll see a target symbol and an arrow. If it points to the bottom, press it and a textfield with the name "target" will appear. If u put the cursor in the text field, the target symbol is activated. Press it and the "insert target path" panel will open.
    There, be sure that the notation is Dots and the mode is Absolute. In a window y'll see the structure in directory like appearence, with the _root (represents your movie) as the main folder and the "clip" hanging from it as a subfolder. If u press the "clip", your target path will automaticaly be inserted in your script: _root.clip
    If u have any problems post a reply.
    Take care

  7. #7

    Ohhhhhh Ahhhhhh...

    I put a pretty neat spin on my movie. Instead of just putting the button in the corner of the movie, I gave it all the same actions and everything, editted the mc, and put the button on a layer behind it!

    So now all you would hae to do is click on the mc, not like find the button and do it, because when I did it, you would have to click on the button and the mc would like jump over to your cursor.

    One more question, can you tell me a little bit about target areas? I would like to drag and then drop some stuff into target areas.

  8. #8
    Member
    Join Date
    Feb 2001
    Posts
    43
    That was the answer to finding the _root.clip for sure. It was the absolute radio that needed to be clicked to get it to say _root. Thnx again for the great response and being right on target with what i am needing to do. I will play with it and come up with some more questions soon im sure..

  9. #9
    Old dog learning new tricks

    Join Date
    Dec 2000
    Posts
    1,498

    Target areas

    Hi guys it's me again...
    There is a tutorial about target areas but the principle is this:
    We have an mc (named as "Bob" in the main timeline) and we want to drag it and to drop it in a certain area in the stage. So we must define in some way this area. One way to do this is to make a movie clip with the dimension we want (named as "Helen" in the main timeline). All we've got to do now is to check that if Bob is droped is on top of Helen or not (kinky example). And if it is it's ok, if it's not to return to its original place.
    So we need to get the original coordinates of Bob in the first frame:
    x_pos = Bob._x;
    y_pos = Bob._y;
    And then when Bob is droped to check if its droped on Helen:
    if (eval(Bob._droptarget) <> _root.Helen)
    Bob._x = x_pos;
    Bob._y = y_pos;
    }
    I think that's it in general (hope I don't forget anything).
    Peace

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