I’m trying to have a document class using SWFAddress & gSkinners framescript manager class but keep getting SWFAddress errors…
This is the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.asual.swfaddress::SWFAddress$/::_getValue()
at com.asual.swfaddress::SWFAddress$/::_check()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()
This is the documentclass code:
package {
import flash.events.*;
import com.gskinner.utils.FrameScriptManager;
import flash.display.*;
import com.asual.swfaddress.*;
import caurina.transitions.*;
import caurina.transitions.properties.*;
public class Website extends MovieClip {
// constructor:
public function Website() {
//FrameScript setup
super();
SWFAddress.addEventListener(SWFAddressEvent.CHANGE , handleSWFAddress);
var fsm:FrameScriptManager = new
FrameScriptManager(this);
fsm.setFrameScript("$/",homeFunct);
fsm.setFrameScript("$/about/",aboutFunct);
fsm.setFrameScript("$/portfolio/",portfolioFunct);
fsm.setFrameScript("$/contact/",contactFunct);
}
// public getter/setters:
//**********************************************
// SWFAddress
//**********************************************
// Custom utilities
public function replace(str, find, replace):String {
return str.split(find).join(replace);
}
public function toTitleCase(str):String {
return str.substr(0,1).toUpperCase() + str.substr(1).toLowerCase();
}
public function formatTitle(addr):String {
if (addr.substr(addr.length - 1, 1) == '/') {
addr = addr.substr(0, addr.length - 1);
}
return 'Webbmall' + ((addr.length > 0) ? ' / ' + toTitleCase(replace(addr.substr(1), '/', ' / ')) : '');
}
// SWFAddress handling
public function btnClick(event:MouseEvent):void {
SWFAddress.setValue(event.target.link);
}
public function btnRollOver(event:MouseEvent):void {
SWFAddress.setStatus(event.target.link);
}
public function btnRollOut(event:MouseEvent):void {
SWFAddress.resetStatus();
}
public function handleSWFAddress(event:SWFAddressEvent):void {
if (currentFrame == 2 && event.value == '') {
play();
} else {
gotoAndStop('$' + event.value);
if (currentLabel == null) {
gotoAndStop('$/error/');
}
}
SWFAddress.setTitle(formatTitle(event.value));
}
// private methods, webbsidans olika sektioner:
//***************************************
// Hem - home
//***************************************
private function homeFunct():void {
// trace(“hem”);
stop();
}
//**************************************
// About - Om oss
//**************************************
private function aboutFunct():void {
// trace(“om oss”);
//
}
//***************************************
// Portfolio
//***************************************
// trace(“portfolio”);
//
}
//*********************************************
// Kontakt - contact
//*********************************************
private function contactFunct():void {
//trace(“kontakt”);
}
}
}
I would really appreciate some help with this one.
I’ve read that it’s usually an issue of stage or root access but I’m not sure - still new to AS3.
I also have some preload code on frame 1 in the movie:
function enterFrame(e:Event){
var bl:int = loaderInfo.bytesLoaded;
var bt:int = loaderInfo.bytesTotal;
if (bl && bt && bl == bt) {
removeEventListener(Event.ENTER_FRAME, enterFrame);
nextFrame();
} else if (loading_mc.bar_mc) {
loading_mc.bar_mc.scaleX = bl/bt;
}
}
addEventListener(Event.ENTER_FRAME, enterFrame);
stop();
All the best, Niklas