If you mean that the movieclip changes color randomly only when is created, you can do this: In a new as file we gonna make a new class, write this: package{ import flash.display.MovieClip; import flash.display.Shape; import flash.events.Event; public class part2 extends MovieClip{ public function part2():void{ addEventListener(Event.ADDED_TO_STAGE,added); } public function added(e:Event):void{ var array1:Array=["red","black","urple","yellow","blue","green"]; var i:int=Math.random()*array1.length; switch(array1[i]){ case "red": graphics.beginFill(0xFF0000); break; case "black": graphics.beginFill(0x000000); break; case "urple":graphics.beginFill(0x800080); break; case "yellow": graphics.beginFill(0xFFFF00); break; case "blue":graphics.beginFill(0x0000FF); break; case "green": graphics.beginFill(0x008000); break; } graphics.drawCircle(0,0,4); graphics.endFill(); addEventListener(Event.ADDED_TO_STAGE,algo); } public function algo(e:Event):void{ removeEventListener(Event.ADDED_TO_STAGE,algo); } } }
Dont forget to save it "art2" without commas.
Then in the actions of a saved as3 file write this:
stage.addEventListener(MouseEvent.CLICK,crear); function crear(e:MouseEvent):void{ var pointart2= new part2(); point.x=mouseX; point.y=mouseY; addChild(point); }
will this work in AS2 or just AS3, because i'm using AS2
Considering it's written in AS3, no, it won't. These kind of things are important to specify.
I one time wrote something like this for a particle system. I had a random number (lets call it randomColor), and every time i needed a new color i had it recalculate the number. I also had a uInt var (lets call it currentColor) that hold a color value such as 0x006633.
Lets say you want 4 colors, have it generate a random number between 1 and 4. Then in a function, have an If statement checking If(randomColor == 1) { currentColor = 0x990000 } If(randomColor == 2) { currentColor = 0x009900 } If(randomColor == 3) { currentColor = 0x000099 }
And so on and so forth for as many colors as you want. Then before it is added have it apply a color transform to the movie clip using currentColor as the color. I don't know how to apply a color transformation in AS2 so go check it up yourself.
that last post was really from me not ps3dude10. and no I want to add my car MC every 1/6 second and I want the car to randomly chose a different color each time it's added to stage.
that last post was really from me not ps3dude10. and no I want to add my car MC every 1/6 second and I want the car to randomly chose a different color each time it's added to stage.
right now it just makes it all one color. Is there any way to change the MC hue? I know you can in Photoshop and I think you can in Flash, but do you know how to do it in AS2?