lisarose66
08-29-2009, 07:24 PM
can you do that? does it have to be a button? I want to click on the movie clip and make it disappear. once all the objects are gone, the timer ends, points are added and on to the next level.
my other option is to move over the movie clip and it disappears. can you do either? or both?
i haven't written anything to make this happen all i have is the set up. not sure where to go but here's the code anyway...
//timer to add poop piles
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, poopTimer);
timer.start();
//number of piles to add
var numPoop:int=10;
function poopTimer(evt:TimerEvent):void {
poopPiles();
if (numPoop == 10) {
timer.removeEventListener(TimerEvent.TIMER, poopTimer)
}
}
//function that creates 10 poop piles
function poopPiles() {
for(var i=0; i < numPoop; i++)
{
var poop1:MovieClip = new poop();
poop1.x=Math.random()*550;
poop1.y=Math.random()*400;
addChild(poop1);
}
}
//Scooper Dog on stage
var scooperDog:MovieClip=new dogScoop();
addChild(scooperDog);
scooperDog.x=385;
scooperDog.y=315;
//move the dog around the stage to collect the poop
//i wold prefer to move over the poop to collect it since using keyboard movement for the dog but clicking is ok too
//click on poop to collect
//Scooper Dog keyboard movement
stage.addEventListener(KeyboardEvent.KEY_DOWN, detectPoop);
function detectPoop(moveDog:KeyboardEvent):void{
if (moveDog.keyCode==Keyboard.UP) {
//daffy_mc.rotation=0;
scooperDog.y-=15;
}
if (moveDog.keyCode==Keyboard.LEFT) {
//daffy_mc.rotation=-90;
scooperDog.x-=15;
}
if (moveDog.keyCode==Keyboard.RIGHT) {
//daffy_mc.rotation=90;
scooperDog.x+=15;
}
if (moveDog.keyCode==Keyboard.DOWN) {
//daffy_mc.rotation=180;
scooperDog.y+=15;
}
}
this much works thus far but trying to figure out how to get the poop to disappear. i did try hitTest so that poop alpha would go to zero, which worked in another project i did but not this one.
if (scooperDog.hitTestObject(poop1)) {
poop1.alpha=0;
}
thank you for the input.
lisa
my other option is to move over the movie clip and it disappears. can you do either? or both?
i haven't written anything to make this happen all i have is the set up. not sure where to go but here's the code anyway...
//timer to add poop piles
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, poopTimer);
timer.start();
//number of piles to add
var numPoop:int=10;
function poopTimer(evt:TimerEvent):void {
poopPiles();
if (numPoop == 10) {
timer.removeEventListener(TimerEvent.TIMER, poopTimer)
}
}
//function that creates 10 poop piles
function poopPiles() {
for(var i=0; i < numPoop; i++)
{
var poop1:MovieClip = new poop();
poop1.x=Math.random()*550;
poop1.y=Math.random()*400;
addChild(poop1);
}
}
//Scooper Dog on stage
var scooperDog:MovieClip=new dogScoop();
addChild(scooperDog);
scooperDog.x=385;
scooperDog.y=315;
//move the dog around the stage to collect the poop
//i wold prefer to move over the poop to collect it since using keyboard movement for the dog but clicking is ok too
//click on poop to collect
//Scooper Dog keyboard movement
stage.addEventListener(KeyboardEvent.KEY_DOWN, detectPoop);
function detectPoop(moveDog:KeyboardEvent):void{
if (moveDog.keyCode==Keyboard.UP) {
//daffy_mc.rotation=0;
scooperDog.y-=15;
}
if (moveDog.keyCode==Keyboard.LEFT) {
//daffy_mc.rotation=-90;
scooperDog.x-=15;
}
if (moveDog.keyCode==Keyboard.RIGHT) {
//daffy_mc.rotation=90;
scooperDog.x+=15;
}
if (moveDog.keyCode==Keyboard.DOWN) {
//daffy_mc.rotation=180;
scooperDog.y+=15;
}
}
this much works thus far but trying to figure out how to get the poop to disappear. i did try hitTest so that poop alpha would go to zero, which worked in another project i did but not this one.
if (scooperDog.hitTestObject(poop1)) {
poop1.alpha=0;
}
thank you for the input.
lisa