A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Get X value of Rotating graphic

  1. #1
    Flash Initiate StuartW's Avatar
    Join Date
    Jul 2000
    Location
    The Metaverse
    Posts
    504
    Not a problem you would think..

    I would like to get the x value of a ball MC, which is contained in a movieclip that's rotating via an enterframe clip event.

    i.e.

    I have a moviclip called "ball" which is located in a moviclip called "rotate", this actionScript is on the clip event of "rotate".

    onClipEvent (enterFrame) {
    setProperty ("_root.rotate", _rotation, _rotation+10);
    ..:xBall = getProperty("-root.rotate.ball", _x);
    }

    However this appears to return a value of x IN RELATION to my rotate MC, i.e. it's a static value.

    Is there a way of getting Flash to return properties in relation to the stage, or do I have to hit that maths books again!

    I tired using a controlClip insted of the clipevent script but that gave me a very strange x value????

    Thanks for any pointers in advance,

    Stu

  2. #2
    curmudgeon swampy's Avatar
    Join Date
    Jan 2001
    Location
    [wakey]
    Posts
    2,775
    surely the _x property will remain static as the MC is rotating around it's registration point ?

  3. #3
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    hi StuartW,
    swampy is right. i saw that you where not using dot syntax to target your variable xBall). (..:xBall should be _root.rotate.xBall) plus i saw you where asking the variable to 'getProperty' is our variable moving?? like is it changing its _x position? if you just want a number written in a textfield you should simply put the target.clip._x in the value box of the variable instead. As in '_root.rotate.xBall = _root.rotate.ball._x' so... to answer your path problem, anything related to the stage starts with '_root'. if you want to know the _x position of your ball on the root, then your variable xBall should target (_root.rotate._x +(or minus depending where the ball is, ie: before or after the center of the clip) _root.rotate.ball._x), but as swampy was saying the ball rotates around its center so its center does not move (ie: its _x does not change)
    hope this helps.
    gparis

  4. #4
    Flash Initiate StuartW's Avatar
    Join Date
    Jul 2000
    Location
    The Metaverse
    Posts
    504
    Cheers guys that kinda helped me to understand.

    The "Ball" movieclip is inside the "Rotate" Movieclip, but is not in the centre, so it 'Orbits' the centre point of the Rotate clip...if you see what I mean?

    I want to get the _x value of the "Ball" movieclip in relation to the stage as the "Ball" movieclip actually moves, but I can see what your saying - it's always going to be static...

    But is there any way of getting the _x value of the "Ball" (as it's orbiting the centre point of Rotate it is actually moving) movieclip? Or is it back to the drawing board?

    Cheers for your help guys it's much appreciated.

    Stu


  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    hi again,
    ahh, about time we know that so, no the variable xBall won't give you a static number, as the _root._x of the ballclip changes. Assuming you put your variable(xBall) textbox on the stage, attach this script to the MC ball:
    Code:
    onClipEvent (enterFrame) {
    	_root.xBall = _root.rotate.ball._x + _root.rotate._x; }
    hope this'll help
    gparis
    [Edited by gparis on 06-14-2001 at 12:51 PM]

  6. #6
    Flash Initiate StuartW's Avatar
    Join Date
    Jul 2000
    Location
    The Metaverse
    Posts
    504
    Nice one!



    Much appreciated.


    Stu

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