Infurating Bug with Flex SDK3 and Modules solved.

I was having some issues with a pureMVC app I've been building with the new release of Fabrication for pureMVC.  The issue was my module wasn't being loaded properly or didn't have a router.  So I decided to write a really simple flex project to test it outside of my bigger project.

I created a FlexApplication (that uses fabrication)


<?xml version="1.0" encoding="utf-8"?>
<fab:FlexApplication
    xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    xmlns:fab="org.puremvc.as3.multicore.utilities.fabrication.components.*">

   


    <mx:Script>
        <![CDATA[
            import com.bti.sandbox.FabricationTest.control.ShellStartupCommand;

            override public function getStartupCommand():Class
            {
                return ShellStartupCommand;
            }
        ]]>
    </mx:Script>

   


</fab:FlexApplication>

The statup command is super simple just for testing.



package com.bti.sandbox.FabricationTest.control
{
    import mx.events.ModuleEvent;
    import mx.modules.IModuleInfo;
    import mx.modules.ModuleManager;
    import mx.utils.ObjectUtil;

    import org.puremvc.as3.multicore.interfaces.INotification;
    import org.puremvc.as3.multicore.utilities.fabrication.components.FlexApplication;
    import org.puremvc.as3.multicore.utilities.fabrication.components.FlexModule;
    import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;

    public class ShellStartupCommand extends SimpleFabricationCommand
    {

  
       


        override public function execute(note:INotification):void
        {
            // lets test this thing by loading a module

            var module : IModuleInfo= ModuleManager.getModule("TestModule.swf");

            module.addEventListener( ModuleEvent.READY, moduleReadyListener);   
            module.addEventListener( ModuleEvent.ERROR, handleError);

            module.load();
        }

        public function moduleReadyListener( event : ModuleEvent) : void
        {

            var moduleInstance : FlexModule = event.module.factory.create() as FlexModule;

            trace("module instance is " + moduleInstance);
            moduleInstance.router = (this.fabFacade.getApplication() as FlexApplication).router;
            moduleInstance.initialize();
        }

        public function handleError( event : ModuleEvent) :void
        {
            trace("error " + ObjectUtil.toString( event));
        }

       
       


    }
}

the simple module I'm using for testing :


<?xml version="1.0" encoding="utf-8"?>
<FlexModule xmlns="org.puremvc.as3.multicore.utilities.fabrication.components.*" xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">
    <mx:Label text="I am the test module"/>

   
   


    <mx:Script>
        <![CDATA[
            import com.bti.sandbox.TestModule.control.TestModuleStartupCommand;

            override public function getStartupCommand():Class
            {
                return TestModuleStartupCommand;
            }

           


        ]]>
    </mx:Script>

</FlexModule>

</code>


And finally the startup command for the simple module

package com.bti.sandbox.TestModule.control
{
    import org.puremvc.as3.multicore.interfaces.INotification;
    import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;

    public class TestModuleStartupCommand extends SimpleFabricationCommand
    {
        override public function execute( note:INotification ):void
        {
            trace("TestModuleStartupCommand started!!!");
        }

       


    }
}

In testing the "moduleReadyListener" is never called, and the "handleError" is never called.  I tested the app with a Charles - http proxy in the browser and the module was being loaded, but the READY event was never being fired.

I was googling in frustration and found this note so I made a really small change to the applications startup command, I made the module variable a member of the class instead of local to the method and viola, it works.

package com.bti.sandbox.FabricationTest.control
{
    import mx.events.ModuleEvent;
    import mx.modules.IModuleInfo;
    import mx.modules.ModuleManager;
    import mx.utils.ObjectUtil;

    import org.puremvc.as3.multicore.interfaces.INotification;
    import org.puremvc.as3.multicore.utilities.fabrication.components.FlexApplication;
    import org.puremvc.as3.multicore.utilities.fabrication.components.FlexModule;
    import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;

    public class ShellStartupCommand extends SimpleFabricationCommand
    {

        private var module : IModuleInfo;

        override public function execute(note:INotification):void
        {
            // lets test this thing by loading a module

            module = ModuleManager.getModule("TestModule.swf");

            module.addEventListener( ModuleEvent.READY, moduleReadyListener);   
            module.addEventListener( ModuleEvent.ERROR, handleError);

            module.load();
        }

        public function moduleReadyListener( event : ModuleEvent) : void
        {

            var moduleInstance : FlexModule = event.module.factory.create() as FlexModule;

            trace("module instance is " + moduleInstance);
            moduleInstance.router = (this.fabFacade.getApplication() as FlexApplication).router;
            moduleInstance.initialize();
        }

        public function handleError( event : ModuleEvent) :void
        {
            trace("error " + ObjectUtil.toString( event));
        }

       
       


    }
}

 


