A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Making a wheel with elements that grow as they get closer to the top.

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    19

    Making a wheel with elements that grow as they get closer to the top.

    Hey, I'm working on a project with a 2D, flat, globe, that rotates either left or right. Essentially, it's a circle. All around this circle are going to be buildings, evenly spaced. If you're having trouble visualizing that, see this illustration. http://www.more4kids.info/uploads/Im...g-hands-sm.jpg The children in this illustration would be the buildings I'm referring to. Now, the top most building will be the biggest, and the others will gradually get smaller. How can I get this working so that buildings ease in and ease out in size as the planet rotates?

    Thanks!

    If you have any clarifying questions, let me know.

  2. #2
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    bump!

  3. #3
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    still need help!

  4. #4
    World Kit Vote Holder Abelius's Avatar
    Join Date
    Feb 2002
    Location
    US
    Posts
    963
    I would make sure that the transformation point is located at the base of the buildings, and centered x-wise. Then I would simply use some code to make them bigger or smaller as they rotate.

    PHP Code:
    this.addEventListener (Event.ENTER_FRAMErotateTheThing);

    function 
    rotateTheThing (e:Event):void
    {
        
    main_mc.rotation += 1;
        if (
    main_mc.rotation<180&&main_mc.rotation>0)
        {
            
    main_mc.b1_mc.scaleY-=.005;
            
    main_mc.b1_mc.scaleX-=.005;
        }
        else
        {
            
    main_mc.b1_mc.scaleY+=.005;
            
    main_mc.b1_mc.scaleX+=.005;
        }
        
    trace (main_mc.rotation);

    Cordially,
    Abelius
    www.worldkit.com

  5. #5
    World Kit Vote Holder Abelius's Avatar
    Join Date
    Feb 2002
    Location
    US
    Posts
    963
    Here is a zip file if you need it. In the sample I only made the first building do the scaling, you can add it for as many buildings as you need.

    http://www.worldkit.com/TEMP/scaleBuilding.zip
    Cordially,
    Abelius
    www.worldkit.com

  6. #6
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    awesome! thanks! this helps so much. i really appreciate you taking the time out to do this.

  7. #7
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    Hmm, I tried duplicating this, and now I get:

    1021: Duplicate function definition.

    Source: function rotateTheThing (e:Event):void

  8. #8
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    scratch that! it works! however, I do have another question. is there anyway to have the building, when it shrinks, remain where it was initially positioned on the globe? as in, the base would stay touching the same point of the globe, just the building would shrink in place (as opposed to drawing in towards the middle).

    thanks!

  9. #9
    Member
    Join Date
    Apr 2008
    Posts
    65
    Abelius wrote: "I would make sure that the transformation point is located at the base of the buildings, and centered x-wise." This should keep it from scaling in the middle.

    I also tested the code in this post. I added additional movieclips, i.e. b1_mc, b2_mc, b3_mc, b4_mc and postioned them on a main_mc that is rotating. There is one in the top, bottom, left, and right. I found that with this code they all start at their normal size, scale down, then back up when they get to their original location. italianice388, were you wanting the buildings, b1_mc etc, to only be large when they get to the top of the globe?

  10. #10
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    yes! they should be tallest at the top of the globe.

  11. #11
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    also, thank you for directing me to abelius' quote! totally missed that. tsk.

    thanks again, both of you guys. seems to be working just fine now!

    edit:

    so, how do i add the other buildings into the code? i've tried a few things and nothing seems to be working
    Last edited by italianice388; 07-20-2009 at 10:23 PM.

  12. #12
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    bump!

  13. #13
    Member
    Join Date
    Apr 2008
    Posts
    65
    I made an attempt but only got so far. I added additional buildings/objects to the main_mc. Imagine a circle with a building on top, bottom, left, and right like a cross. I write the code as follows. The only problem is that they are at their tallest point from their starting position. I know that you only want them at their tallest when they reach the top of the globe, so maybe someone else can make a recommendation.

    stop();
    this.addEventListener (Event.ENTER_FRAME, rotateTheThing);

    function rotateTheThing (e:Event):void
    {
    main_mc.rotation += 1;
    if (main_mc.rotation<180&&main_mc.rotation>0)
    {
    main_mc.b1_mc.scaleY-=.005;
    main_mc.b1_mc.scaleX-=.005;
    main_mc.b2_mc.scaleY-=.005;
    main_mc.b2_mc.scaleX-=.005;
    main_mc.b3_mc.scaleY-=.005;
    main_mc.b3_mc.scaleX-=.005;
    main_mc.b4_mc.scaleY-=.005;
    main_mc.b4_mc.scaleX-=.005;
    }
    else
    {
    main_mc.b1_mc.scaleY+=.005;
    main_mc.b1_mc.scaleX+=.005;
    main_mc.b2_mc.scaleY+=.005;
    main_mc.b2_mc.scaleX+=.005;
    main_mc.b3_mc.scaleY+=.005;
    main_mc.b3_mc.scaleX+=.005;
    main_mc.b4_mc.scaleY+=.005;
    main_mc.b4_mc.scaleX+=.005;
    }
    trace (main_mc.rotation);
    }

  14. #14
    Junior Member
    Join Date
    Feb 2007
    Posts
    19
    thanks! yeah, the only problem now is making it so each building gets its maximum height once it reaches the top, not it's starting point.

Tags for this Thread

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