PDA

View Full Version : help with game!


coolabs87
12-03-2007, 09:00 PM
hey again everyone, just need a lil help again! :p

i was wondering how to edit my duplicateMovieClip code to create multiple movieclip instances on screen at once and of different sizes- its a asteroid avoidance game lol

My code on root timeline (first frame) is:

onEnterFrame = function() {
var asteroid_mc:MovieClip = asteroid_mc.duplicateMovieClip("asteroid2_mc",3)
asteroid_mc._x += 40;
asteroid_mc._xscale = 75;
asteroid_mc._yscale = 110;
};

the best ive got so far is just one more asteroid, so any help would be most grateful!:D

Draxus
12-04-2007, 05:02 AM
onEnterFrame = function()
{
nhd = _root.getNextHighestDepth()
var asteroid_mc:MovieClip = asteroid_mc.duplicateMovieClip("asteroid2_mc", "asteroid2" + nhd, nhd)
asteroid_mc._x += 40;
asteroid_mc._xscale = Math.random() * 80 + 30; //30 is the min, 30 + 80 is the max
asteroid_mc._yscale = Math.random() * 80 + 30;
};


Just change the random for the scales to whatever you want.

coolabs87
12-04-2007, 09:26 AM
thanks for the response! but the error page comes up saying there is a 'type mismatch' on this line:

var asteroid_mc:MovieClip = asteroid_mc.duplicateMovieClip("asteroid2_mc", "asteroid2" + nhd, nhd)

any idea why the error message is coming up??? cheers

Draxus
12-04-2007, 11:31 AM
Sorry, it should have been:

var asteroid_mc:MovieClip = asteroid_mc.duplicateMovieClip("asteroid2_mc" + nhd, nhd)

I never use duplicateMovieClip :)