This type of bug is infurating, but at least I now have a fix :)

Vendor client relationships

Our clients are very good and we don't get this type of crazyness, but I have had them in the past, and found this really funny.

Vendor client relationships

Cheerwine is LIVE!

After 700 hrs of development, and goodness knows how many hours of creative, shooting and project management, www.itsasoftdrink.com is finally live.

Bluetube Interactive, my company did the development in Flex, Flash, pureMVC, clearspring and slideshowpro.

Awesome Incorporated did the creative, shooting and all round fantastic visuals

Kohler Audio did the sound composition, foley work, and crazy loops!

Hauser Group was the agency that directed and brought this amazing project to us.

Thanks a bunch to my whole team for working night and day on this !  Its time for me to go to sleep now :)

We'll do a case study on this soon, but when people tell you that "flex" can't look good, remember this whole site was built IN flex. We had many challenges to overcome, but it was a blast!

Cheers
Grant

Astra Flex and Flash Library from Yahoo - Time input component

I love simple components that just do a job that we all end up having to do and think "there must be someone who's already done this".  Astra is a fairly small Flex an Flash library that has some components that make life a little easier, the time input component I particularly like since it validates the time the user puts in and won't accept an invalid time.

Flash Audio hell - How to loop audio in Flash

I have just been in flash audio hell for a few days, trying to get 14 audio files to sync properly and loop in two different fla's

I first has gaps at the end of the loops so they stumbled as they looped even though the audio file was looped correctly.  The audio file is exactly 13 seconds and my fla is set to 24fps so thats 312 frames but when you place the loop it appear to be about 1/2 a frame too long.  The end result was either gaps, skips or general failure for the loops to "loop".

The biggest thing was don't import mp3's, they have silence at the front that messes up your loop, import wav or aiff files and let flash compress the audio.  It may be possible to create looped mp3's and import them but I haven't tried it.

The other thing if you  want them to loop, don't let flash do it using the timeline, no "gotoandplay(1)" code it will never loop properly. In the layer properties, if you use "stream" or "start" one loop will stay in sync but any other loops will start to drift away from each other.

Set all audio loop layers to Sync :Event and Repeat 9999.  and if you really must, add some code that counts to 9999 and start it again, but at that "loop" it will skip :)


I also found Kenny Bewllews site VERY helpful.


New bus cards

New Bluetube interactive bus cards just came from print 100 !

New bus cards
New bus cards

New bus cards

Adobe won't allow cross "upgrades"

Running Bluetube interactive, we use a lot of Adobe products,  for some stupid reason, I upgraded our CS3 suite to CS4 Production Premium instead of CS4 web premium back on October 2008.  I realized this in march and called adobe to ask if we could PAY to do a "cross grade" since we don't use after effects or premiere and it was a stupid mistake.

Adobe can't help with a cross crade.

So then I asked can we use our dreamweaver Mx or dreamweaver CS3 to upgrade just dreamweaver, no dice either, since I used our CS3 web suite (which includes dreamweaver) to get the CS4 production suite, we can no longer use it as an upgrade.

I understand I made a mistake and I'm assuming its not a common one, but its unfortunate that a company like mine that is small but 90% of its software spending goes to adobe is subject to an inflexibile policy that just plain "can't help". I wasn't asking for "free", I was willing to pay to switch, but the only option they had was for me to buy a full price copy of dreamweaver for $399.

Grant

pureMVC console

Bluetube Interactive does 90% of its projects using Flex and pureMVC, The Flex pureMVC console  looks like a great tool for pureMVC developers, I'll most definately be trying this out, I have a fairly large pureMVC app that would benefit from some insights.

Revolver for sitecore

Have not had chance to check it out yet but looks like it could help with sitecore based sites :

Revolver command line tool for sitecore

Once I get chance I plan to watch the Revolver Video that describes basic usage. Atlanta Symphony Orchestra will be doing some updates to their sitecore implementation and Bluetube Interactive will be able to use Revolver to make some of these tasks easier.

Debugging flex modules

I have a large flex application using pureMVC. Its a flex based media portal, sort of like a Flex based "yahoo".  its loads lots of different modules that I did not write, I built the framework.

Some of these modules load flash swf's which sometimes have script timeouts, so when I'm trying to debug, I'm constantly interupted by "script timeout" exceptions that halt the main thread and stop me whever I'm stepping through the code, after dealing with it I have to click "resume" in the debugger and start over, its very frustrating.  If you change your main application script timeout to 60 seconds it has no effect on loaded modules, and the module mxml tag has no provision for extending or ignoring the script timeout exception.

If anyone has figured out some voodo to solve this annoying issue I'd be most interested.