PLZ HELP ASAP I am having 10 errors (1120) associated with the access of undefin
ID: 3532208 • Letter: P
Question
PLZ HELP ASAP
I am having 10 errors (1120) associated with the access of undefined property.
onEnterFrame, onClick, onLeftClick, MouseUp, onUpClick, MouseUp, onDownClick, MouseUp, onRightClick, and MouseUp.
The Errors are being thrown from the .addEventListener fron lines 58 to 73
Also im trying to do a Frogger Script
package
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
import flash.events.MouseEvent;
public class frogKatta extends MovieClip
{
// Create instances of library symbols
var car1:Car = new Car();
var car2:Car = new Car();
var truck1:Truck = new Truck();
var truck2:Truck = new Truck();
var frog:Frog = new Frog();
var FinishLine:finishLine = new finishLine();
var HealthBar:healthBar = new healthBar();
var vx:int = 0;
var vy:int = 0;
var hit:Boolean = false;
var carStart:Boolean = false;
var truckStart:Boolean = false;
public function frogKatta()
{
frog.x = 230;
frog.y = 375;
truck1.x = 545;
truck1.y = 230;
truck2.x = 560;
truck2.y = 235;
car1.x = 550;
car1.y = 78;
car2.x = 560;
car2.y = 80;
// add created instances to stage
addChild(frog);
addChild(truck1);
addChild(truck2);
addChild(car1);
addChild(car2);
// * PROBLEM WITH STAGE.ADDEVENTLISTENER
// Add event listener for keyboard
// PROBLEM STARTS HERE ***********
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
// Add Event for mouse click
stage.addEventListener(MouseEvent.CLICK, onClick);
// creating instance of onClick from the MouseEvent.CLICK
//Keyboard
left.addEventListener(MouseEvent.MOUSE_DOWN, onLeftClick);
// to move
left.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
// to stop
up.addEventListener(MouseEvent.MOUSE_DOWN, onUpClick);
up.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
down.addEventListener(MouseEvent.MOUSE_DOWN, onDownClick);
down.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
right.addEventListener(MouseEvent.MOUSE_DOWN, onRightClick);
right.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
// PROBLEM ENDS HERE****
// Keyboard functionality
function onKeyDown(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT)
{
vx = -5;
frog.play();
}
else if (event.keyCode == Keyboard.RIGHT)
{
vx = 5;
frog.play();
}
else if (event.keyCode == Keyboard.DOWN)
{
vy = 5;
frog.play();
}
else if (event.keyCode == Keyboard.UP)
{
vy = -5;
frog.play();
}
}
// Keyboard again to stop
function onKeyUp(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT || event.keyCode == Keyboard.RIGHT)
{
vx = 0;
frog.stop();
}
else if (event.keyCode == Keyboard.DOWN || event.keyCode == Keyboard.UP)
{
vy = 0;
frog.stop();
}
// Clicking Functionality
function MouseUp(event:MouseEvent):void
{
vy = 0;
vx = 0;
frog.stop();
}
// on"librarybutton name left" Click
function onLeftClick(event:MouseEvent):void
{
vx = -5;
frog.play();
}
function onUpClick(event:MouseEvent):void
{
vy = -5;
frog.play();
}
function onDownClick(event:MouseEvent):void
{
vy = 5;
frog.play();
}
function onRightClick(event:MouseEvent):void
{
vx = 5;
frog.play();
}
// on enter frame
function onEnterFrame(event:Event):void
{
frog.x += vx;
frog.y += vy;
truck1.x += -10;
car1.x += -20;
//Car1 & 2 SCREEN WRAPPING
if (car1.x <= -400)
{
car1.x = 550;
}
// If car 1 leaves screen add car to other side of the screen
if (car2.x <= -400)
{
car2.x = 550;
}
if (car1.x <= 135)
{
carStart = true;
}
// Screen wrap so if car is less than or equal to 135 in distance add another car
if (carStart)
{
car2.x += -15;
}
//Truck1 & 2
if (truck1.x <= -400)
{
truck1.x = 550;
}
if (truck2.x <= -400)
{
truck2.x = 550;
}
if (truck1.x <= 135)
{
truckStart = true;
}
if (truckStart)
{
truck2.x += -10;
}
if (frog.hitTestObject(truck1) || frog.hitTestObject(truck2) || frog.hitTestObject(car1) || frog.hitTestObject(car2))
{
frog.y += 10;
hit = true;
}
if (hit)
{
if (HealthBar.width < 10)
{
HealthBar.width = 0;
}
else
{
HealthBar.width -= 10;
}
}
if (HealthBar.width < 1)
{
//S.O.P you lose);
}
if (frog.hitTestObject(FinishLine))
{
removeChild(frog);
removeChild(FinishLine);
removeChild(car1);
removeChild(car2);
removeChild(truck1);
removeChild(truck2);
// addchild of you winning
}
}
}
}
}
}
Explanation / Answer
var loaded:Object; loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoaded); function handleLoaded(e:Event):void { loaded = event.target.content; } load2.addEventListener(MouseEvent.CLICK, handleClick); function handleClick(e:MouseEvent):void { if (loaded) { loaded.gotoAndPlay("outro"); } //load new swf } if (carStart) { car2.x += -15; } //Truck1 & 2 if (truck1.xRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.