Don't waste time. Join now. No cost.
September 04, 2010, 12:21:19 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: For all people signing up I have been forced to change the way of doing it.
You will need to send me an email after you have registored, at this point I will check and approve your entry.
All this is due to ASSHOLES loading this sight with Sex Links, Add's for same, which will not be allowed.

email: redridecycle@yahoo.com
Wayne
 
Pages: [1]
  Print  
Author Topic: Registration Point Question  (Read 809 times)
Wayne
Administrator
Full Member
*****

Karma: 0
Offline Offline

Gender: Male
Posts: 118


BEER ,beeeeeeeeeeer ah beer.


« on: March 26, 2009, 05:50:33 AM »

As I have seen and been ask around several forums, this one question keeps coming up. " Can I change the registration point of a object with scripting." The answer is Yes & No. Got you confused? Well you can not physically in run time change it, but you can lie to you viewer/flash player to think it is some where its not.

 

Now I will take you away from the wall and put you out of pain.
The code is small and uses a function to achieve this.
This is the function: 
Code:
function origin()
    {
        var bounds = this.getBounds(this._parent);
        return ({x: (bounds.xMin + bounds.xMax) / 2, y: (bounds.yMin + bounds.yMax) / 2});
    }
Now what we will do is for this example we will rotate an object so you will see the function at work.

This is setting up your rotation: 
Code:
onClipEvent (load)
{   
     this.rotation_speed = 2;
    this.rotation_origin = origin();
}

Now we need to create a loop to keep this running: 
Code:
onClipEvent (enterFrame)
{
    this._rotation = this._rotation + rotation_speed;
    var curr_origin = origin();
    this._x = this._x + (this.rotation_origin.x - curr_origin.x);
    this._y = this._y + (this.rotation_origin.y - curr_origin.y);
}

All this code is set inside a sprite so now draw a box and name it box.
Convert it to a sprite.
Now go to Transform and set your registration point to custom and enter X: -69.65  Y: -78.8.
Now test. If you did everthing right it will rotate as if your Res.Point was set to center.

Hope this helps.

Wayne


Link to this Post: http://cycle1500.com/action/index.php?topic=64.msg99#msg99
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Around the World in 80 Settings Theme by MT2-Soft, in association with SMFThemes and TinyPortal Media. (Theme © 2008, Gary M. Gadsdon)
Copyright 2005.