hi this is the calculation i used for something very similar. dynamic text 
layed out round a circle (picture attached), although it doesn't take into 
account re-registering it so it is top left registration:
function makeNames() {  for (var i:int=0; i<filmNames.length; i++) {            
filmHolders[i] = new MovieClip();               filmHolders[i].val = i;         
namesHolder.addChild(filmHolders[i]);           //              var degs:Number 
= i * 20;               var rads:Number = (degs * Math.PI) / 180;               
var r:Number = 110;             var rx:Number = (r * Math.cos(rads));           
var ry:Number = (r * Math.sin(rads));           // ...          
filmHolders[i].x = rx;          filmHolders[i].y = ry;          
filmHolders[i].rotation = i * 20;               //              var 
nameText:TextField = new TextField();               nameText.text = 
filmNames[i];
                filmHolders[i].addChild(nameText);              //      }}
surely if you put each sprite you want around the circle inside a container 
sprite for each sprite then you can sort the registration out:
//container for "wheel" of spritesvar containAll:Sprite = new 
Sprite();addChild(containAll);
containAll.x = stage.stageWidth/2;containAll.y = stage.stageHeight/2;
function makeSprites(num:Number) {      //create your sprite and draw contents  
var mySprite:Sprite = new Sprite();     mySprite.graphics.beginFill(0xff0033);  
mySprite.graphics.drawRect(0,0,30,20);  mySprite.graphics.endFill();    
//create a container for the sprite     var myContainer:Sprite = new Sprite();  
containAll.addChild(myContainer);       myContainer.addChild(mySprite); 
//re-register inside container  mySprite.x = -mySprite.width/2; mySprite.y = 
-mySprite.height/2;        //do calculations       var degs:Number = num * 20;  
   var rads:Number = (degs * Math.PI) / 180;       var r:Number = 110;     var 
rx:Number = (r * Math.cos(rads));   var ry:Number = (r * Math.sin(rads));   
//apply calculations to container       myContainer.x = rx;     myContainer.y = 
ry;     myContainer.rotation = num * 20;}//run function a few timesfor(var 
i:int = 0; i<16; i++) {      makeSprites(i);}
(i've also not eaten so its probably wrong and i've completely misunderstood 
what you're after!!!)
good luck,
david
> Subject: Re: [Flashcoders] Placing sprites on the circumference of a circle
> From: w...@innerfuse.biz
> Date: Mon, 9 Nov 2009 21:55:36 +0100
> To: flashcoders@chattyfig.figleaf.com
> 
> After a bike ride down hill to the supermarket and cooking I just  
> tried out all your suggestions and I have to say it appears to work!  
> Really nice, only the problem I am currently happening is the issue  
> when I am creating sprites dynamically during runtime the origin is  
> not in the bottom center but in the top left which goofs up  
> everything. And when I try to do:
> 
>       x = -( b.width / 2 );
>       y = -( b.height );
> 
> Before I am updating the positions as calculated the trigonometry  
> formulas. I am quite sure I am overseeing something, though. Not sure  
> what is wrong even when I do this after the setting x,y to the values  
> of nx, ny it still fails for me.
> 
> The current code I am using is as follows:
> http://www.innerfuse.biz/dropbox/code.txt
> 
> Anyone know what I could be doing wrong? Thanks again, you guys are  
> lifesavers :)
> 
> (really need to get a book about mathematics again to fresh up)
> 
> Yours,
> Weyert de Boer
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
                                          
_________________________________________________________________
New Windows 7: Find the right PC for you. Learn more.
http://www.microsoft.com/uk/windows/buy/_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to