Home / Support / ShowRoom / Swiff Player Developer / User Guide
Swiff Player Developer Guide

Overview

Flash Loading

When a PowerPoint slide is entered during the Slide Show, ShowRoom computes the bounds of the Flash shape to be displayed on screen. If the Flash is inserted as tranparent ShowRoom takes a snapshot of the screen where the Flash is to be displayed.

A Flash loader written in ActionScript is loaded and started. This loader loads the snapshot background bitmap from ShowRoom. Then your Flash is loaded and started.

Accessing the API from your Flash

To access the ShowRoom API, you need to create a ShowRoom object. If this object is not null, your Flash does run in PowerPoint and have access to the ShowRoom PowerPoint API. This object should be created once and must take your main Sprite object in arguement:

import flash.display.Sprite;
import com.globfx.showroom.ShowRoom;
import com.globfx.showroom.SlideShow;
import com.globfx.showroom.Slide;

public class MyFlashApp extends Sprite
{
  private var showroom : ShowRoom = null;

  public function MyFlashApp()
  {
    showroom = ShowRoom.create(this);
    if( showroom != null )
    {
      trace("We are running in PowerPoint");

      // e.g. "Presentation1.pptx"
      trace("Presentation is named "+showroom.presentation.name);

      trace( "The SlideShow has "+showroom.slideShow.numSlides+" slides." ); 

      // First slide has number 1 for instance
      trace("Current Slide Number is "+showroom.slideShow.currentSlide.number);
      trace("Current Slide Title is "+showroom.slideShow.currentSlide.title);
    }
    else
    {
      // the ShowRoom PowerPoint API is not available
      trace("We are not running in PowerPoint");
    }
  }
}

Important: the stage object might not be initialized in your main Sprite contructor. You may have to wait for the ADDED_TO_STAGE event before accessing this object:

import flash.display.Sprite;
import flash.events.Event;

public class MyFlashApp extends Sprite
{
  public function MyFlashApp()
  {
    this.addEventListener( Event.ADDED_TO_STAGE, on_added_to_stage );
  }
  private function on_added_to_stage( e : Event ) : void
  {
    // stage object is available
  }
}

Navigating through slides

To navigate through slides during the Slide Show, simply use the SlideShow object:

import flash.display.Sprite;
import com.globfx.showroom.ShowRoom;
import com.globfx.showroom.SlideShow;

public class MyFlashApp extends Sprite
{
  private var showroom : ShowRoom = null;

  /* ... */

  private function goto_next_slide() : void
  {
    showroom.slideShow.gotoNextSlide();
  }
  private function goto_previous_slide() : void
  {
    showroom.slideShow.gotoPreviousSlide();
  }
  private function goto_slide( slide_number : int ) : void
  {
    showroom.slideShow.gotoSlideNumber(slide_number);
  }
}

Receiving PowerPoint Effects

Applying effects on your Flash will enable it to have multiple visual states on screen. As an example, creating a picture slide show in ActionScript will require as many effects as the number of pictures to show.

You can apply a number of standard PowerPoint effects to your Flash. These effects will all have the same type in PowerPoint and will be started "On Click", except for the first one that you can edit and place in the PowerPoint Timeline.

These effects are standard PowerPoint effects. Therefore they are fully compatible with standard PowerPoint Remotes.

To specify the number of effects applied to your Flash, use the "Enable ShowRoom Effects" check box in the Flash Ribbon Tab (or in the Developer Tab in the properties dialog box). Then enter the number of effects needed.

Enabling ShowRoom Effects will create a first master effect in the PowerPoint Timeline. This effect can be edited and placed in the Timeline. When the slide is entered during the Slide Show, ShowRoom will expand this master effect to a list of sequential standard effects that PowerPoint will execute.

When an effect is executed, ShowRoom sends to your Flash the current effect index, using the SwiffPlayerShape.EFFECT_CHANGED event. In the picture slide show example, you would need to display picture index when the effect index is executed.

import flash.display.Sprite;
import flash.events.Event;
import com.globfx.showroom.ShowRoom;
import com.globfx.showroom.SwiffPlayerShape;

public class MyFlashApp extends Sprite
{
  private var showroom : ShowRoom = null;

  public function MyFlashApp()
  {
    showroom = ShowRoom.create(this);
    if( showroom != null )
    {
      showroom.shape.addEventListener( SwiffPlayerShape.EFFECT_CHANGED,
                                       on_showroom_effect_changed );
    }
    else
    {
      // the ShowRoom PowerPoint API is not available
    }
  }
  private function on_showroom_effect_changed( e : Event ) : void
  {
    trace( "Current effect index is "+showroom.shape.effectIndex );
  }
}

Playing with your Flash background Bitmap

When you set your Flash transparent, ShowRoom will take a snapshot of the screen behind your Flash. This snapshot bitmap contain the exact slide background and content behind your Flash.

You have access to this background bitmap to change it and do whatever you like with it. For example, you can blur it, make it gray, animate it, playing 2D or 3D effects as an entrance of your Flash.

import flash.display.Sprite;
import flash.display.Bitmap;
import flash.filters.BlurFilter;
import flash.filters.BitmapFilterQuality;
import com.globfx.showroom.ShowRoom;
import com.globfx.showroom.SwiffPlayerBackground;

