A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Registration point of loadmovieclip mc

  1. #1
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234

    Registration point of loadmovieclip mc

    Hi all,

    Been ages since I've been on the board... but my money for travel ran out so back to work

    Anyhow, I'm working on a application for playing around with images. I create a placeholder mc and placed it on the stage. Whilst making a mc of it I selected the center of the mc as a registration point.

    Now when I load a jpg into the mc Flash places the jpg top left pixel to the registration point. Kinda sux because when you rotate the picture it doesn't rotate around the centre but around the topleft point of the jpg.

    Any solutions?

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  2. #2
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234

    Just maybe

    I found a piece of code here:

    http://www.kirupa.com/forum/showthread.php?t=70919

    Similiar to a solution I've been thinking of. But isn't there a simpler solution than a hack like this?

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  3. #3
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    Hi
    Here is an example how.....


    First i created an empty movieclip to act as a holder for a loaded jpg....
    I gave it the instance name ....subholder.....in the properties panel and placed it
    top left of stage...X:0 Y:0....the reg point had been set to top left when i created it.

    Then i put this on the timeline to load an external image ...
    code:
    loadMovie("pic1.jpg", _root.holder.subholder);



    The (holder) is a movieclip that will contain this (subholder) clip.......

    So to do this ...i opened a new project(whilst other is still open)
    and drew a rectangle that was the same scale as the stage(550,400)
    ...then also aligned it with the stage....
    ....i then converted this rectangle to a movieclip
    and gave it a central registration point.....
    I gave this clip an instance name of....holder
    once converted i doubleclicked this clip
    to see its timeline .....

    Then i opened the previous project,... rightclicked on the first frame and
    selected Copy Frames...

    Then returned to the later project where i am looking at the timeline of the holder clip
    and pasted the frame into it on a new layer then deleted the rectangle shape layer...
    .....so now the subholder clip is top left of stage and it is within the holder clip
    which has a central reg point and is aligned centrally to stage...


    Then i added a button to rotate the holder clip....

    This FLA shows the method used....the holder clip containing the subholder clip is the one that is actually rotating on its central reg point.

  4. #4
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    Interesting approach! Thanx for that...

    But I don't think it's very exact. When I press the red button untill the image is rotated to 180' the bottomright point of the image should be on the exact spot the topleft point of the image when not rotated. This is not the case in your example.

    However, like in your example, I've been thinking to create a parent holder for my image holder mc as well. And then with calculations see what I can do...

    I also found this online: http://redhot.pepper.jp/ming_php/regist_point2.html

    Will let you know when I managed to hack a solution.

    Still up for ideas though!

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

  5. #5
    Angkor-What? Gekke_Hollander's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    234
    Easier than I thought. Like your example I created a parent_holder mc with the registration point set to the centre. In this mc I place a child_holder mc with the registration point set to the top left.

    After loading the jpg into the child_holder mc (make sure it's loaded) the width and height of both parent and child mcs is the same to that of the original picture. Let's say 150x150px.

    So what I do is relocate the child_holder mc inside the parent_holder mc.

    Code:
    	if (_root.parent_holder.child_holder._x == 0 && _root.parent_holder.child_holder._y == 0) {
    		_root.parent_holder.child_holder._x = (_root.parent_holder.child_holder._x-(_root.parent_holder.child_holder._width/2));
    		_root.parent_holder.child_holder._y = (_root.parent_holder.child_holder._y-(_root.parent_holder.child_holder._height/2));
    	}
    In other words; if the loaded image is aligned to the registration point x0,y0 then align it so the centre of the image is right on top of the registration point. The centre of the image being half the width and half the height of the image. So move the image to x-75 and y-75.

    Now if I rotate _root.parent_holder or zoom it or whatever... it will do so believing the centre of the image is the registration point

    Hope this will help other folks out there as well... if you find a better solution let me know!

    Cheers
    MX 2004 Pro - Oops I did it again!!!
    SWF, it's a journey... not a destination

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