Userfrienly links in flash based websites

  • gunjan
  • Born
  • Born
  • gunjan
  • Posts: 2

Post 3+ Months Ago

Hi,
I am working on a flash as2.0 based website. One can visit other pages of this website by navigation buttons(flash). The problem is when inner pages are changed its website address(in browser address bar) showing the same address(as it was in start).
I want to go through the pages as "www.abc.com/home or /aboutus" (same as a simple html page).
Please help me...

Thanks,
Gunjan :?:
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

Quote:
The problem is when inner pages are changed its website address(in browser address bar) showing the same address(as it was in start)


So do you mean that the links arent doing anything or they are just loading the same original page over and over?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

I think he means that when he's navigating through pages, the url adress doesn't change.
For this you can use javascript to set the URL in the browser. How? ... not sure, just google.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

You'll have to use anchors instead of addresses like you're used to.

For instance, instead of
Code: [ Select ]
http://www.site.com/section/page

It will be something along the lines of
Code: [ Select ]
http://www.site.com/#section/page

Without the hash, altering the location in the browsers address bar will cause the document to refresh/reload.

A few simple javascript functions to work with the location in the document make it a little easier on Flash.
If you've ever tried to use "FSCommand", you'll definitely appreciate the replacement called "ExternalInterface" that will work with those javascript functions from Flash.

Here's a basic read/write set of javascript functions for setting the location field so it can be bookmarked & retrieving that information when a bookmark is accessed.
Code: [ Select ]
function setLocation(href){
  if(href.charAt(0) != '#'){
   href = '#' + href;
  }
  window.location.href = window.location.href + href;
}

function getLocation(){
  var hash = window.location.href.split('#');
  if(hash.length > 1){
   return '/' + hash[1];
  }else{
   return '/';
  }
}
  1. function setLocation(href){
  2.   if(href.charAt(0) != '#'){
  3.    href = '#' + href;
  4.   }
  5.   window.location.href = window.location.href + href;
  6. }
  7. function getLocation(){
  8.   var hash = window.location.href.split('#');
  9.   if(hash.length > 1){
  10.    return '/' + hash[1];
  11.   }else{
  12.    return '/';
  13.   }
  14. }


Within the Flash movie, you'll begin with importing the ExternalInterface.
Code: [ Select ]
import flash.external.ExternalInterface;

Then use the static "call" method of ExternalInterface to use those location manipulation functions.
Code: [ Select ]
// Save the location,
// assuming "path_hash" was a path used to load an XML document,
// or another movie.

ExternalInterface.call("setLocation", path_hash);

// This might be used when the movie first loads,
// to check for a bookmark, ect.

var path_hash:Object = ExternalInterface.call("getLocation");

myXML.load( base_url + path_hash );
  1. // Save the location,
  2. // assuming "path_hash" was a path used to load an XML document,
  3. // or another movie.
  4. ExternalInterface.call("setLocation", path_hash);
  5. // This might be used when the movie first loads,
  6. // to check for a bookmark, ect.
  7. var path_hash:Object = ExternalInterface.call("getLocation");
  8. myXML.load( base_url + path_hash );


An advanced example of this technique can be see at 2advanced, the following link will load the main movie, then take you directly to their Senior Management page once the libraries are loaded.
http://www.2advanced.com/#company/team/senior

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 5 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.