# Rotation and tempo

**URL:** <https://forum.kirupa.com/t/rotation-and-tempo/118546>\
**Category:** Uncategorized\
**Created:** [August 6, 2004, 3:10pm UTC](https://forum.kirupa.com/t/rotation-and-tempo/118546 "2004-08-06T15:10:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![farmerito](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@farmerito](https://forum.kirupa.com/u/farmerito)\
**Post date:** [August 6, 2004, 3:10pm UTC](https://forum.kirupa.com/t/rotation-and-tempo/118546/1 "2004-08-06T15:10:22Z")

</div>

Hi there,

I am new to ActionScript and hope someone can help.

1. I want the user to be able to activate a ball (ball\_mc) which will rotate around a circlular ring (ring\_mc).

2. I want the user to be able to control the speed or tempo at which this ball moves around the ring.

3. One rotation of the ring will equate with a bar of music. Therefore the user should also be able to decide on the beat length of the ring in musical time i.e. 2,3, 4, 5, 6, 7, 8, 9, 10, or 12 beats.

4. On the ring the user will also be able to place movie clips which represent percussion sounds (duration\_mc) and I therefore also want the ball\_mc to trigger the percussion sound when it encounters the duration\_mc.

5. I want the percussion sound triggered to be determined by the colour of the ring\_mc and the user should be able to drag different coloured rings on to the stage. I have created an empty movie clip called canvas\_mc to house the rings and I have seven different coloured rings which will each have a different associated sound.

All very complicated. Any help would be greatly appreciated.  
Cheers!  
Farmerito

---

<div class="post-metadata">

**Author:** ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)\
**Post date:** [August 6, 2004, 5:44pm UTC](https://forum.kirupa.com/t/rotation-and-tempo/118546/2 "2004-08-06T17:44:14Z")

</div>

the ball needs to have a center point at the central point yo want to rotate it around (which u can do using the \_rotation property of a movieclip)

also look up hit testing (for those “encounters”) sounds and how to start them etc and also hav a look at startDrag etc… im sorry i cant give you more detailed help atm but i hav a headache… :S who knows, if i get bored tomoro after work i might do a quick mock up for you… but no promises yet 😉

Prophet.

---

<div class="post-metadata">

**Author:** ![farmerito](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@farmerito](https://forum.kirupa.com/u/farmerito)\
**Post date:** [August 9, 2004, 2:09pm UTC](https://forum.kirupa.com/t/rotation-and-tempo/118546/3 "2004-08-09T14:09:43Z")

</div>

> [@Prophet](#):
>
> the ball needs to have a center point at the central point yo want to rotate it around (which u can do using the \_rotation property of a movieclip)
> 
> also look up hit testing (for those “encounters”) sounds and how to start them etc and also hav a look at startDrag etc… im sorry i cant give you more detailed help atm but i hav a headache… :S who knows, if i get bored tomoro after work i might do a quick mock up for you… but no promises yet 😉
> 
> Prophet.

That would be great. Here is the code I have at the moment. It included a few other features apart from those I mentioned previously.

var iconDepth:Number = 10000;  
var ringDepth:Number = 0;  
var down:Boolean = false;

\_root.onMouseDown = function() {  
if (\_root.canvas\_mc.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
var x:Number = \_root.\_xmouse;  
var y:Number = \_root.\_ymouse;  
\_root.holder\_mc.moveTo(x, y);  
down = true;  
}  
};  
\_root.onMouseUp = function() {  
down = false;  
};  
var currentColor:String = “000000”;  
\_root.createEmptyMovieClip(“holder\_mc”, -100);  
function draw() {  
\_root.holder\_mc.lineStyle(3, parseInt(currentColor, 16), 100);  
var x:Number = \_root.\_xmouse;  
var y:Number = \_root.\_ymouse;  
\_root.holder\_mc.lineTo(x, y);  
}  
\_root.onMouseMove = function() {  
updateAfterEvent();  
if (down && \_root.canvas\_mc.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
draw();  
}  
};  
window1\_mc.gotoAndStop(“color”);  
window2\_mc.gotoAndStop(“admin”);  
var topClip:MovieClip = window1\_mc;  
function swap(clip:MovieClip) {  
clip.swapDepths(topClip);  
topClip = clip;  
}  
//build menu list of duration symbols  
function buildIconList() {  
//set the locations of the elements of the icon list  
var spacing:Number = 35;  
var iconY:Number = 75;  
var iconX:Number = 75;  
//create a duplicated list of incrementally named icons based on  
//frame contents of the icon\_mc  
for (var i = 0; i \< \_root.icon\_mc.\_totalframes; ++i) {  
var newName:String = “icon\_mc” + i;  
var clip:MovieClip = \_root.icon\_mc.duplicateMovieClip(newName, 1000 + i);  
clip.gotoAndStop(i + 1);  
clip.\_x = iconX + i \* spacing;  
clip.\_y = iconY;  
clip.homeX = clip.\_x;  
clip.homeY = clip.\_y;  
clip.icon\_btn.onPress = function() {  
startDrag(this.\_parent);  
};  
clip.icon\_btn.onRelease = function() {  
stopDrag();  
\_root.iconReleased(this.\_parent);  
};  
}  
}  
buildIconList();

function iconReleased(icon:MovieClip) {  
//checks if clip is released over the canvas and if so it creates a duplicate  
//with incremental name by incrementing the iconDepth variable  
if (\_root.canvas\_mc.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
++iconDepth;  
var newName:String = “object” + iconDepth + “\_mc”;  
var clip:MovieClip = icon.duplicateMovieClip(newName, iconDepth);  
clip.gotoAndStop(icon.\_currentFrame);  
clip.icon\_btn.enabled = false;  
//set the size of the clip relative to the icon  
clip.\_xscale = 100;  
clip.\_yscale = 100;  
clip.onPress = function(){  
//turn off the drawing facility  
down = false;  
startDrag(this);  
};  
clip.onRelease = function(){  
//Check if clip is dragged off the canvas and if so remove the clip  
if (!\_root.canvas\_mc.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
++iconDepth;  
this.removeMovieClip();  
}  
stopDrag();  
};  
}  
//send the icon back to original position in list  
icon.\_x = icon.homeX;  
icon.\_y = icon.homeY;  
}  
//similar functions as above to create coloured ring menu list  
function buildRingList() {  
var spacing:Number = 50;  
var ringY:Number = 250;  
var ringX:Number = 30;  
for (var i = 0; i \< \_root.ring\_mc.\_totalframes; ++i) {  
var newRing:String = “ring\_mc” + i;  
var clip:MovieClip = \_root.ring\_mc.duplicateMovieClip(newRing, 2000 + i);  
clip.gotoAndStop(i + 1);  
clip.\_x = ringX;  
clip.\_y = ringY + i \* spacing;  
clip.homeX = clip.\_x;  
clip.homeY = clip.\_y;  
clip.ring\_btn.onPress = function() {  
startDrag(this.\_parent);  
};  
clip.ring\_btn.onRelease = function() {  
stopDrag();  
\_root.ringReleased(this.\_parent);  
};  
}  
}  
buildRingList();  
function ringReleased(ring:MovieClip) {  
if (\_root.canvas\_mc.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
++ringDepth;  
var newRing:String = “object” + ringDepth + “\_mc”;  
var clip2:MovieClip = ring.duplicateMovieClip(newRing, ringDepth);  
clip2.gotoAndStop(ring.\_currentFrame);  
clip2.ring\_btn.enabled = false;  
clip2.\_xscale = 400;  
clip2.\_yscale = 400;  
clip2.onPress = function(){  
down = false;  
startDrag(this);  
};  
clip2.onRelease = function(){  
if (!\_root.canvas\_mc.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
++ringDepth;  
this.removeMovieClip();  
}  
stopDrag();  
};  
}  
ring.\_x = ring.homeX;  
ring.\_y = ring.homeY;  
}  
function clearContent() {  
//clear the lines drawn and held in holder\_mc  
\_root.holder\_mc.clear();  
//clear each of the duration symbols duplicated on canvas  
for (var i = 0; i \<= iconDepth; ++i) {  
var name:String = “object” + i + “\_mc”;  
\_root[name].removeMovieClip();  
}  
//reset iconDepth so that subsequent clips can begin from original depth  
iconDepth = 10000;  
}  
function clearRings(){  
//similar to removing durationc clips, this removes the rings created  
for (var i = 0; i \<= ringDepth; ++i) {  
var name:String = “object” + i + “\_mc”;  
\_root[name].removeMovieClip();  
}  
//reset the ringDepth as above  
ringDepth = 0;  
}  
var kick\_mc = this.createEmptyMovieClip(“kick\_mc”);  
var kick:Sound = new Sound();  
kick.attachSound(“Kick”);  
function checkOverlap():Void{  
if(ring\_mc.redBall\_mc.hitTest(\_root.duration\_mc)){  
kick.start();  
kick.setVolume(50);  
}  
}  
//set the frequency of checkOverlap  
var nOverlapInt

The hit test is not working and I also haven’t got the ball rotating around the rings.

Let me know if you have any suggestions.  
farmerito

---

<div class="post-metadata">

**Author:** ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)\
**Post date:** [August 9, 2004, 6:54pm UTC](https://forum.kirupa.com/t/rotation-and-tempo/118546/4 "2004-08-09T18:54:26Z")

</div>

can i hav the fla?  
wuld b much easier!  
o and btw, sorry - i totally forgot to do that!! lol

Prophet.

---

<div class="post-metadata">

**Author:** ![farmerito](https://avatars.discourse-cdn.com/v4/letter/f/d26b3c/32.png) [@farmerito](https://forum.kirupa.com/u/farmerito)\
**Post date:** [August 10, 2004, 4:13pm UTC](https://forum.kirupa.com/t/rotation-and-tempo/118546/5 "2004-08-10T16:13:52Z")

</div>

It seems to be too big to send.

Here is a smaller file that I am trying to get ball to rotate in.

---

<div class="post-metadata">

**Author:** ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)\
**Post date:** [August 10, 2004, 5:47pm UTC](https://forum.kirupa.com/t/rotation-and-tempo/118546/6 "2004-08-10T17:47:58Z")

</div>

any chance of gettin gthat in Flash MX format? (ie. not FMX2004) 😉

Prophet.

PS sorry to be such a pain! 😉 lol
