Archive for category ActionScript

MovieClipLoader and Loader quirks with cached images

On a recent project I ran into a quirk/unexpected behavior when using MovieClipLoader in AS2 or Loader in AS3 to load an image. When using the classes, you have the ability to listen for a progress event, which you typically use to show an progress bar. If an image is cached, one would think the progress event would not fire since it should be fired on bytes loaded not bytes read, correct? Wrong. If an image is cached the progress event still fires, even to the tune of 9 times.

I would have not guessed this to be the case, and had even willingly drank the koolaid into believing all my load worries had been solved by these glorious classes. Instead I had to back peddle and use enterFrame checks for progress events and only use the onLoadInit/complete event from the class. All of this I found because a designer was getting upset because the progress bar kept showing up on loaded images. That’s right folks, the mantra here is “designers are your friends”.

5 Comments


Project: Adult Swim Interactive Video

The Project

http://www.adultswim.com/ivc/trinity/index.html

Ghetto Players

Last Friday Adult Swim stepped out of what I consider the “ghetto video” player realm and into something a little more interactive and fit for the web. You see, I believe anyone can throw up a single video or collection of videos on the web, hence the meaning of “ghetto”. There are ways to make the experience better, more fluid, profitable, easier with tools, etc, but at the core you are just ripping a video and throwing it on a site. Don’t get me wrong, this is great and I’m happy for the shift to this medium. I love and want content to continue to be put up in this way. I personally push for it and try to make it happen. However, it ignores the strength of the medium beyond just supplying on demand viewing.

Interactive Video

Enter the concept of interactive video. What does this mean? Well a lot of people are doing variant things with video now, so it could mean different things. Some use video as a highlight element and not the driver of the experience. In my case, video is the content, it tells the story. From a content creator’s perspective you have to go beyond providing just a video view. You have to provide the ability to dig into that story. That experience then becomes a driver beyond just the video’s view. I’ve heard many discussions about how video interlaced with related content should tell a story and implementations that attempt it, but I’ve always walked away feeling empty. I’ve always wanted to put my own stamp on it.

The Struggle

Funny thing is, I’ve had the current AS project idea, design, and implementation in my head for over 3 years (aka Flash6), but never had the approval to do it. This was due to having to convince people that video on the web is a viable thing and that it doesn’t take away from their viewership, but only adds to it.I have had a strategy that I employed this year to overcome this. By slowly introducing video to some companies and helping them understand it, I first used this to get their video out there, then used that to change their technologies, and I’m now using it to open doors for my ideas. I would be lying if I didn’t say that without YouTube scaring the pants off them, they probably would have held tight to their beliefs of protecting and not releasing their content. To that all I can say is, thanks YouTube.

Project Concept

Anyways, enough talk right? What is the concept? Simply, this particular project seeks to take DVD style experiences to the web with a twist. Taking a video (show) and the related content (images, audio, video, or written articles) that would be associated with a DVD, I seeked to merge both into a linear narrative. All of the related content is time coded to the video where the video serves as the linear driver/story teller. As you watch the content, you are given subtle alerts for the associated content, which you can then use to jump to and view. In addition, if you wish to browse those content elements, you can do so, and jump directly to them via a menu. The video is then synced to the content. The point is that you are always looking at content in context. On top of that, your context is never lost. You are never driven completely away from the story and have to dive back to it. The story always exists right there in visual sight. As you move through the application you can shift your focus to what you want to pay attention to and the UI will visually shift around to let you know where you are going. The application is completely dynamic so I can apply it to any linear video that I want.

Thanks and the Future

For this project, I can’t thank my friend Chris enough for letting me run with the idea and providing me with such great input. He started the game, I showed him the ball, and everyone involved rolled it. It has been well received, with my favorite comment being “You just created the Flux capacitor”, to which AS turned to me and said “If you can build the Flux capacitor, I think I can get it in the budget for next year”. With the Flux capacitor in hand, I’d probably end up just going and betting on things like Biff (which could go sour), so for now I’ll stick to moving my vision forward.With all that said, this is a first pass and isn’t fully indicative of everything I have envisioned. To note that, I did the actual development super quick just to have it out there, have people playing with it, and getting feedback. As I’ve said before, I plan to change entertainment as we know it. Yes a big statement, but I have a big vision. The doors are now opening. This is a small piece to a big puzzle I have. As they always say, you haven’t seen anything yet ;) .For those who find my ramblings interesting, I encourage you to come by and check out my presentation at the April FITC conference in Toronto, Canada this year . This project is just one of many things that I’m planning to incorporate into it.

4 Comments


Project: Adult Swim Video Application

Adult Swim Fix is the proper name for the Adult Swim video application and it is not new. However, as of last week it does have a new video format. It has been switched to the most popular format on the web, Flash.Anyone who is familiar with the application can see that it looks exactly the same. Well, point blank, that is because it is. You see when I wrote it (as well as the Cartoon Video and Toonami players which are still WM), I wrote the player to be format agnostic. When they play video, they have no clue of what the video is, just that it is video. The players are set up where their playback can be changed in a one line reference switch to: Windows Media Streaming, Windows Media Progressive, Quicktime Progressive, Flash Streaming, or Flash Progressive. The rest of the application logic remains the same including the ad serving, tracking, service request, etc.Why did I do this? I did it so that the application could be adapted for variant uses, and more importantly, I did it to make choice a very simple option. I first had to convince the machine that video on the web is a good idea and work within their comfort zone. In the same breathe, I wanted to make it easy enough for them to move from their comfort zone to an area where they can form advances. It was all strategic and done in the best interests of the companies using the player.All said, the Fix Flash conversion was step A. Right now I consider it a “ghetto player” comparable to the likes of those like Brightcove. Not that it, or they are not good, but the focus in the wrong place and not on the users. I intend to do better, a lot better, I just needed to open the doors first ;) .If anyone is interested, I’ll be briefly touching on Adult Swim Fix, SuperDeluxe, and other video projects in my presentation at FITC in April.

3 Comments


NetStream Bug in Mac Flash Player 9.0.28

In the Mac version of Flash Player 9.0.28, the NetStream event NetStream.Play.Stop does not fire on clips that are longer in length. I did not narrow it down to what length it deteriorated at, but generally the test clips were around 3 to 4 minutes in length. The bug tests were consistent, and could not be replicated in previous versions of the Mac player or any PC player. Just to verify it wasn’t the encoder, the first tests were done encoding with AnyStream, and later attempts were made with encoders such as the Adobe Standalone, which failed as well.

Is this a serious bug, it depends on how you define serious. Most developers use this event to determine completion of a video, even the Adobe FLVPlayback component uses it and fails. In players that display post video messaging, run post rolls, or cycle playlists and rely on this method, these action items simply won’t display or run.

You can attempt workarounds with NetStream.Buffer.Empty and the duration from MetaData. In this specific case, you attempt to catch the Empty event firing at the end of a clip and use that as your completion event. Even if it doesn’t fire in certain race conditions, I recommend at least putting something like this in as backup measures.

All in all, it’s not good when there are inconsistencies in the player. My hope is that it gets addressed soon.

6 Comments


Project: Adult Swim AssyGrams

Right before Christmas 06 I got to create a quick and “interesting” e-card application for Adult Swim’s show Assy McGee. The app allows you to choose a type of recipient and a greeting, it then blends the choices together with related props, clothes, and message pieces into a single e-card for your loved ones to enjoy. The only external piece other than the Flash was a backend service that sent an email containing the html page the SWF was embeded on with query params that reflected a user’s selections. When your unexpecting recipient visited the url, the SWF was fed the params via FlashVars and they were fed an Assy greeting full of wisdom.

Now I have to point out that for those who aren’t comfortable with things that contain a lewd sense of humor to the tune of the South Park genre, the app is definitely not for you. If it’s any forewarning, the character the e-card is based on is a pair of legs and a backside. So with that said, for those who think they may get a good laugh, send your friends some Assy!.

No Comments


WMode causes Flash fullscreen mode not to work

Flash’s new fullscreen mode does not work when you set the wmode param in the embed code to transparent or opaque. Fullscreen mode will only work if wmode is not set by the embed. I saw the issue come up on a project, so I thought I’d point it out for others since it is not outlined in Adobe’s documentation.

7 Comments


PS3 and WII Flash capabilities dump

I ran a simple Flash capabilities dump script on both the Nintendo WII and the PS3. I then did a diff of the two outputs against each other and against a PC.
Below are the results:

