I’m trying to create a little movie that has popcorn flying all over.
I have the graphics in a .fla file, whose Document class is linked to the file below (let’s call it Physics), but I continue to get this error:
1180: Call to a possibly undefined method addEventListener.
Code:
package
{
import flash.display.*;
import flash.events.Event;
import Pop;
// an array in which to store our particles
var particles:Array = new Array();
// call frameLoop every frame
addEventListener(Event.ENTER_FRAME, frameLoop);
function frameLoop(e:Event)
{
var particle:Pop;
// loop through the array of particles and update each one
for(var i : int = 0; i < particles.length; i++)
{
// update the particle at index i
particles*.update();
}
// make a new particle
particle = new Pop(Popcorn, this, 150,125);
// set our particle's velocity
particle.xVel = randRange(-7,7);
particle.yVel = randRange(-10,-5);
// add drag
particle.drag = 0.99;
// add gravity
particle.gravity = 0.4;
// randomise initial particle size
particle.clip.scaleX = particle.clip.scaleY = randRange(0.1,2.5);
// add shrink
particle.shrink = 0.98;
// and add it to the array of particles
particles.push(particle);
// if there are more than 100 particles delete the first
// one in the array...
while(particles.length>100)
{
particle = particles.shift();
particle.destroy();
}
}
// returns a random value between min and max
function randRange(min:Number, max:Number)
{
return Math.random()*(max-min)+min;
}
}