Rotation and tempo

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

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 :wink:

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

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

Prophet.

It seems to be too big to send.

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

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

Prophet.

PS sorry to be such a pain! :wink: lol