• How do I embed video in my publication using ActionScript?

This article is about Flash publication. We highly recommend you to create HTML5 publications instead of Flash ones. You can convert your existing Flash publications to HTML5 using this instruction.

Note: We recommend embedding videos in publications using YouTube and Vimeo hosted videos.

However, if this method is not suitable for you for any reason, you can also embed a video file by following the instructions below.

Please note that this alternative method requires skills in working with ActionScript and Adobe Flash Professional.

The following is an alternative approach to creating a custom ActionScript 3.0 file and embedding it in your publication. This will allow you to include videos that are not hosted on YouTube or Vimeo on your publication’s pages.

First of all, we recommend creating a separate folder to store all the page files that you’d like to embed in your publication. You might call it «workspace». Then please create a subfolder within this folder — «flv» — to which you should move all the videos that you’d like to add to the pages.

Then you can create the ActionScript file using Adobe Flash Professional:

 

Once you’ve created the file, save it to the «Workspace» folder.

After the file is saved, please click File > Import > Import Video. Import your video’s FLV file to Adobe Flash. After the «flv» folder (which is a subfolder of the «workspace» folder).

 

 

Then choose skin and color for your video:

 

Enter the instance name in Properties/SWF. It should be named «VideoName» as this name has to match with the instance name used later in the code.

Check that the relative path in the «Source» field is correct, e. g. just the path to your video file within the «workspace» folder, not the entire path starting with the drive name. You can do this by clicking on the «cubes&pen» button in the SWF file properties.

 

 

This will allow your video to playback properly even if your publication has been moved to another location.

You can see the timeline at the bottom of the window. Notice the little black dot on the left side of the timeline. Click on it and press F9.

 

 

Copy and paste the following code into the window that appears:

import flash.events.Event;

var _page:Object;

VideoName.fullScreenTakeOver = false;

function setBookPage(page:Object):void

{

_page = page;

page.addEventListener("pageOpen", handlePageOpen);

page.addEventListener("pageClose", handlePageClose);

}

function handlePageOpen(e:Event):void

{

VideoName.play(); // to launch video automatically

}

function handlePageClose(e:Event):void

{

VideoName.pause(); // to stop video

}

 

Close the window.

Now click Ctrl+Enter to see a preview. If you edit the project later, save it and click Ctrl+Enter again to update the files.

 

Now open FlippingBook Publisher and create your publication project.

Import the .swf file with the page containing your video from the «workspace» folder.

Once you have finished editing your publication project, click Publish > to HTML and enter the desired path for your publication. Click «Start».

 

This will create a folder with output files.

Open the folder HTML and copy the file with your video skin .swf file into it, so that it would be next to index.html. Copy the .flv video file to the /files/flash/ folder.

Open your publication’s folder and launch index. html. The video should now work!

 

Was this article helpful?