A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Tweening from _root xy to a symbols xy?

  1. #1
    Member
    Join Date
    Dec 2007
    Posts
    47

    Tweening from _root xy to a symbols xy?

    I can't seem to figure out how to do this I have been working on a blackjack game and adding dealing animation to it, the cards come in from offscreen and end up at their locations. Theres rotation involved and its not working too well without adding it to an symbol that is rotated instead of the card. This takes away the issue of x and y values that I add for the cards added to the previous one on a hand, rotation does'nt cause any problems as the rotated symbols err xy is rotated along with it. If I do this without attaching the cards to the symbol for each hand with the rotation and rotate the card itself, rotation is fine but card placement is incorrect.

    If I go with the symbol attachment method which I've been using, the rotation causes the location in which I'd specify on the stage to start from to be rotated...I'm guessing theres a simple solution? Any help would be much appreciated.

    Images to show what I'm after and what I've got atm.
    www.polarathene.com/Temp/
    Correct placement is '01', with the tween being used '02'

  2. #2
    Member
    Join Date
    Dec 2007
    Posts
    47
    bump

  3. #3
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    So right now you are in testing phase with the transitions (if that is what the swf you linked to is showing)

    What is the problem. the card seems to move somewhere properly...
    can you clarify?
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  4. #4
    Member
    Join Date
    Dec 2007
    Posts
    47
    In that temp folder are two accompanying images as well. The first shows correct layout while the 2nd shows what you see in the swf.

    The cards are being drawn from the correct location in the swf but rotation is being applied to the card itself rather then the container clip that I attach them to. This causes the cards to be laid out with each hand having different positioning...errlook at the left and see the 2nd card points to the left and on the right the 2nd card points to the right, they should all go right.

    By attaching a card and giving it just x and y without rotation giving the container that rotation instead I'll get the cards laid out correctly like in the first image. However the location from where the card is drawn during the tween has changed as its now referring to the position in the rotated container. I'm not quite sure how to explain this...If I had a perfect square and rotated it 90 degrees clockwise, the original top right corner is now the bottom right corner.

    So currently I can have one or the other, I'm sure I can have both but I'm not sure how to achieve that.

  5. #5
    Member
    Join Date
    Dec 2007
    Posts
    47
    bump

  6. #6
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    After trying to do some testing, here is what I think

    I think you should rotate the movieclip that will contain both cards

    The movie clip is placed where it will END UP.

    Then you can use a globalToLocal function on the starting point of the card. Then animate the card inside of (for example a 'hand' movie clip) and move it towards 0, 0. Then the next card will end up at 8, 20;

    The cards will always end up the same way top card above right of the first card.

    They will have the rotation you need too....

    does this help?
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  7. #7
    Member
    Join Date
    Dec 2007
    Posts
    47
    I think I'm already doing what your saying. The part I did'nt understand was the global to local, which is what I want to know. If theres a way I can give it the x and y location from _root to the x and y on the hand movie clip that would be great

  8. #8
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    What the globalToLocal() does, is it takes a point (x,y) from the root and it converts it into the relative x and y inside of the movieclip you want.


    //(this is on the root and will hold 2 card images inside of it)
    var hand:MovieClip = _root.createEmptyMovieClip("hand_mc", 1);
    hand._x = 100;
    hand._y = 100;

    //this would be your root starting x and y for the cards to fly out from
    var pt:Object = {x:500, y:500}

    hand.globalToLocal(pt);
    trace(pt.x + ":" + pt.y);

    Thats the idea behind the globalToLocal. throw that in a test fla, and play around with it so you get the idea.
    You will place your cards inside of the hand movieclip, at the location of the point object after you have 1. placed the hand mc where it will end up and 2. after you call the globalToLocal on the point object.

    Then in your tween, tell card 1 to go to something like 0, 0 and the other card to 8, 16. Hope this works.
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  9. #9
    Member
    Join Date
    Dec 2007
    Posts
    47
    Brilliant!! THANK YOU so much for teaching me that feature Thats freaking awesome man

    Nobody else was able to help me, cheers *happy now* once again thanks!

  10. #10
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    Glad to help
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


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