Say you have a Flash widget that you need to put on the server to receive dynamic data yet you want to test it in Flash with all of your nice trace(); statements etc... The only trouble is that when you post it to the server you always forget to comment out the values that you test with. These are the hard coded values you typed into the file or Class. You don't want to have to remember each time you FTP the file up to the server to comment out those pesky variables that are critical for testing in the Flash authoring tool.
The solution to the problem is quite simple. All you need to do is ask Flash where it lives. You do this by having Flash ask what is its URL using this._url
Here is the code:
if (this._url.substr(0,5) == "file:")
Because anything run in Flash will be located at a file path, ask if the location(_url) name starts with the characters "file:" - this._url.substr(0,5) == "file:"
If the answer is yes then set your variables - var totalBytes:Number = 2712
A web address will never start with the characters "file:" but rather "http" or the name of a subdomain. Because of this the variables will not yet be defined when the file is on the server and your .swf will be ready to receive anything the server has to throw at it. And yet, you will always be able to test it in the Flash authoring environment.
I am putting up a test experiment for a Flash class that I built that will add a lot of functionality to the Google Analytics. Please help me test out my class by simply playing with the Flash objects below. Mouse over them click on them, just leave your mouse alone and do nothing at all.
The purpose of this Flash and Google Analytics experiment is to get more granular data about how the user interacts with the Flash object. The class I've created will tell me how long it takes people before they interact with the piece, how long they are interacting with it, how many times the user mouses-over, clicks, etc...
Thanks for the help in testing this. I will post results next week.
Download Flash Switcher here. http://www.sephiroth.it/weblog/archives/2006/10/flash_switcher_for_firefox.php
For those of you not familiar with how extensions work you will want to download the extension (.xpi file). Open it from the download window and then when the download window asks what program to open it with find Firefox.
This should bring up a window like this:
Click "Install Now" and then after you restart look for it down in the corner of the browser.