public class MyFlashApp extends Sprite
{
  private var showroom : ShowRoom = null;

  public function MyFlashApp()
  {
    showroom = ShowRoom.create(this);
    if( showroom != null )
    {
      if( showroom.background != null )
      {
        // get the background bitmap pixels, create another Bitmap and blur it
        var bmp : Bitmap= new Bitmap( showroom.background.bitmapData );

        var blur_size : int = 8;
        var filter : BlurFilter = new BlurFilter( blur_size,
                                                  blur_size,
                                                  BitmapFilterQuality.HIGH );
        bmp.filters = [ filter ];
        
        addChild(bmp);

        // hide the previous bitmap
        showroom.background.visible= false;
      }
    else
      {
        trace("The Flash is not set tranparent");
      }  
    }
    else
    {
      // the ShowRoom PowerPoint API is not available
    }
  }
}

Resizing your Flex Application

ShowRoom will automatically resize your Flash by using the standard IFlexDisplayObject.setActualSize(newwidth,newHeight) function.

As all Flex applications implement the IFlexDisplayObject interface, you don't have to code anything else.

Resizing your Flash (not using Flex Framwork)

When your Flash in running into the slide (not full screen), its size it the same as the stage size (stage.stageWidth and stage.stageHeight). You can then resize it by handling the Event.RESIZE event:

  private function on_added_to_stage( e : Event ) : void
  {
    // stage object is available
    stage.scaleMode= StageScaleMode.NO_SCALE;
    stage.align= StageAlign.TOP_LEFT;
    stage.addEventListener( Event.RESIZE, on_stage_resize );
  }

  private function on_stage_resize( e : Event ) : void
  {
    // layout your Flash using stage.stageWidth and stage.stageHeight
  }
}

When your Flash in running in Full Screen mode, its size is not the same as the stage size. ShowRoom will resize it by using the IShowRoomContent interface. You can also use this interface to layout your Flash even if it is not running in Full Screen mode.

import flash.display.Sprite;
import com.globfx.showroom.ShowRoom;
import com.globfx.showroom.IShowRoomContent;

public class MyFlashApp extends Sprite implements IShowRoomContent
{
  private var showroom : ShowRoom = null;

  public function MyFlashApp()
  {
    showroom = ShowRoom.create(this);
    if( showroom != null )
    {
      trace("We are running in PowerPoint");
    }
    else
    {
      // the ShowRoom PowerPoint API is not available
      trace("We are not running in PowerPoint");
    }
  }

  // called by ShowRoom to resize this Flash
  public function setShowRoomContentSize( newWidth : Number,
                                          newHeight : Number ) : void
  {
    // layout your Flash using newWidth and newHeight
  }
}

Using the Visited Slide History

To access the visited slide history, use the SlideShow.history property to display the previously visited slide numbers, the elapsed time on this slide and the date/time the slide was entered:

import flash.display.Sprite;
import com.globfx.showroom.ShowRoom;
import com.globfx.showroom.SlideShow;

public class MyFlashApp extends Sprite
{
  private var showroom : ShowRoom = null;

  /* ... */

  private function display_history() : void
  {
    var history : Array = showroom.slideShow.history;
    if( history == null || history.length <= 1 )
    {
      trace( "No history yet" );
    }
    else
    {
      // history[0] is the current slide
      // history[1] is the previous slide in time, etc.

      trace( "History: "+(history.length-1)+" previously visited slides:" );
      for( var i : int = 1; i < history.length; ++i )
      {
        var vs : VisitedSlide = history[i];
        var slide_number : int = vs.slide.number;
        var elapsed : Number = vs.elapsed;
        var dateEntered : Date = vs.dateEntered;
        trace( "  "+i+" : "
               +"Slide Number: "+slide_number+", "
               +"Duration: "+vs_elapsed+" seconds"+", "
               +"Entered: "+dateEntered );
      }   
    }
  }
}

Listening to the Slide Show Pause/Resume event

If your Flash is displaying a video or a complex animation, you need to know when the PowerPoint Slide Show is paused and resumed to pause and resume your video or animation.
Listen to the SlideShow.PLAY_STATE_CHANGED event for that.

Note: A Slide Show is paused by PowerPoint when it loses focus. Try F1 or Ctrl-S during the Slide Show to pause it.

import flash.display.Sprite;
import flash.events.Event;
import com.globfx.showroom.ShowRoom;
import com.globfx.showroom.SlideShow;

public class MyFlashApp extends Sprite
{
  private var showroom : ShowRoom = null;

  public function MyFlashApp()
  {
    showroom = ShowRoom.create(this);
    if( showroom != null )
    {
      showroom.slideShow.addEventListener( SlideShow.PLAY_STATE_CHANGED,
                                           on_slideshow_play_state_changed );
    }
    else
    {
      // the ShowRoom PowerPoint API is not available
    }
  }
  private function on_slideshow_play_state_changed( e : Event ) : void
  {
    if( showroom.slideShow.paused )
      trace( "Slide Show has been paused." );
    else
      trace( "Slide Show has been resumed." );
  }
}

Going Further

Go further and download the samples and their source code.

Home  |  Swiff Chart  |  Swiff Chart Generator  |  ShowRoom  |  Swiff Saver  |  SWF Extractor  |  Swiff Player
Swiff Player Developer