• Home
  • About
  • Contact
  • Projects
    • Games
      • Blocks (Tetris Clone)
    • History Keeper - Deep Linking Toolkit
    • SwfHTML

unFocus Projects

A blog about unFocus Projects, and things of interest, including unFocus History Keeper.

Feed
  • A Simple State Manager for History Keeper

    Aug 26th 2010

    By: Kevin Newman

    No comments

    Someone asked how to store a key value pair in HistoryKeeper recently, and this was my answer.

    History Keeper does not provide any state management features beyond the information you store on the actual deep link (URL hash). However, you should be able to use the deep link information to grab the data you need out of a standard JS object (using it like a hash table):

    var storage = {
        "/": {
            key: "home value"
        },
        "/about": {
            key: "about value"
        }
    };

    Once you have your values stored like that you can use the storage object to lookup your chunk of data by the deep link string:

    function onHistoryChange(hash) {
        alert(storage[hash].key);
    }
    unFocus.History.addEventListener('historyChange', onHistoryChange);

    You can make the “value” as deep as you want ( key: {more: “complex”} ), I only used a simple string for demonstration purposes.

    This example is JavaScript, but the concepts are the same for Actionscript as well.

    I hope that helps!

    History Keeper, Tips & Tricks

    Actionscript, Ajax, deep linking, HistoryKeeper, Javascript

  • Frash shows Flash on iPhone can be Great (with Screenshots)

    Aug 11th 2010

    By: Kevin Newman

    No comments

    Warning: RANT ahead

    Steve Jobs is full of crap. I could actually understand and respect a straightforward admission that the Flash Platform is a threat to Apple’s iOS business model – which is the real reason Jobs won’t let Flash on the iPhone and iPad. That’s not even a very good reason – the App Store has many compelling features on it’s own, even if Flash is in the browser, not the least of which is the easy to understand path to monitization. Performance is another issue – Flash is fast enough, faster than JS/Canvas by quite a bit, but it’s still not as fast as a native app and all it’s OpenGL goodness (among all the other great Apple APIs). Keeping Flash off iPhone (and especially CS5 iPhone apps) has nothing to do with performance, or compatibility. That’s just bunk! And nobody likes a liar.

    /rant

    Here are some screenshots to show how well many sites I’ve been involved with work in Flash on the iPhone (3GS using jailbreak and Frash).

    adcSTUDIO's home page
    adcSTUDIO’s Home Page
    adcSTUDIO's about us section
    adcSTUDIO’s About Us Screen
    Terminal Design (before activating Frash)
    Terminal Design (before activating Frash)

    Terminal Design's Home Page (with Flash)
    Terminal Design’s Home Page (with Flash)
    Make Beliefs Comix app.
    Make Beliefs Comix app.
    March of Dimes - March for Babies Facebook app

    Beaverkill Press Homepage
    Inside the Beaverkill Press Microsite
    A text book app


    A quit note on the technology: this is using Frash, which is a hack (a wrapper or compatibility layer) to get the Android version of Flash Player 10.1 running inside of iOS – it has not been optimized (or even completed at this point) to run well on iOS yet, and probably will never run as well as it can on Android. A recent test app I’ve been playing with runs 50% faster on a Droid Eris, vs. the iPhone 3GS – the Eris is slower hardware, running Android 2.1. It’s also crashy, and is missing features like streaming movie support (it does work with videos embedded in a swf) – and touch events are not quite as streamlined as they are on a real Android device (hover works better on Android for example, and hot spots are easier to hit). It’s also got all the quirks of the Wii and desktop Flash Player’s “noscale” feature (on Android there is a workaround that solves this, not implemented in Frash yet).

    I just like to point that out, because some users are judging the viability of Flash on iOS/iPhone/iPad based on this hack (which is current at version 0.02), which is beyond silly.

    For anyone interested, I followed these instructions to install it on my iPhone. Note: this uses SSH and dpkg to install. If you don’t know how to reverse that, you may want to find an apt repo and use Cydia to grab this, so you can uninstall Frash when you are done playing, as it can be quite unstable.

    Adobe, Commentary, Flash

    Actionscript 3.0, Flash, iPhone

  • Including Page Templates from a WordPress Plugin

    Aug 10th 2010

    By: Ken

    No comments

    Recently, It occurred to me while writing a plugin dealing with custom post types and taxonomies for WordPress that it’d be nice to have some custom templates to go along with it. I seemed onerous to ask the the user to add template tags to their theme to be able to display a better page then what WordPress displays by default. So I set out to make the plugin include the template pages from the plugin directory itself. The code below is derived directly from the WordPress source code, which means it’s GPL, so feel free to use it in your GPL licensed projects.

    So the first thing I needed to figured out was what functions needed to be filtered to let me add the plugin directory to the locations that WordPress checks for. I eventually found the appropriate ones by reading the source code and asking in the #wordpress IRC chat (not #wordpress-dev, that’d be the wrong chat to ask this kind of question). “get_single_template()” and “get_taxonomy_template()” are the functions of interest and they in turn call “locate_template()” which is the function we need to rewrite.

    function locate_plugin_template($template_names, $load = false, $require_once = true )
    {
        if ( !is_array($template_names) )
            return '';
       
        $located = '';
       
        $this_plugin_dir = WP_PLUGIN_DIR.'/'.str_replace( basename( __FILE__), "", plugin_basename(__FILE__) );
       
        foreach ( $template_names as $template_name ) {
            if ( !$template_name )
                continue;
            if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
                $located = STYLESHEETPATH . '/' . $template_name;
                break;
            } else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
                $located = TEMPLATEPATH . '/' . $template_name;
                break;
            } else if ( file_exists( $this_plugin_dir .  $template_name) ) {
                $located =  $this_plugin_dir . $template_name;
                break;
            }
        }
       
        if ( $load && '' != $located )
            load_template( $located, $require_once );
       
        return $located;
    }

    (reference: ‘function locate_template‘)

    The “locate_plugin_template()” function is a direct copy of “locate_template” function but I added the $this_plugin_dir variable (using code I found on the wordpress.org forums) and added a 3rd check to the foreach loop. (Some of the code here can be removed, for example the $load check with the load_template() call, as our code won’t be invoking it but I left it to better reflect the source.)

    Next we have to filter the appropriate functions to call our new function.

    add_filter( 'taxonomy_template', 'get_custom_taxonomy_template' );
    add_filter( 'single_template', 'get_custom_single_template' );

    There’s not much in the original functions that need to be changed:

    function get_custom_taxonomy_template($template)
    {
        // Twenty Ten adds a 'pretty' link at the end of the excerpt. We don't need it for the taxonomy.
            remove_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
        remove_filter( 'get_the_excerpt', 'twentyten_auto_excerpt_more' );
       
        $taxonomy = get_query_var('taxonomy');
       
        if ( 'custom_taxonomy_name' == $taxonomy ) {
            $term = get_query_var('term');
       
            $templates = array();
            if ( $taxonomy && $term )
                    $templates[] = "taxonomy-$taxonomy-$term.php";
            if ( $taxonomy )
                    $templates[] = "taxonomy-$taxonomy.php";
       
            $templates[] = "taxonomy.php";
            $template = locate_plugin_template($templates);
        }
        // return apply_filters('taxonomy_template', $template);
        return $template;
    }

    (reference ‘function get_taxonomy_template‘)

    There’s some bonus remove_filter calls at the beginning and ‘locate_template’ is replace by ‘locate_plugin_template’. The only other thing is that we simply return the $template variable instead of using ‘apply_filters’ (I got errors when trying to apply the filter while running the filter filtering the filter :-/). There is also a check to see if we are working with our own taxonomy: The code in the if statement doesn’t really need to run again unless it’s one of our taxonomies, else it’ll just return the original $template.

    The single template function filter is much the same:

    function get_custom_single_template($template)
    {
        global $wp_query;
        $object = $wp_query->get_queried_object();
       
        if ( 'custom_post_type_name' == $object->post_type ) {
            $templates = array('single-' . $object->post_type . '.php', 'single.php');
            $template = locate_plugin_template($templates);
        }
        // return apply_filters('single_template', $template);
        return $template;
    }

    (reference ‘function get_single_template‘)

    Now, this isn’t a perfect solution. For example, themes have much varying structures, so building a template that’s compatible with Twenty Ten wouldn’t necessarily be compatible with any other theme. If the theme isn’t compatible, it could be bad since you’ve interrupted the fallback that the theme provides in favor of yours. You should probably include a check to see if the current theme is the theme you are targeting. I suggest you use this code in a plugin that is basically a companion plugin for your own theme or framework. Additionally, you could offer template tag functions, shortcodes, and widgets as a more robust solution.

    Uncategorized, Wordpress Plugins

    Custom Post Types, Plugin Theme Templates, WordPress Taxonomies

  • The Bunny (Video) Explodes. Explodes!

    Jun 29th 2010

    By: Kevin Newman

    1 comment

    I wanted to see how far I could push that exploding Actionscript 3.0 code – see if Flash could handle updating each animating pixel every frame, while playing a video, then blurring it. Sure enough, it can! It did take further optimization from the version I posted the other day – including swapping copyPixels with getPixel/setPixel, and removing an anonymous function call (wow that was expensive!). Here it is:

    Note: This’ll probably run like slush on the debug player (judging by the performance in Flash authoring).

    Fun & Games

    Actionscript, Flash, GFX

  • The Pixels Explode. Explode!

    Jun 23rd 2010

    By: Kevin Newman

    No comments

    Update: I posted a follow up an exploding video!

    Well I guess technically the pixels don’t explode as much as the DisplayObject explodes into pixels! I recently needed an effect that would make a bitmap image look sparkley, so I did some goggling, and game across a Firefly particle effect on a blog post belonging to Erik Hallander (at least I think so, the blog has been down for months, so I can’t double check). This pretty impressive effect looks like the following example (I hope reposting it here is not a problem).

    Note: This is a modified version of the original adding the Stats.as box, and autolooping – and removes the actual firefly affect (I didn’t need that part for my purposes).

    Very nice start! I don’t get an FPS problem – on my computer the example above rocks 62/60 fps (25% CPU on my Core 2 Duo)! So FPS was not the big problem. This example uses over ~19-23MB of RAM (with a lot of fluctuation)! And that is with 2×2 pixels, it goes up higher with 1×1 pixels. Additionally, this example already has an optimization in it to skip over empty (black) pixels in the DisplayObject it works on – which leads to a significant RAM savings.

    Using the display list this way – and two filters per DisplayObject – it began causing the player to kick up a lot of invalid BitmapData/null reference errors (which I’m guessing is what happens when you run out of memory, since many many checks confirmed that the BitmapData was not invalid) – especially when I tried to make it work on 1×1 pixels to animate every pixel.

    So the first thing I did was to clean up some of the obvious stuff, to bring down the memory usage – in the original blog post, Erik noted that this was unoptimized code, so I knew what I was getting into. I did things like remove the extra nested DisplayObjects (each pixel was a subclasses Sprite instance, with a BitmapData added to it), and cleaned up extra variables that were laying around, moved a lot of things inline, reused as many variables as I could, cutting down on object instantiation – and followed a lot of the other tips in a conveniently timed ByteArray post. Doing that really helped – I cut the memory use about in half – and on the initial animation (a black and white logo) the affect seemed worked quite well. But it didn’t scale well – larger images simply wouldn’t work.

    I still wanted to use this affect, and I’ve seen many thousands of pixels being animated before – so I knew it was possible. So a radical departure. I’ve been reading about drawing directly to Bitmaps for quite a while, and that was going to be my path. So more optimizations – removed the display list code completely, changed the Pixel class to a simply property class (where are the enums?!), and used that to store information about where in the original source to look for the pixel data as well as other relevant animation data (most of which was already done for me – thanks!) for each pixel block. I also removed dependence on TweenMax – which is what the original uses for all the animations – and used the easing equations directly, within an ENTER_FRAME event.

    The result is a RAM reduction by 25% and a steadier memory usage, coming in at ~5MB with 4x as many pixels (and roughly the same amount of CPU). The changes utilize copyPixels and a linked list, with an accumulation buffer like effect – for a total of 3 bitmaps (the original, which is rendered from the DisplayObject and stored, the scattered one the pixels get copied into, and the copy of that that gets blurred by the BlurFilter – a hidden memory cost illuminated by Thibault Imbert).

    There are further optimizations that can be used as well (and should really be used for full image per pixel animations) – such as writing to an opaque BitmapData, rather than one with Alpha, and reducing the BlurFilter quality – getting a better handle on type marshaling, etc. It might also be faster to store the RGB value of each pixel, and draw those directly instead of using copyPixels, but I haven’t tried that yet.

    I got so much help from the Flash community on this, that it would be irresponsible not to share this back, so feel free to check out the source.

    Some Notes:

    The memory usage applies to both swfs on this page – so you can’t see the memory usage difference in these examples. I quoted the standalone Flash Player in this post.

    Also, I’m getting some kind of performance problem in plugin browsers (everything except IE) on Windows, and on every browser on mac but Firefox which is limiting both of these to around 30FPS. I have no idea what’s causing it.

    On the code quality – the code isn’t all that messy IMHO, but it is not well documented, and a lot of the configuration hooks I left in are not really being utilized in a decent API – I may refactor at some point to clean that up. There is also a limitation of the skip pixel check that will keep it from working well for greater than 1×1 pixel size (since it only checks the top left corner of the size rect).

    Enjoy!

    Tips & Tricks

    Actionscript, Flash, GFX

  • I’m totally signing up for Final Fantasy XIV beta

    Apr 7th 2010

    By: Kevin Newman

    No comments

    I’m totally signing up for Final Fantasy XIV. It seems to say I need a fan site. Does this count? :-D BTW, Final Fantasy XIII is wicked cool.

    Fun & Games

  • Update Theme

    Mar 11th 2010

    By: Kevin Newman

    1 comment

    Just a quick note. The old theme (iNove) was creating extra history entries for some reason when you came to unfocus.com. I have no idea why, but that theme is now history. This new theme (iCandy 1.4 by Nischal Maniar) fixes the problem and looks nicer anyway. :-)

    WordPress

  • 3D Gaming is Awesome!

    Jan 7th 2010

    By: Kevin Newman

    3 comments

    After I watched Avatar in 3D, I became curious about PC gaming in 3D. So I did some research on the subject. There are three kinds of home 3D solutions on the market today (and a few more in theaters); active shutter glasses, and polarized LCD monitors are the two full color technologies. Each have their advantages and drawbacks, which I may blog about in more detail in the future (if you want more info, I suggest reading the xbit labs reviews of the various technologies).

    I wanted to try to find a solution that did not require the layout of hundreds of dollars just to test out how well (or not) the 3D of these systems actually worked, so I wondered if there was a way to test these out, with minimal cost – sure enough, both available 3D graphics drivers support anaglyph mode to preview the tech. The third option anaglyph – you may remember this trick from super bowl half time commercials, and cereal box addins. First up is nVidia’s solution is slightly

    For nVidia 3D Vision Discover, you’ll need to make sure you have a beefy enough nVidia video card – ATi users are out of luck. As luck would have it, I have a supported card, an 8800GT (the lowest end card supported!). To turn it on, follow the instructions on nVidia’s 3D Vision Setup page. Make sure you have both the correct version of display drivers, and the 3D Vision drivers.

    If you don’t have the correct glasses colors (as I didn’t – I used magenta/green glasses backwards from Monster’s Vs. Aliens DVD – eventually I replaced one lense with a red one from a children’s spy kit I got from Friendly’s) it may be a little tricky to enable the affect in nVidida’s drivers if you don’t have the correct colored glasses, since they don’t actually let you turn it on without testing you first. Just guess at what the answers are and press back if you get it wrong – there are not that many combinations of answers, and you’ll eventually get it right.  Once you do that, you’ll have an option to turn this all on in the Stereoscopic 3D section of your NVIDIA Control Panel (right click desktop to get there), or use the CTRL + T shortcut to turn it on.

    The nVidia drivers work amazingly well on Valve Source engine based games – like Left 4 Dead and Team Fortress 2. In some parts of Left 4 Dead 2, such as the sugar cane fields on the return trip level of Heavy Rain, it may even give you a bit of an advantage, since you can see the depth of the plants – it’s much easier to see where you are going. They did less well in older UT3 engine based games, like Bioshock, where you can see noticeable gaps around some objects where the fog effects just don’t line up correctly in both eyes (it’s shifted to the right or left, for each eye respectively), and certain shadows are lost. Newer UT3 games, like Batman .. Arkham Asylum, which claims out of the box support for nVidia 3D Vision, and Avatar, which has 3D support that must be enabled in game, look phenomenal. (For Avatar you need to set nVidia stereoscopic view on in the driver first and then the game to get it to work). Other Ubisoft games like Assassin’s Creed and Prince of Persia also look great.

    Another option is to use the iZ3D 3D drivers – which work with any 3D card, including ATi Radeon. iZ3D sells a line of specialized monitors that actually polarize two images (similar to how many 3D movie screens work), and use passive glasses to filter out each image from the correct eye, thus presenting two different images to each eye. You don’t need a 3D monitor to use the drivers though, as they have a free anaglyph mode built in (among other modes). These drivers seem to incur a greater performance hit than the nVidia glasses – but despite many posts (seemingly little more than assumptions) I’ve found on forums and blog posts, I actually found them more compatible than nVidia’s drivers, especially in Bioshock, which is downright amazing in 3D (despite missing many shadows). These drivers don’t start out with the modest 3D settings as the nVidia’s more out of the box settings, but once you tweak these (there are more options for tweaking, and each game starts out with a tweaking guide overlay to help you out), you should be up and running.

    The best part of the iZ3D drivers is that you can actually change the color settings of the anaglyph mode (apparently you used to be able to do that for nVidia, but they removed that ability). This is fantastic, because it means you can get all the colors, with less ghosting that you’d miss if you don’t use the correct glasses with the nVidia drivers. Most anaglyphs actually separate 3 colors, not just two – one channel (red) to one eye and the other two channels (green + blue = cyan) to the other. In my case, I am using green and magenta (blue + red). The fact that blue is being split to the wrong eye is why you get ghosting with the nvidia drivers and the Monsters Vs. Aliens (or Coraline) glasses.

    Here’s a quick guide to change the anaglyph colors for iZ3D drivers. First find the correct config file – for me (Windows 7) it was:

    C:UsersAll UsersiZ3D Driver

    I can’t confirm these two, but they helped me find the location in Windows 7 - from the iZ3D forums:

    XP: “Documents and SettingsAll UsersApplication DataiZ3D DriverLanguage”

    Vista: “ProgramDataiZ3D DriverLanguage”

    Once you have opened the Config.xml file in one of those folders, you can edit the following items to make it green/magenta:

    <anaglyphoutput>
    <customleftmatrix m00="0" m01="0" m02="0"
    m10="0" m11="1" m12="0"
    m20="0" m21="0" m22="0"/>
    <customrightmatrix m00="1" m01="0" m02="0"
    m10="0" m11="0" m12="0"
    m20="0" m21="0" m22="1"/>
    </anaglyphoutput>

    In case you are interested, here is a quick key for what these values actually mean – or at least 3 of them – it’s matrix math which is hard ;-) :

    m00=”R” m01=”0″ m02=”0″
    m10=”0″ m11=”G” m12=”0″
    m20=”0″ m21=”0″ m22=”B“

    There are bugs and drawbacks with each solution – most games were not made with 3D in mind, so this can be a bit of a hack. Some games are missing shadows or have misaligned affects (like Bioshock), and I couldn’t get OpenGL games to work at all with either driver (despite settings for it in iZ3D). Other games seem to perform flawlessly (like Left 4 Dead, Batman or Avatar). Another big drawback of these systems is the cost – full color 3D setups can be pretty expensive $300-$400 for the monitor, and another $200 for the glasses (and an additional $150 for each pair you want to add for group movie watching). The iZ3D solution (and Zalman makes a compatible monitor) are getting cheaper, but are still quite pricey at around $300 for the monitor and cheaper passive glasses (with no other special requirements/costs, except some kind of reasonably strong video card).

    The affect is pretty convincing for me though, and since I already have a nice 120Hz monitor, and a decent enough graphics card, I’ll be adding nVidia Shutter glasses to my birthday list. :-)

    Fun & Games, Tips & Tricks

    3d, 3d vision, iZ3D, nVidia, Video Games

  • Stop All Child MovieClips in Flash with Actionscript 3.0

    Dec 7th 2009

    By: Kevin Newman

    4 comments

    While trying to come up with a way to get two different movies loaded at the same time, to play at different frame rates, I came up with a method to recursively stop all child movies of an as3 MovieClip. I didn’t end up using it, but I thought it might be useful for someone, so here it is:

    import flash.display.DisplayObjectContainer;
    import flash.display.MovieClip;

    function stopAll(content:DisplayObjectContainer):void
    {
        if (content is MovieClip)
            (content as MovieClip).stop();
       
        if (content.numChildren)
        {
            var child:DisplayObjectContainer;
            for (var i:int, n:int = content.numChildren; i < n; ++i)
            {
                if (content.getChildAt(i) is DisplayObjectContainer)
                {
                    child = content.getChildAt(i) as DisplayObjectContainer;
                   
                    if (child.numChildren)
                        stopAll(child);
                    else if (child is MovieClip)
                        (child as MovieClip).stop();
                }
            }
        }
    }

    The plan was to use that to stop playing movies, every other frame, and restart them on the alternative frames, but there is apparently no way to tell if a MovieClip is currently playing or not, to know which ones to restart.

    I did end up hacking Tweener to add support for a Timer based update method. That way I can adjust the stage FPS to match the older timeline content (at 12fps) and have my Tweener based interactions work at a silky smooth 60 FPS.

    I’ll post more on that later.

    Tips & Tricks

    Actionscript 3.0, as3, Flash

  • Trace Actionscript in a Browser

    Nov 10th 2009

    By: Kevin Newman

    1 comment

    Testing Flash apps in a browser can be cumbersome, but it needs to be done for some browser only functionality, such as deep linking and back button functionality – as well as checking other things that might change once you are out of the Flash “test movie” sandbox, and into the browser – things like file path issues. The convenient trace window is not available in the browser, but there are alternatives.

    Flash Content Debugger and “Allow Debugging”

    While it’s not essential for tracing, the first thing you should do, is make sure you are running a content debugger version of the Flash Player. You need both the Active X version for IE, and the Plugin version for everyone else (Firefox, Chrome, Opera, Safari, etc.). Both plugin types have their quirks with regards to JavaScript (and other platform differences), and really require specific testing in each, so make sure you grab both versions. Once you have those, you’ll be able to see uncaught exceptions in AS3 swfs right in the browser. You can even use the Flash Content Debugger from the browser, though I haven’t found a smooth way to do that yet. For many thing, a simple trace is all you need.

    A quick tip that took me a while to notice – the “Allow Debugging” checkbox in Flash’s Publishing Settings dialog, actually causes the Flash compiler to add debugging symbols to the compiled swf, symbols that give you useful information like the actual line number of an error, in addition to the stack trace. The “Allow Debugging” verbiage, is most definately not enough to communicate that difference – I thought it was more of a locking mechanism. Hopefully you haven’t stumbled around for too long with that, like I did when I first switched to AS3..

    Tracing

    The easiest way to trace from Flash is to use Firefox with the FlashTracer extension from sephiroth.it. With FlashTracer, you can use the regular old built in trace method without any extra work on your part. Make sure you download the one from sephiroth.it (2.3.1), since the one from addons.mozilla.org (2.2.0) doesn’t work in Firefox 3.5. For many things that’ll be all you need. But sometimes, you’ll need information in other browsers, and will want to trace to the browsers JavaScript console. In addition to simple trace messages, you can also call a number of other methods that will out put your messages in different formats and colors, making it easier to spot what you might be looking for.

    Check out the Firebug Console API for more information.

    Enabling the JavaScript console

    If you are already familiar with the various JavaScript consoles, please feel free to skip to this part.

    Each of the major browser vendors has a JavaScript console implementation, and thankfully, the API is mostly compatible with one another. The GUI is a bit different in each (except Safari and Chrome – both are based on WebKit), so here’s a quick rundown on how to access the JavaScript console for each:

    Firefox

    You should get to know and love Firebug. It is currently the best developer tool available on any platform – so good the others all copied it, even if they won’t admit it (*cough*Microsoft*cough*). Firefox is oddly enough, the only browser that doesn’t ship with a JavaScript console, and requires you to install an extension. While running Firefox, you can find and install that extension at www.getfirebug.com.

    Once Firebug is installed, you will notice a little bug (insect) icon in the bottom right hand corner of the browser window, on the status bar. Click that to open and enable Firebug for the page you are currently viewing. Firebug will only turn itself on, on a site by site basis, and only after you click on that bug icon. Once it has popped open, you will see some tabs, with many goodies like the fabulous “Net” tab (very useful to make sure swfs are being loaded in the browser), and the “HTML” tab, which contains a live, nested version of your html code, which can be edited in real time - it’s hard to describe how much better life is in the Web Development since Firebug. Anyway, the tab we are interested in, is the “Console” tab – click that. On the actual tab, there will be a little down arrow – click that to open a menu, then click “Enabled” to turn the console on (the onscreen instructions are a little odd, their picture is of the “Script” tab – the arrow you want is on the “Console” tab, not the “Script” tab).

    Internet Explorer

    You’ll need to upgrade to IE8. If you are stuck on IE6, I’m sorry for you. You will not be able to easily debug Flash apps – that browser is simply difficult to work with, and you’ll probably need to output to either a text field within flash, or to a div element using JavaScript. Go and download IE8 now, if you don’t already have it. Once you have IE8 installed, you can find the “Developer Tools” under “Tools” menu. You can also press F12 to bring them up. The dev tools in IE8 are docked to the main window, along the bottom of the screen, very much like Firebug. You will notice 4 tabs in a blue bar, below a row of link buttons – click the “Script” tab to open the script tools. You will have two panes at that point – in the left is a debugger, and in the right pane, you should see a button for the Console.

    Safari

    You’ll need to enable the developer tool first, before you can turn on the JavaScript console. Click on the gears icon on the main toolbar, and choose “Preferences”, then click the “Advanced” tab (the one with the gear icon). On that page, there is a checkbox labeled “Show develop menu in menu bar”. Check that, and close the window. Now under the Page icon menu, you’ll see a sub menu called “Develop”. In that sub-menu, choose “Show Error Console”. This will open the “Web Inspector” window. You can dock the window along the bottom of the main window by clicking the dock button in the bottom left of the Web Inspector window. To the right of that button, there is another button with a greater than sign, and three lines. That button will toggle the JavaScript console.

    Chrome

    Click the page drop down icon on the right of the main toolbar to open the main menu, then go to Developer, then JavaScript console. This will open the “Developer Tools” window, which contains the many things, including the JavaScript console. You can dock window inside of the main window by pressing the dock button on the bottom left of the popup window. To the right of that button, there is another button with a greater than sign, and three lines. That button will toggle the JavaScript console for Chrome.

    Opera

    Under the Tools menu, choose the “Advanced” submenu, then choose “Developer Tools”. This will open a panel along the bottom of the main window (sensing a trend here?). In that panel, click on the “Error Console” tab. If you’d like to only see JavaScript errors, you can click the bottom JavaScirpt tab (under the white output area of the Error Console). Note: Their is an alternative “Error Console” under Tools -> Advanced -> Error Console. Try them both, and use the one you prefer.

    Tracing to the Console

    Once you have familiarized yourself with the JavaScript console, you can start to trace to it. The JavaScript command is simple enough:

    window.console.log("your message").

    From Actionscript you’ll need something like this:

    import flash.external.ExternalInterface;
    ExternalInterface.call("console.log", "your message");

    Since we are using ExternalInterface, you’ll need to make sure you have the allowScriptAccess object param, or embed attribute set to an appropriate value – either “always” or “sameDomain” (sameDomain is the default, so as long as you have your html/javascript/swf all on the same domain, you should be good to go).

    You should now be able to trace (or something like it) in the browser. Next time I’ll cover some more advanced uses, as well as some more specific snafus with deep linking and browser back button functionality.

    History Keeper, Tips & Tricks

    Actionscript, deep linking, HistoryKeeper, Javascript

    • 1
    • 2
    • 3
    • 4
    • >
  • Tags

    3d 3d vision Actionscript Actionscript 3.0 Ajax as3 asp.net charset encoding Custom Post Types deep linking EOT Flash Flash Player 10 FlashPlayerInfo forum GFX HistoryKeeper IE6 IIS 7 Internet Explorer iPhone iPhone WordPress iZ3D Javascript jQuery Mac OS X Microsoft Mosso MouseWheel nVidia OpenType Plugin Theme Templates SVG SwfHTML Tetris Twitter user ip address Video Games web.config webfonts wordpress plugin WordPress Taxonomies
  • Archives

    • August 2010
    • June 2010
    • April 2010
    • March 2010
    • January 2010
    • December 2009
    • November 2009
    • September 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • May 2008
    • September 2007
    • August 2007
    • July 2007
    • May 2007
    • April 2007
  • Categories

    • Adobe
    • Commentary
    • Creative Suite 3 (CS3)
    • Flash
    • Fun & Games
    • History Keeper
    • Object Patent Magic
    • Permalinks
    • Server Technology
    • SwfHTML
    • Tips & Tricks
    • Uncategorized
    • Web Fonts
    • Widgets
    • WordPress
    • Wordpress Plugins
  • Blogroll

    • adcSTUDIO Blog
    • Adobe Blogs
    • BIT-101 Blog
    • ByteArray.org
    • Dean Edwards
    • Flash Develop
    • Game HaXe
    • Kaicho Emeric Arus
    • majmar
    • Mike Chambers
    • Soulwire
    • The Flash Blog
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org

© Copyright unFocus Projects. All rights reserved.

Theme designed by Nischal Maniar