dcsimg
A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: dynamically placing movie clips on stage

  1. #1
    Senior Member
    Join Date
    May 2002
    Posts
    132

    dynamically placing movie clips on stage

    Hi I am hoping somone can help me with this problem,

    I had an idea of a project i would like to build and my actinscript has improved a lit so I just need a little help with some of it as I am not sure whether it can be done.

    I create some movie clips and place them in my library only they have not been dragged onto the stage yet.

    What I would like to know is whether I can have a button which once clicked would somehow put the apropriate movieclip i wanted onto the stage in a certain spot so that the user could then drag the movieclip around.

    The whole piont is that I dont want the movie clips on stage at the start I want to be able to select them from a menu or click a button and i get an instance on the stage.

    a good example I have found is http://www.pearldrum.com/dreamkit/index.html

    So just so poeple are clear I want to be able to place clikps onto the stage with the click of a button or from a menu or something and I want to know if it can be done firstly and also what the actionscript is

    Thanx all
    Pixelmagik

  2. #2
    Senior Member sofiebel's Avatar
    Join Date
    Feb 2001
    Posts
    1,044
    This is done with attachMovie:
    Code:
    on (release) {
        this.attachMovie( "circle", "circle1", 2 );
    	circle1._x = 200;
    	circle1._y = 200;
    }
    Create a circle movieclip so it is in the library and not on the stage. In the library, right click its name and choose 'linkage...'. The identifier name in this case is "circle".
    To access the movieclip on the stage, use "circle1", this is now the instance name of the movieclip.

  3. #3
    Senior Member
    Join Date
    May 2002
    Posts
    132
    ok the line that confuses me is the this.

    what is this referring too and y level 2 for a parameter

    What if when it is placed on the stage I want the user to have the abilty to drag it where would i put the startdrag and stopdrag commands or can I assignthem somehow when the movieclip has been placed

    cheers
    pixelmagik

  4. #4
    Senior Member sofiebel's Avatar
    Join Date
    Feb 2001
    Posts
    1,044
    You should create a drag inside the circle movieclip. So you draw a circle and turn it into a movieclip. Inside this movieclip, select the circle again and make another movieclip. Name it 'dragcircle'. So now the movieclip dragcircle is inside the movieclip circle that you will attach as explained above. Open this movieclip and select the movieclip 'dragcircle'. Use the start en stopDrag codes on this movieclip like this:
    Code:
    onClipEvent (mouseDown) {
        _root.circle1.dragcircle.startDrag(lock);
    }
    onClipEvent (mouseUp) {
        _root.circle1.dragcircle.stopDrag();
    }
    Last edited by sofiebel; 12-30-2002 at 08:14 AM.

  5. #5
    Senior Member
    Join Date
    May 2002
    Posts
    132
    ok i did that but it still wont drag so i am not sure what the bug is.

    I have uploaded it here so u might have a sneek peek and tell me why the code ist working

    Cheers Pixelmagik

    tis in mac format so i hope u can read it!!
    Attached Files Attached Files

  6. #6
    Senior Member sofiebel's Avatar
    Join Date
    Feb 2001
    Posts
    1,044
    Can't, I'm on pc. Can you read a pc file, 'cause I could send you an example.

  7. #7
    Senior Member
    Join Date
    May 2002
    Posts
    132
    yes that is no problem on my end so if u have an example I would be mosy grateful

    Cheers Pixelmagik

  8. #8
    Senior Member sofiebel's Avatar
    Join Date
    Feb 2001
    Posts
    1,044
    Try this.
    Attached Files Attached Files

  9. #9
    Senior Member
    Join Date
    May 2002
    Posts
    132
    i had this problem a few weeks ago someone posted a file and when i clicked on the blahblha.fla link i got a attachment .php and couldnt open it. If possible could u please email it to me at pixelmagikau@yahoo.com.au


    Much appreciated

    Pixelmagik

  10. #10
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Hi...
    I've just spent the weekend looking at a similar thing.

    As for placing movieClips in a certain place on the stage.

    Create a empty movie clip and drag from libary on to the stage.
    Give the empty movie clip an instance name, say , 'myClip'
    then use the attachMovie method

    i.e. myClip.attachMovie("yourMC", "yourMC", 1);

    or you may need to use:-

    _root.myClip.attachMovie("yourMC", "yourMC", 1);

    That bit should cause little problem. just remember when you
    create your empty movie to set properties export for action
    script.
    --------------------------------------------------------------------
    experiament with this code to drag movie around. Not too sure
    on this bit.

    startDrag ("myClip", true);
    Mouse.hide();
    If someone tells you it can't be done,
    it's probally because they don't know how.

  11. #11
    Senior Member
    Join Date
    May 2002
    Posts
    132
    OK, Awesome,

    Recieved file and all is working,

    Just curious

    the first few posts you suggested that i make a movie clip inside the first circle clip and use the mouseUp and mouseDown commands for the clip.

    When I checkd that file you sent to me you had used a button inside instead any reason for that, was it because the movieclip idead wasnt working or can it still be done both ways.

    just curious

    Cheers pixelmagik

  12. #12
    Senior Member sofiebel's Avatar
    Join Date
    Feb 2001
    Posts
    1,044
    I guess you can use both, but the buttons make it easier when you want to use lots of buttons and drag them around the stage. I ran into problems with the movieclips when I started using more then 1. Changing it to buttons did the trick.

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