Hi guys,
I really hope someone is able to help me with this problem. Its driving me crazy :jail: . Ok so here it goes. I have 4 files, InsideCastle.fla, InsideCastle.as, PointBurst.as, and IntrotogameTESTING.fla. Im trying to run IntrotogameTESTING.swf and when you click on a button I am trying to open InsideCastle.swf.
The code in InsideCastle is as follows:
//import fl.accessibility.ButtonAccImpl();
//ButtonAccImpl.enableAccessibility();
import flash.net.URLRequest;
import flash.events.*;
var externalSWF:URLRequest = new URLRequest(“InsideCastle.swf”);
var myLoader:Loader = new Loader();
Castle_btn.addEventListener(MouseEvent.CLICK, onButtonClick);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, swfLoading);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfComplete);
function onButtonClick(event:MouseEvent):void
{
myLoader.load(externalSWF);
}
function swfComplete(event:Event):void
{
addChild(myLoader);
//myLoader.x = //you can adjust the x postion here
//myLoader.y = //adjust the y position here
}
function swfLoading(eventprogressEvent):void
{
//you can do something here while the swf is loading…
}
It throws the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at InsideCastle/scrollWithHero()
at InsideCastle/gameLoop()
The code in scrollWithHero is:
public function scrollWithHero() {
scrollWithHero != null;
//if (scrollWithHero == null) {
// addEventListener(Event.ADDED_TO_STAGE, scrollWithHero);
// }
var stagePosition:Number = gamelevel.x+hero.mc.x;
var rightEdge:Number = stage.stageWidth-edgeDistance;
var leftEdge:Number = edgeDistance;
if (stagePosition > rightEdge) {
gamelevel.x -= (stagePosition-rightEdge);
if (gamelevel.x < -(gamelevel.width-stage.stageWidth)) gamelevel.x = -(gamelevel.width-stage.stageWidth);
}
if (stagePosition < leftEdge) {
gamelevel.x += (leftEdge-stagePosition);
if (gamelevel.x > 0) gamelevel.x = 0;
}
}
And the code in gameLoop is:
public function gameLoop(event:Event) {
gameLoop != null;
// get time differentce
if (lastTime == 0) lastTime = getTimer();
var timeDiff:int = getTimer()-lastTime;
lastTime += timeDiff;
// only perform tasks if in play mode
if (gameMode == “play”) {
moveCharacter(hero,timeDiff);
moveEnemies(timeDiff);
checkCollisions();
scrollWithHero();
}
}
You have no idea how much I need help! Im officially going mad. If you need more code to get an idea just gimme a shout!
Thanks in advance! :beam: