Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : Named Anchor Weirdness


BoltUpright
2/16/2004 7:03:38 PM
I am trying to retrofit an existing flash project to use named anchors for
forward and back buttons. Originally, the site had a menu of 7 buttons, each
of which called a function to load the relevant content... nothing complicated.
To implement the named anchor navigation, I have created 7 empty frames on the
_root timeline, labeled them and set them as anchors. Then I removed the
function call from the button and changed the button action to
gotoAndStop("framelabel") I put the previously existing function call on the
respective frame along with a stop action. This works perfectly. Click the
button, the timeline jumps, the function executes and the content loads...
awesome... However... when I click the back button, it doesn't go back to the
previously viewed frame, it goes back to the frame previous to the current one
on the time line. For example, assuming Home is button 1 and the default
starting position, when I click on say, button 3, then click the browser's back
button, it goes to the frame for button 2. A subsequent press of the back
button goes to the frame for button 1.

It looks like flashplayer is inserting all the anchor frames into the
javascript history list, not just what is clicked on. For instance, if I am on
button 1 and click button 6, I hear 5 IE navigate 'clicks', and 5 objects are
inserted into the browser history between the page I was on and the page I
selected.

I have tried many things, both in this mentioned flash movie, as well as new,
blank ones and it doesn't seem to matter if the named anchors are frames,
scenes or any combination of the two. If anyone can shed any light on this
matter, I would greatly appreciate it


Jeckyl
2/17/2004 8:24:56 AM
Yes .. its another Flash Player bug.

Named anchors are effectively broken.

They only work for linear movies with no jumping backwards.

As soon as your movie does a gotoAndPlay to an earlier frame, ALL the frames
from start of movie to that earlier frame are added to the history (as if
you had instead gone to the beginning and then jumped to each of the named
anchors in turn until you got to the frame you wanted).

SOLUTION: Don't use named anchors. They are useless.

BoltUpright
2/20/2004 7:30:09 PM
With a little help, I found a solution that works very well... It's kind of
hackish, but it's a nice workaround... Basically it involves adding a hidden
1px frame (or IFRAME) to your html and creating separate single frame tiny
flash movies for each 'page' of your flash site. The tiny movies are embedded
in html as normal and button actions that previously jumped sections in your
main flash are changed to getURL the tiny movie's html page into the hidden
frame... Then a localConnection call in the hidden movie directs the main
flash to goto and play the frame it's supposed to, or whatever the original
button action was supposed to be. Since you are actually loading a real html
document by clicking the buttons, the browsers history object is properly
updated and you can successfully navigate the site with the forward and back
buttons.... very nice
AddThis Social Bookmark Button