I had this file working flawlessly when it was it was a single .flv file, but I need to code part of the code with oop and be able to reference it with my original .flv file. I am hopelessly stuck and quite new to flash any help would be great.
Thanks,
This is the code I have to call my OOP from the .flv file
apple_mc.x=stage.stageWidth / 1.5;
apple_mc.y=stage.stageHeight / 7;
import keys;
var Keys:keys = new keys();
This is what I have for my OOP
package {
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.;
import flash.ui.;
public class keys extends MovieClip {
public function keys(){
trace(“flashes”);
//apple_mc.x = stage.stageWidth / 1.5;
//apple_mc.y = stage.stageHeight / 7;
var speedY:Number = 0;
var speedX:Number = 0;
var radius:Number = apple_mc.height / 2;
var friction:Number = .91;
var ax:Number = 0;
var ay:Number = 20;
var gravity:Number = 0.5;
//addEventListener(MouseEvent.MOUSE_DOWN, appledrop);
function appledrop(e:MouseEvent):void {
this.addEventListener(Event.ENTER_FRAME, applefall);
}
addEventListener(MouseEvent.MOUSE_DOWN, appledrop);
function applefall(e:Event):void {
speedY += gravity;
speedY += ay;
speedX += ax;
speedY *= friction;
speedX *= friction;
apple_mc.y += speedY;
apple_mc.x += speedX;
if (apple_mc.y + radius > stage.stageHeight) {
apple_mc.y = stage.stageHeight - radius;
speedY *= -1;
} else if (apple_mc.y - radius < 0) {
apple_mc.y = radius;
speedY *= -1;
}
if (apple_mc.x + radius > stage.stageWidth) {
apple_mc.x = stage.stageWidth - radius;
speedX *= -1;
} else if (apple_mc.x - radius < 0) {
apple_mc.x = radius;
speedX *= -1;
}
}
addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
function keyDownHandler(e:KeyboardEvent):void {
switch (e.keyCode) {
case Keyboard.LEFT :
ax = -0.5;
break;
case Keyboard.RIGHT :
ax = 0.5;
break;
case Keyboard.UP :
gravity = 0;
ay = -0.5;
break;
case Keyboard.DOWN :
ay = 0.5;
break;
}
}
function keyUpHandler(e:KeyboardEvent):void {
gravity = 0.5;
ax = 0;
ay = 15;
}
}}
}