New Member
✔️ HL Verified
💻 Oldtimer
I have to make an assignment for school, and basically we have to make this Christmas card, made completely with ActionScript 3. And mind you, I am a complete Actionscript 3 noob.
Now, it being winter and all, I added some snow to my card. The snow works fine, but we have certain prerequisites we have to meet for our card. One of them is the usage of a Hittest.
Now what I wanted to do was add a hittest to the snowflakes with the mouse, and have the flakes bounce of the mouse.
Now the problem with the code above is, whenever I start the movie, I will just get a complete list of traces, like it is just looping, without the flakes even hitting the mouse.
I'm sort of stuck now, I have tried a million things now, nothing works..
Now, it being winter and all, I added some snow to my card. The snow works fine, but we have certain prerequisites we have to meet for our card. One of them is the usage of a Hittest.
Now what I wanted to do was add a hittest to the snowflakes with the mouse, and have the flakes bounce of the mouse.
Code:
////////////////////////////////////////////////
////////////////////////////////////////////////
///////////////SNEEUWVLOKKEN CODE///////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
// Sneeuwvlokken lijst
var vlokken:Array = new Array()
//aantal sneeuwvlokken en snelheid
var aantal:int = 250;
var speed:int = 3;
var vlok:MovieClip; // maak nieuwe sneeuwvlok movieclip aan
for(var i:int = 0; i<=aantal; i++)
{
vlok = new MovieClip(); //Nieuw sneeuwvlokje aanmaken
vlok.graphics.clear();
vlok.graphics.beginFill(0xCCCCCC, 1) //Kleur sneeuw
vlok.graphics.drawCircle( -2, -2, 3 + Math.random()); // Grootte van sneeuwvlok
vlok.x = Math.random() * stage.stageWidth; //Beginpunt X
vlok.y = Math.random() * stage.stageHeight;//Beginpunt Y
// zet snelheid x in vlok
vlok.speedX = Math.random(); //Snelheid X
// zet snelheid y in vlok
vlok.speedY = 2 + Math.random() * 10; //Snelheid Y
vlok.scaleX = Math.random() * vlok.scaleY; // Verschillend in grootte X
vlok.scaleY = vlok.scaleX; // Neem Y grootte aan voor ronde sneeuwvlok
// voeg toe aan displaylist
addChild(vlok);
// voeg aan sneeuwvlokken lijst toe
vlokken.push (vlok);
}
stage.addEventListener(Event.ENTER_FRAME, intro);
function intro(e:Event):void
{
vlok.hitTestPoint(parent.mouseX, parent.mouseY, true)
{
trace("The mouse hits a snowflake")
}
}
addEventListener(Event.ENTER_FRAME, function():void
{
for (var i:int = 0; i < vlokken.length; ++i)
{
var vlok:MovieClip = vlokken[i] as MovieClip;
vlok.x += vlok.speedX;
vlok.y += vlok.speedY;
if(vlok.y > stage.stageHeight || vlok.x > stage.stageWidth)
{
vlok.x = Math.random() * stage.stageWidth;
vlok.y = -10;
}
}
}
)
I'm sort of stuck now, I have tried a million things now, nothing works..