Wednesday, March 9, 2011

Integrate Captivate Files With Adobe Flex

Adobe Flex came to rescue when we hit the wall with Captivate, need some customizations in the Captivate UI.  Had to struggle to find a good documentation on access Captivate Variables and Events in Adobe Flex

Following are the Steps

Step1 : Setup

Download and Copy the classes Actionscript classes to your and helper classes from

Create package (com.widgetfactory) and copy the events and helpers to your project

Step 2: Access Captivate Variables and Events

Create a Flex Project and add Image comp for Captivate File,Captivate  Access Events and variables

   1: <s:Application>
   2: <fx:Script>
   3:     <![CDATA[
   4:         import;
   5:         import;
   6:         import com.widgetfactory.helpers.CaptivateEventsToWidgetEvents;
   8:         private function loadCaptivateFile( url:String):void {
   9:               if( !contentLoader.hasEventListener( Event.COMPLETE ) ) {
  10:                         contentLoader.addEventListener( Event.COMPLETE, handleCaptivateLoadComplete );
  11:                }
  12:               contentLoader.load( url ); //url points to the swf file
  13:         }
  15:      private function handleCaptivateLoadComplete( event:Event = null ):void {
  16:             var captivateMovie:MovieClip = MovieClip(contentLoader.content);            
  17:             CaptivateEventsToWidgetEvents.registerEventsWithWidgetEvent( this, captivateMovie);
  18: //Access captivate events
  19:             if( !captivateMovie.hasEventListener( WidgetEvent.ENTER_MOVIE ) ) {
  20:                 captivateMovie.addEventListener( WidgetEvent.ENTER_MOVIE, movieStartedEvent, false, 0, true );
  21:             }
  22:      }
  24:     private function movieStartedEvent(event:WidgetEvent):void{
  25:           var captivateMovie:MovieClip = MovieClip(contentLoader.content);
  26:           captivateMovie.cpCmndMute = 1            //acccess cpativate variables
  27:     }
  29: <s:Application>


Captivate variables take a little time 10-20ms to take into effect, so if you set it and right away try to access it, you will still see the old value.

Ideally, I feel, if the project is getting too complex, it better to your Flex directly and create a database centric application instead of Using Captivate and doing workarounds. But again this is case by case.

Happy Flexing!!

No comments:

Post a Comment