Flash man by Zerofractal Studio
Read the original post from 10/17/2008 HERE
Read the later version with sample files from 2/25/09 HERE
Since October, I have been receiving at least one email a week on my deeplinking with SWFAddress tutorial. I thought that one in particular might be of use to others trying to master deeplinking, so I am posting it here with his approval.
Vaughan van Dyk also provided a wealth of files for users. Here are his comments:
“I have CS2, so I’ve attached your original in that format along with as many comments as possible in the time available (swf_address-v), because comments will likely be the easiest for people to follow along to. (Download the files for personal use HERE.)
I have also attached my stripped-down version (simple-v), which removes preloader/splash screen/neat titles and just demos use of core SWFAddress. Maybe people start there with the basics and then progress onto your swf-address, and then eventually to the samples. You are welcome to use these however you need – I hope they can be of help.” (Download the files for personal use HERE.)
He also provided sample files, but I am unable to access my server while in Honduras, so I will post them upon returning in late July. If you have other tips and/or suggestions, please add them in the comments below so we can grow out this troubleshooting forum for SWFAddress!
Hi Tracy,
Firstly I just want to thank you for the brilliant service you provided to the world by giving your ‘cut-down’ example of SWFAddress in action!
I recently happened upon SWFAddress and explored using it for some Flash work where I wanted a smooth solution for jumping to specific frames in a Flash file. But the official SWFAddress documentation is particularly workmanlike (just telling you what everything does but not how to get it working together) and all the samples involve a needless number of other features without any commented code to let you know why they are doing what they’re doing.
I almost gave up eventually, but thankfully found your post:
http://www.innovativeinteractivity.com/2009/02/25/example-files-and-tips-for-deeplinking-with-flash-swf-address/
Using that, I could achieve what I was looking for!
As a small thank-you and if you don’t mind, I’d like to suggest that your code/example could be cut down even further, to a truly bare-bones implementation so that those who want to add extra features (e.g. preloader) can do so, but don’t have to have excess code lying around if they aren’t going to use those features.
Here’s what I found, and please note that I am a long-time traditional programmer but a fairly-new ActionScript coder so errors and omissions expected:
1. Your swf_address zip file includes two .DS_Store files, which aren’t necessary for this.
2. Although the article talks of using AS2, the actual FLA in the zip was authored in CS3. It would be nicer to have it in CS2, which would be forwards-compatible.
3. In frame 2’s AS, the following code is only needed if you have a preloader on frame 1 – if you don’t, it can be entirely omitted because the first frame will be your title page:
if (_currentframe 2 && value ”) {
intro.play();
} else {
gotoAndStop(‘$’ + value);
}
4. Frame 2’s three “custom utilities” functions manipulate the frame label to make it neater for displaying in the title bar of the browser. The three functions are quite complex but are entirely optional.
5. In the onChange function, the getPath and getParameter methods are only needed if you have multi-level pages. In the SWFAddress Portfolio sample, they use this for the Portfolio – 1 2 3 subpages that create URLs such as http://www.asual.com/swfaddress/samples/flash/#/portfolio/2/. If you’re not going to use subpages, you don’t need these two methods – getValue is all we want.
6. It’s not necessary to repeat frame 3’s AS code in every frame thereafter.
Also it would be useful to point out that your and my versions here use SWFAddress 2.2 (and AS2 as you mention). SWFAddress recently updated the AS/JS to version 2.3 but that did bring with it a few issues for some. I’m sticking with 2.2 for now.
And the following are just some of my findings about using SWFAddress for jumping to specific frames. Probably all of it you know but may be useful for some of your readers:
Important: You can only test SWFAddress by running the HTML file from a server. So you can’t just load it normally on your local machine and see the URL change dynamically. This was a bit of a worry given that you’d actually want to test it first. So you will need to use something like XAMPP and put your folder in the xampphtdocs folder and then with XAMPP running, in a browser go to http://localhost/yourfolder/index.html …voila the URL now changes dynamically.
Once you strip out all that excess code, using SWFAddress for jumping to a specific frame is really rather simple. At its core, it’s one major function and a few methods:
* the main function is SWFAddress.onChange and it’s triggered everytime the URL changes; basically stripping out the important bit from the URL (e.g. the #page05 bit) and using that in Flash to go to the appropriate frame with that label
* then every button that affects navigation uses SWFAddress methods for the following three button events:
onRollOver (optional – uses setStatus to add to the URL that displays in the browser’s status/prompt bar at the bottom of the browser when your pointer rolls over the button)
onRelease (important – uses setValue and specifies what to add to the URL to uniquely identify the page by specifying the named frame to jump to, which of course will then trigger onChange – you do not need to use gotoAndStop as well in this onRelease event because that is done in onChange)
onRollOut (optional – uses resetStatus to clear the browser’s status/prompt bar so that nothing displays there when your pointer rolls away from the button)
* I wanted to remove references to # in the original code to save one having to set all the named labels to have # in front (e.g. #page08) but it caused the pages to cycle when one jumps to a specific frame and I’m not sure why. For now, it’s definitely safest to just prepend frame labels with a #
——————————
Again, I am not trying to be critical in the least with this, just some suggestions and findings. Especially for the slightly newer coder out there who will find this article. As I said, your site is the true saviour of SWFAddress and I just want to see it grow!
Keep up the great work and thanks again.
Vaughan
Discussion
No comments for “FlashTip: Updated tips on SWFAddress”
Post a comment