I am using SWFAddress for deeplinking my flash site and am not able to get the sections to load/reload with the forward/back browser buttons (or when I type the appending section name in the address bar). The code works so that the section title is being appended when I access each section through the site, just not the browser …
import com.asual.swfaddress.*;
SWFAddress.addEventListener(SWFAddressEvent.CHANGE, onChange);
function onChange(e:SWFAddressEvent):void {
if (e.value != "/") {
SWFAddress.setTitle("Title | " + e.value.substring(1));
} else {
SWFAddress.setTitle("Title | Home");
}
switch (e.value) {
case "/home" :
goSection(null);
break;
case "/company" :
goSection(null);
break;
case "/products" :
goSection(null);
break;
case "/catalog" :
goSection(null);
break;
case "/gallery" :
goSection(null);
break;
case "/contact" :
goSection(null);
break;
case "/" :
goSection(null);
break;
}
}
for (var i:uint = 0; i < pBtns.length; i++) {
pBtns*.addEventListener(MouseEvent.CLICK, goSection);
}
}
function goSection(event:MouseEvent):void {
var instanceName:String = event.currentTarget.name;
var secReq = new URLRequest(instanceName + ".swf");
//swf address
SWFAddress.setValue(instanceName);
//unload exg content;
secLoader.unloadAndStop();
//load section content;
secLoader.load(secReq);
//section preloader;
secLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, secPreloader);
function secPreloader(event:ProgressEvent):void {
...
}
}
…I am also getting an error msg in my flash file with the “onChange” function …
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main_fla::MainTimeline/goSection()
at main_fla::MainTimeline/onChange()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.asual.swfaddress::SWFAddress$/_dispatchEvent()
at com.asual.swfaddress::SWFAddress$/_setValueInit()
at com.asual.swfaddress::SWFAddress$/_check()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()