WII/PS3 to PC Differences

  • PrintJob methods missing on the WII and PS3
  • WII to PS3 Differences

  • PS3 has names property for Camera and Microphone, WII does not
  • WII/PS3 Version Strings

    PS3 7,0,70,0
    WII 7,0,70,0

    WII/PS3 Flash Capabilities Output
    Read the rest of this entry »

    6 Comments


    Making SWFs Aware of Browser Sessions

    In my previous post about the Nascar slideshow, I mentioned how the module had variant behavior based on whether you had seen it or not during the current browser session. Though I briefly described the process to make this happen, I've decided to share example code of how this is done.

    What is a Browser Session?
    First off, when I speak of a browser session it is important to know exactly what I mean. Loosely defined, a browser session is the time duration from the point at which a session is started (while the browser is open) until all instances of that browser are closed. A session typically can be started by setting the session on entrance to a site, at login to a site, or at some other predetermined time.

    Does a SWF know about a Browser Session?
    A SWF has no internal way of knowing whether it was being visited another time by navigating in the same browser (page forward, page back, page refresh, etc), or whether it is the initial visit by a fresh browser instance. This lack of knowing presents an issue of being able to act on a temporary browser session. Essentially, the SWF doesn't know when or how it was opened. For example, setting a Shared Object and reading it, you don't have a way to clear it when a browser closes (without help) or know whether it was set before you restarted your computer. Thus it knows nothing of its opening relationship, only that it was opened. Instead, the information has to be given to the SWF by the browser, since the browser is aware of it.

    Making the SWF aware of the Browser Session
    In order to do make the SWF aware of the session, you can create a browser based session cookie (a temporary cookie that is removed when the browser is closed). You can then pass the existance of this cookie into the SWF as a FlashVar with a Boolean value. If it exists you know that you are in a current session, if not the SWF is being opened for the first time in this particular browser instance. The timing at which you do this is important, as you want to write out the SWF first, then create the session cookie so it is available for subsequent embeds .

    EXAMPLE CODE:
    Using SWFObject, adding the session information to a swf is pretty easy to do:

    JavaScript:
    1. var so = new SWFObject("TestBrowserSession.swf", "session" , 50, 50, 6, "#FFFFFF");
    2. // session flag to swf
    3. so.addVariable("FLASHVARS_hasSession", (document.cookie.indexOf("session=exists")!=-1) ? "true" : "false");
    4. so.write("sessionDiv");
    5. // set session
    6. document.cookie = "session=exists;";

    A working example can be seen here.

    No Comments


    MouseWheelManager Class

    OVERVIEW
    Flash allows you to capture the events from a mouse wheel. The event fires with two params (delta:Number, scrollTarget:MovieClip). In most cases, you only want one thing to respond to this event. For example, if you have two listboxes with scrollbars, you only want the one that your mouse is over to respond to the event. You could accomplish this by having each element listen for the wheel event and do it's own check to determine whether it should handle it or not. However, if you did this everytime the event fired, all the handler checks would have to run. In the case of having 50 elements listening, that would be 50 if checks, which is inefficient.

    COMPONENT TECHNIQUE
    If you dig into the Flash component classes, you will find they implement the check rather intelligently. In mx.core.ScrollView, a single listener is implemented. The handler evaluates the second param (scrollTarget) to determine which component should handle the event. It does this by starting at the MovieClip target passed in and working up the parent chain until it finds a MovieClip that is a ScrollView instance. Once it finds that instance, it makes the instance dispatch a scroll event.

    SIMPLE SOLUTION
    I created a MouseWheelManager class that has the same intelligence as the ScrollView, but is a lot simpler to use . To utilize it with an Class or Object, instead of making that class subclass ScrollView (doesn't rely on additional classes), the class just has to have a onMouseWheel handler and register itself and associated MovieClip with the manager.

    /**
    * Dreamsocket
    *
    *  @author : Kenny Bunch
    *  @example:
    *
    *           import com.dreamsocket.managers.MouseWheelManager;
    *
    *            var o:Object = {};
    
    *            o.onMouseWheel = function(p_delta:Number, p_startingTarget:MovieClip):Void
    *           {
    *                  trace("works");
    *           }
    *
    *            MouseWheelManager.getInstance().register(foo_mc, o);
    */
    
    class com.dreamsocket.managers.MouseWheelManager
    {
            private static var k_instance:MouseWheelManager;
    
            private var m_targets:Object;
    
            private function MouseWheelManager()
            {
                    this.m_targets = {};
                    Mouse.addListener(this);
            }
    
            public static function getInstance():MouseWheelManager
            {
                    if(MouseWheelManager.k_instance == null)
                    {
                            MouseWheelManager.k_instance = new MouseWheelManager();
                    }
    
                    return MouseWheelManager.k_instance;
            }
    
            public function register(p_tgt:MovieClip, p_instance:Object):Void
            {
                    this.m_targets[p_tgt] = p_instance;
            }
    
            public function unregister(p_tgt:MovieClip):Void
            {
                    delete(this.m_targets[p_tgt]);
            }
    
            private function onMouseWheel(p_delta:Number, p_startingTarget:MovieClip) : Void
            {
                    var testTarget:MovieClip = p_startingTarget;
                    var target:MovieClip;
    
                    while(testTarget != null)
                    {
                            if (this.m_targets[testTarget] != null)
                            {       // target exists in list and is bottom of tree set as target and stop climbing parents
                                    target = testTarget;
                                    break;
                            }
                            //  child mc is not a target climb to parent and test
                            testTarget = testTarget._parent;
                    }
    
                    if (target != null)
                    {       // target found dispatch event
                            this.m_targets[testTarget].onMouseWheel(p_delta, p_startingTarget);
                    }
            }
    }
    

    5 Comments


    AS3: Visualizing Video

    In an attempt to start using AS3 and Flexbuilder, I created a simple module (based in part on Brendan Dawes "Cinema Redux" processing experiment), that visualizes a movie by taking snapshots of frames on a supplied sample rate. It uses those snapshots to create a visual mosaic image, which allows you to see the use of light, color, and transition throughout the movie.
    Read the rest of this entry »

    6 Comments