A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Attaching a MC from a library and setting its X and Y

  1. #1
    Senior Member Ingale's Avatar
    Join Date
    Jun 2003
    Posts
    332

    Attaching a MC from a library and setting its X and Y

    Hi all!
    I have a movie in the library which I want to attach to the stage by code. Here's the code I've been using:
    Code:
    count = 0;
    _quality="High";
    onEnterframe = function () {
    	attachMovie("main", "circle"+count, count++);
    };
    This code works, but it puts the attached MC (circle) in the middle of the stage. How can I set its X and Y coordinates to place it exectly where I need it? I tried a few things, but the code I tried shifted the entire stage instead of that MC alone... So how can I do it?

    Thanks in advance!

    Sometimes the most simple things are the most effective...

  2. #2
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    Code:
    count = 0;
    _quality="High";
    onEnterframe = function () {
    	attachMovie("main", "circle"+count, count++);
                 this["circle"+count]._y = number;
    	this["circle"+count]._x = number;
    };
    If you don't think you're going to like the answer, then don't ask the question.

  3. #3
    Senior Member Ingale's Avatar
    Join Date
    Jun 2003
    Posts
    332
    Thanks!!!

    Apparently I was close, but not close enough...
    These 2 lines of code also gave me the idea how to scale that darn MC with the code.

    Once again, thank you!

    Sometimes the most simple things are the most effective...

  4. #4
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    attachMovie also allows you to use an init Object. the attached movie will have its properties set to whatever you set in the init Object. e.g.

    Code:
    count = 0;
    _quality="High";
    onEnterframe = function () {
    	attachMovie("main", "circle"+count, count++,{_x:count*10, _y:10});
    };
    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  5. #5
    Senior Member EQFlash's Avatar
    Join Date
    Jun 2002
    Location
    where i'm at
    Posts
    2,735
    nice code lex
    If you don't think you're going to like the answer, then don't ask the question.

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