define('DISALLOW_FILE_EDIT', true); Javascript – Page 2 – unFocus Projects – Kevin Newman and Ken Newman

unFocus.History Keeper 2.0 (and SwfHTML) Beta 4 – Out Now!

A brand spanking new Beta 4 of unFocus.History Keeper is out, and ready for download! Download it from Google Code. (If you are wondering what happened to Beta 3 – I actually rolled that update about half way, and had it sitting in SVN for a while, but I never made the archive, or release notification.)

Sloppy change log:

Fixed Flash Player 10 PlugIn detection.
Changed license to MIT
Quick and dirty temp IE8 support (makes IE8 use the timer method).
– removed ObjectPatentMagic
– added Packed library files for Beta 4 (says RC1 in SVN, but I changed my mind, there’s more I’d like to add).
– Added svn:keywords to most files.
– Updated tests for EventManager, FlashPlayerInfo, HistoryKeeper, SwfHTML and SwfShim.
– removed WebTV code, since the entire FlashPlayerInfo script doesn’t work in WebTV anyway.
– Fixed Issue 5. Added methods for major, minor and bugfix versions, to reflect changes to the convention in Flash Player 10 – Also cleaned up issues releated to the changes in IE.
– Added getUpdateVersion for the special case Flash Player 9 updates.
– Quick fix for shimMode on SwfShim.
– Fixes IE support.
– Adds shimMode property (it’s off by default).
– Fixed typo in call to get initial hash value (deep link), which broke it.
– Updates to the HistoryKeeper Actionscript 3.0 files. These changes are generally significant.
– Added asdocs comments (to AS3 files).
– Added support for Opera’s history.navigationMode.
– Made IE8 Hack detection more robust, and IE detectin simpler.
– Initial commit of Actionscript HistoryKeeper and AS3->JS communication framework (really just an easier replacement for fscommand). All of this is pretty rough – vomit draft material.
– Some smaller code comment and formatting cleanups.
– removed problematic _createAnchor functionality. (Issue 6)
– updated IE version detect to be compatible with multi-digit versions.
– Reworked Error messages so that they make sense in FireBug and other Javascript consoles. Fixes Issue #3
– Added direct and gpu WMode values.
– Made value checking case insensitive.
– Added SVN keywords Revision and Date, and added text/javascript mime-type.
– Fixed SwfShim.

Enjoy! 🙂

unFocus.FlashPlayerInfo update for Player 10

Adobe has updated their versioning system for Flash Player. This welcome change, creates a few backward compatibility problems with FlashPlayerInfo though, since the terms I applied to each version decimal place, do not match Adobe’s new terms (they are off by one place-ish, sorta).

To address these changes I added a new set of methods to check for the new “major”, “minor” and “bugfix” version numbers, for Flash Player 10+. The old methods will return the same data it does now (Version.MajorRevision.MinorRevision.BetaVersion). The new methods will not work for older Player versions of Flash Player (or at least won’t make sense), returning the data from the new format instead (MajorVersion.MinorVersion.BugfixVersion.build). In older players, getBugfixVersion would refer to “r” or third decimal place version number, which is what you used to look for when trying to detect something like r115. For older players you should continue to use the older getMinorRevision method. There should be no need to update your current detection routines, unless you need to target this new information. One change worth noting, will hopefully not be noticed – getVersion now returns both of MajorVersion and MinorVersion as a JavaScript Number, so that you can check against dot releases (getVersion() > 10.1). This should not affect backward compatibility.

In addition, for Flash Player 9, Adobe released 3 feature or compatibility breaking security updates with strange version names (update 3 was r115 for example, and was significant, adding H.264 and AAC support to the player). So for the special case of Player 9, I added getUpdateVersion. Since Player 9 was the only version to get the odd update versions, this really only applies to that version.

These changes also means that some of the old properties are probably useless in Player version 10+, such as the beta flags and beta version numbers, and getReleaseCode in IE. I used to infer that information from the 4th decimal place, which used to always be 0 except in beta and pre-release builds (based on my observation). In the new version number convention that 4th place is just a build number.

Here are the new methods:
[cc lang=’javascript’ ]unFocus.FlashPlayerInfo.getMajorVersion();
unFocus.FlashPlayerInfo.getMinorVersion();
unFocus.FlashPlayerInfo.getBugfixVersion();
unFocus.FlashPlayerInfo.getBuildNumber();[/cc]

The updated script is in SVN, and will be in the next release.

SwfHTML will probably get a similar update as well.

AS3 unFocus.HistoryKeeper in SVN trunk

I added an initial round of AS3 files to the SVN trunk to make HistoryKeeper more accessible from Actionscript 3.0. If you are feeling adventurous, feel free to check it out of the trunk, and give it a try.

There is also a small resurrected Actionscript to Javascript communicator (eh, it’s totally new actually, but I got to use old knowledge!). The theory is that if you use fscommand to send simple strings to Javascript, you save on Flash setting up a lock to wait for a Javascript call to return a value or finish executing, which should conceivably avoid a short hiccup in the Flash Player. I’m not sure if there’s a real world benefit or not yet – one day I might get around to testing to make sure. At the very least, this framework will make it easier to setup fscommand, since it takes care of creating the javascript snippet for you. After that, it will simply eval whatever you put in the command argument (unless it’s a simple function on window, then it’ll just execute that).

Any comments are welcome. Please note, these classes may change quite a bit, they’re not to be considered stable (though the API probably is, there’s not much there really).

MouseWheel on Mac

So for some reason MouseWheel.SCROLL events don’t work on Mac OS X. There is a fix! Gabriel over at Pixel Breaker created a script which fixes it up nicely.

The script did require some modification to get it to work with SwfHTML, since it was designed to work with SwfObject. It took very little modification to the JavaScript to make it work with any flash embedding script. The script has a register method that takes an id, and uses SwfObject’s getObjectById method to get the swf ref – I just changed the register method to take a swf reference instead of an id string, and viola! It works with anything now. While I was at it, I also took care of some errors you might get on non-mac browsers. Here’s how to use it:

[cc lang=’javascript’ ]
// with SwfHTML
swfmacmousewheel.registerObject(
unFocus.SwfUtilities.getSwfReference(“swfId”)
);

// with SwfObject
swfmacmousewheel.registerObject(
SwfObject.getObjectById(“swfId”)
);
[/cc]

You can really use any method you want to get a reference to the swf object, and pass that in.

Here is the updated swfmacmousewheel javascript file. Note, you will still need to grab the source and follow the instructions from Pixel Breaker.

Quick Update – HistoryKeeper, SwfHTML, SwfShim

Just a quick post.

There have been a couple of fixes and changes that have gone into HistoryKeeper, SwfHTML and SwfShim that are now in the SVN trunk, as well as a few other issues that have been nailed down, and put into the issue tracker.

Among the fixes are finally a fix for the incorrect use of Javascript Errors in SwfHTML, as well as fixing the previously unfinished SwfShim.

Despite the fact that I can’t figure out how to pass flashvars from SwfShim to loaded AS3 based swfs, I’m still going to include it anyway, with a note about that caveat. It does solve some other issues, and adds an easy way to utilize ExpressInstall even if you are using html to embed the swf (rather than javascript). More on that in a future post.

I’ll also be cleaning house around the site, here and on google code. I’ve already removed some old lingering (and useless) ad stuff.

Also, since Microsoft removed the “click to activate” silliness, I went ahead and deprecated PatentMagic. It was buggy anyway.

Check back for more updates, and hopefully, an actual release!