I've been trying to solve this issue over the last couple of days. I am now at the current state:
on a deeplink event the page updates and now so does the browser title!! and when you click recent project and previous project to update the page the browser title is ALSO updated fine. I've also added a little debugging so you can check in the console in firebug if deeplink is firing through.
However when you use the browser buttons to go back and forth, the website still behaves appropriately but the browser title does not update. even through it should be exactly the same process. Check:
http://clients.lukesturgeon.co.uk/dev/#/work/I also need to get the site to check the full URL at the beginning because at the moment I cannot directly deeplink to a project page.
onDeeplink override in WorkPage.asoverride public function onDeeplink(e:GaiaSWFAddressEvent):void
{
if(Gaia.api.getCurrentBranch().indexOf("work") != -1)
{
// reset imageviewer for next time
projectPage_mc.imageViewer_mc.gotoAndStop("load");
// it is still on the WORK page
var link:String = e.deeplink.substr(1);
if(link.length > 0)
{
// show a project
if(projectPage_mc.visible)
{
// dont need to fade in
projectPage_mc.transitionIn(link);
}
else
{
// need to fade in
projectPage_mc.transitionIn(link, true);
}
// show pagination
if(projectPage_mc.paginator_mc.currentFrame == 1)
{
projectPage_mc.paginator_mc.gotoAndPlay("in");
}
}
else
{
// show the thumbnails
TweenLite.to(projectPage_mc, 0.3, {alpha:0, onComplete:function():void{projectPage_mc.visible = false}});
}
}
}
if necessary the code calls a method in ProjectPage.as (this is not a Gaia page but I wanted to keep the same method names for consistancy.
transitionIn in ProjectPage.as just resets the page ready to load new content
public function transitionIn(deeplink:String, tween:Boolean = false):void
{
// clear old project
client_txt.text = "";
agency_txt.text = "";
role_txt.text = "";
project_txt.text = "";
project_txt.height = 10;
viewProject_mc.visible = false;
viewProject_mc.button_txt.text = "";
// get the relevant xml node
_projectXml = parent.assets.myXml.xml..project.(@name == deeplink);
if(tween)
{
visible = true;
alpha = 1;
TweenLite.from(blocker_btn, 0.3, {alpha:0, onComplete:transitionInComplete});
}
else
{
transitionInComplete();
}
}
Then it calls transitionInComplete in ProjectPage.as, it is this method that updates the browser title
private function transitionInComplete():void
{
// set the browser title
Gaia.api.setTitle("Luke Sturgeon / Work / " + _projectXml.title)
// start loading images
imageViewer_mc.push(_projectXml.images);
// animate in text
Typewriter.insert(client_txt, "Client / " + _projectXml.client);
Typewriter.insert(agency_txt, "Agency / " + _projectXml.agency);
Typewriter.insert(role_txt, "Role / " + _projectXml.role);
project_txt.autoSize = TextFieldAutoSize.LEFT;
Typewriter.insert(project_txt, _projectXml.text, {timer:6, onComplete:createLink});
}
In theory this should happen EVERY time the page update because the page is updating properly, but the browser buttons do not update the browser title as well?