5 Replies Latest reply on Feb 22, 2011 11:27 AM by Ned Murphy

# Rotate movieclip in an array

I have created an array on my main timeline to fire melons constantly. I  need the melon to rotate through the air I know that I can use a  variable of rotate but I cant figure out where to put it. Advice and  help is appreciated, thanks.

//melons
var melonSpeed=10;
var melonDelay=100;
var melonAmount=0;
var melonArray=[];

function createMelons(){
var melonMc=this.attachMovie("melon","melon"+melonAmount, 1000+melonAmount);
melonAmount++;
melonMc._x= _root.hero._x;
melonMc._y= _root.hero._y;
melonArray.push(melonMc);

}
function moveMelons(){
currentTime=getTimer();
createMelons();

}else{
if(currentTime+melonDelay<=getTimer()){
}
}
for(var i=0; i<melonArray.length; i++){
melonArray[i]._x+=melonSpeed;

}

}

onEnterFrame = function(){

moveMelons();

• ###### 1. Re: Rotate movieclip in an array

While you are changng the _x property you can also change the _rotation property... something like...

for(var i=0; i<melonArray.length; i++){
melonArray[i]._x+=melonSpeed;

melonArray[i]._rotation+=melonRotation;

}

• ###### 2. Re: Rotate movieclip in an array

Ned thank you so much that works perfectly.

One last question, to set the melons gravity and hittest on enemies, would that also be placed in the same area of code?

I'm really new to Flash and have been learning through tutorials and a book, I know these questions are very basic but having a knowledgeable person such as yourself is of great benefit in the learning process, thanks again

• ###### 3. Re: Rotate movieclip in an array

I think so. Think thru the logic and try to understand what the code is doing and then you should be more comfortable determining where things need happen when.