A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Changing the registration point on a component

  1. #1
    Junior Member
    Join Date
    Aug 2003
    Posts
    25

    Changing the registration point on a component

    I've been using a textArea component which I am dragging around the stage. The default position for the registration point seems to be in the top left. I would like to change this position to the centre. Is there any actionScript code I can use to do this? I have named my components: text1, text2, etc.

    Thanks for any advice.

    Richard

  2. #2
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    I don't think it's possible. You might be able to put the component inside a movie clip and move the clip.

  3. #3
    Member
    Join Date
    Nov 2004
    Location
    Athens, Greece
    Posts
    96
    Geezer is wrong. It is possible to move the registration point with actionscript, which I have used in a map programme that zooms in-out from the screens centre.
    So, you can dynamically scale and/rotate an mc and move the reg point to the center using AS.
    See example attached. Att: there 3 AS 1. in the circle, in the button, in the first frame.
    Good luck!

    PS: Nothing is impossible with some AS and brains
    Attached Files Attached Files

  4. #4
    FK's Geezer Mod Ask The Geezer's Avatar
    Join Date
    Jul 2002
    Location
    Out In The Pasture
    Posts
    20,488
    zafeiris can't read. His example is not a component, and it isn't dragging.

    And I did say you might be able to do it with a movie clip.

    PS: Nothing is impossible with some AS and brains
    Good, I'm a bachelor. show me how to make it do my dishes.

  5. #5
    Member
    Join Date
    Nov 2004
    Location
    Athens, Greece
    Posts
    96
    Q:Is there any actionScript code I can use to do this?
    A:I don't think it's possible. You might be able to put the component inside a movie clip and move the clip.(not with AS?)
    Dear Geezer if you think I have something personal against you, you will be wrong for the third time. If you have something personal against me, I shall never post an answer under your posts. If none of the above is true, I shall remove this post and any statement that could be consindered as an inuendo from you.
    After all there is nothing more than sharing knowledge and experience, with some humour sometimes

  6. #6
    Senior Member ceglia's Avatar
    Join Date
    Jan 2003
    Location
    Los Angeles
    Posts
    262
    Quote Originally Posted by zafeiris
    So, you can dynamically scale and/rotate an mc and move the reg point to the center using AS.
    what if you want to move the registration point to a point that is NOT the center?

    i've got a map that sits beneath a mask. when the user clicks a point on the map, four things happen:

    1. the map scales from 100% to 200%
    2. the map itself moves beneath the mask so that the point that was clicked remains where it was prior to the zoom (when the map scales 200%, the point obviously moves, so this step compensates for that move)
    3. the mask scales from 100% to 25%
    4. the mask moves so that it frames the point that was clicked.

    the overall effect of these four steps is a kind of zoom-in focus effect. the user clicks on a point, and that point is zoomed in and framed nicely.

    the problem is that all of the above-mentioned moves and scales use onEnterFrame, and the effect is smooth but not perfect.

    if there was a way to modify the actual registration point, then steps 1 and 2 could be consolidated, as could 3 and 4. i'm scaling AND moving because the registration point is someplace other than the place that was clicked. if i could move the registration point to the point that is clicked, then scale alone, without the move, would suffice, and the overall effect would be more convincing.

    anyway, if anyone knows how to do this, please let me know!

    thanks.

  7. #7
    Member
    Join Date
    Nov 2004
    Location
    Athens, Greece
    Posts
    96
    Try to play with the code that I uploaded.
    The button has the following code:
    on (press) {
    z+=10
    r+=10//this is for the rotation, so you can remove it
    x=_root.regx//here is the x for the registration you can change it to whatever disired
    y=_root.regy//here is the y for the registration
    map.Zoom(z, r, x, y);
    }

    So, now that you know how to move the reg point, use some maths to move it to the place you want.
    I have done a map project myself with only difference that the map would always zoom in and out with its reg point in the center of the mask.
    Good luck.

  8. #8
    Senior Member ceglia's Avatar
    Join Date
    Jan 2003
    Location
    Los Angeles
    Posts
    262
    hey zafeiris,

    thanks for your reply.

    i modified your script and it works nicely, although i had to specify a fixed offset on the y coordinate. in any case, no big deal.

    i couldn't get it to work with AS-based onEnterFrame-driven moves and scales though. in any case, if i have some time, i'll try to sort that out, but i suspect i'll run into similar problems i was having with my previous solution (which, by the way, does work.... it's just that at the very end of the move/scale it jitters slightly).

    thanks for your help.

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