dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [RESOLVED] TransformationPoint? How do I use this?

  1. #1
    Army Web Designer
    Join Date
    Jun 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    140

    [RESOLVED] TransformationPoint? How do I use this?

    I have created a Sprite object (a simple rectangle). I would like to set the transoformation point so that it is set to the middle of my Sprite object. I need this so that when I rotate it, it will rotate from the center rather than the top-left corner.

    Solutions? Probably simple?

    (*Just learning 3.0 - much better than 2.0)
    Jason Beaudoin
    Web Designer
    Canadian Army

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You cannot set just simply like that. You need to use the Animator class, which is basically xml. There is a property called transformationPoint. Scroll to the bottom:

    http://www.adobe.com/devnet/flash/qu...nal_files_as3/
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Army Web Designer
    Join Date
    Jun 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    140
    Shouldn't it be that easy tho? LOL!

    Pivoting an object from a specific reference point is something pretty basic. Sounds like I may have to create a custom class.

    If anyone knows an easier way... please let me know.
    Jason Beaudoin
    Web Designer
    Canadian Army

  4. #4
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    PHP Code:
    var myspr=new Sprite();
    myspr.x=100;
    myspr.y=100;
    addChild (myspr);
    var 
    point:Point=new Point(myspr.x+myspr.width/2myspr.y+myspr.height/2);
    rotateAroundCenter(myspr,45);

    function 
    rotateAroundCenter (ob:*, angleDegrees) {
        var 
    m:Matrix=ob.transform.matrix;
        
    m.tx -= point.x;
        
    m.ty -= point.y;
        
    m.rotate (angleDegrees*(Math.PI/180));
        
    m.tx += point.x;
        
    m.ty += point.y;
        
    ob.transform.matrix=m;


  5. #5
    Army Web Designer
    Join Date
    Jun 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    140
    See... now that's what I'm talking about.

    Thank you very, very much Tonypa!
    Jason Beaudoin
    Web Designer
    Canadian Army

  6. #6
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    I once made a workaround for flash 8. Here is the conversion:
    PHP Code:
    var container:MovieClip = new MovieClip();
    container.200;
    container.200;
    addChild(container);
    var 
    conChild:= new A();
    conChild.name "conChild";
    container.addChild(conChild);
    conChild.= -container.width/2;
    conChild.= -container.height/2;
    container.addEventListener(Event.ENTER_FRAMErotate);
    function 
    rotate(e:Event)
    {
       
    e.target.rotation += 10

    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  7. #7
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Yep, I used similar workaround too in earlier versions

    Also wish to point that if you use Flash CS3, it comes with MatrixTransform class which has 2 methods to rotate around chosen point.

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