all groups > flash actionscript > december 2004 >
You're in the

flash actionscript

group:

Making targets in actionscript


Making targets in actionscript filmore
12/19/2004 5:18:26 PM
flash actionscript:
I'm working on a project in Flash MX and I would like if anyone would show me
how to make random targets to shoot at in a space ship
game.mickey10010@hotmail.com or reply to this message. :confused; :cool;
Re: Making targets in actionscript kglad
12/19/2004 10:26:41 PM
either use duplicateMovieClip() to duplicate an on-stage movie or use
attachMovie() to attach a movieclip from the library to the stage.

position the duplicated or attached movieclip to suit your needs.
Re: Making targets in actionscript kglad
12/19/2004 10:26:47 PM
either use duplicateMovieClip() to duplicate an on-stage movie or use
attachMovie() to attach a movieclip from the library to the stage.

position the duplicated or attached movieclip to suit your needs.
Re: Making targets in actionscript filmore
12/30/2004 1:13:25 PM
Re: Making targets in actionscript NSurveyor
12/30/2004 2:04:43 PM
Code to make balls that bounce around. On click, they are 'killed'

totalTargets = 10;
moveSpeed = 1;
for(x=0;x<totalTargets;x++){
_root.ball.duplicateMovieClip('ball'+x,_root.getNextHighestDepth());
cball = _root['ball'+x];
cball._x =
cball._x-cball.getBounds(_root).xMin+Math.random()*(Stage.width-(cball.getBounds
(_root).xMax-cball._x));
cball._y =
cball._y-cball.getBounds(_root).yMin+Math.random()*(Stage.height-(cball.getBound
s(_root).yMax-cball._y));
cball.id =
setInterval(bounce,moveSpeed,cball,1+Math.round(Math.random())*-2,1+Math.round(M
ath.random())*-2);
//REPLACE FOLLOWING CODE TO CHANGE SHOOTING METHOD:
cball.onPress = function(){
trace('You shot '+this._name+'!');
stopBounce(this);
}
//=====================================
}
_root.ball.unloadMovie();
function stopBounce(someMC){
clearInterval(someMC.id);
}
function bounce(someMC,ixd,iyd){
if(someMC.xs==undefined){
someMC.xs = ixd;
}
if(someMC.ys==undefined){
someMC.ys = iyd;
}

if(someMC.getBounds(_root).xMax>=Stage.width||someMC.getBounds(_root).xMin<=0){
someMC.xs = -someMC.xs;
}

if(someMC.getBounds(_root).yMax>=Stage.height||someMC.getBounds(_root).yMin<=0)
{
someMC.ys = -someMC.ys;
}
someMC._x+=someMC.xs;
someMC._y+=someMC.ys;
updateAfterEvent();
}
AddThis Social Bookmark Button