I'm almost entirely new to OOP, and I just don't understand how to call a method in one class from another. I'm trying to call a method in the Main.as from a custom class, but it always comes up as the "Call to possibly undefined method" error, and I don't know a way around it.
Main.as code:
package {
import flash.display.MovieClip;
public class Main extends MovieClip {
public var titleScreen:TitleScreen = new TitleScreen();
public var feedMeShibe:FeedMeShibe = new FeedMeShibe; //These are exported
public var milkbone:MilkboneItem = new MilkboneItem; //actionscript symbols
public var openMouthArea:OpenMouthArea = new OpenMouthArea; //in the library
public function Main() {
titleScreen.x = 350;
titleScreen.y = 250;
addChild(titleScreen);
}
public function addShibe(shibeX:Number, shibeY:Number, shibeSize:Number):void {
feedMeShibe.x = shibeX;
feedMeShibe.y = shibeY;
feedMeShibe.width = feedMeShibe.width*shibeSize;
feedMeShibe.height = feedMeShibe.height*shibeSize;
addChild(feedMeShibe);
}
public function addMilkbone(milkboneX:Number, milkboneY:Number, milkboneSize:Number):void {
milkbone.x = milkboneX;
milkbone.y = milkboneY;
milkbone.width = milkbone.width*milkboneSize;
milkbone.height = milkbone.height*milkboneSize;
addChild(milkbone);
}
public function addOpenMouthArea(OMAX:Number, OMAY:Number, OMAW:Number, OMAH:Number):void {
openMouthArea.x = OMAX;
openMouthArea.y = OMAY;
openMouthArea.width = OMAW;
openMouthArea.height = OMAH;
addChild(openMouthArea);
}
}
}
TitleScreen.as code:
package {
import flash.display.MovieClip;
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
public class TitleScreen extends MovieClip {
public function TitleScreen() {
createListeners();
}
private function createListeners():void {
this.addEventListener(Event.ENTER_FRAME, stopFrame);
}
public function stopFrame(e:Event):void {
if (this.currentFrame == 510){
this.removeEventListener(Event.ENTER_FRAME, stopFrame);
this.stop();
addShibe(100, 100, 0.5); //How do I
addMilkbone(50, 50, 0.6); //access the Main class
addOpenMouthArea(200, 200, 1, 1); //with these?
}
}
}
}
I don't normally ask questions online, but I'm at the end of my rope here. I'm completely stumped, and browsing tutorials and previous questions online is only further confusing me. Any help would be greatly appreciated.