関連ページ  
【WEB Flex】 FlexBook の使用方法

サンプルコード

FlexBook の中の flv プレーヤー

FlexBook は、ドラッグやクリックでまるで本物の本のようにページをめくる
事のできる Flex 用のコンテナです。

March 14th, 2007 のアーティクルの FlexBook source files からダウンロード
できます。MIT ライセンスなので、以下のようなドキュメント内の表記とともに
自由に使用できます。
FlexBook

The MIT License

Copyright (c) 2007-2008 Ely Greenfield

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
問題点
全てのコンテナが問題無く実装はできないようです。
複雑なコンテナは表示できないかもしれません。
今回致命的だったのは、VideoDisplay をページに実装した場合、
backCover という、FlexBook 用のコンテナを同時に使用した場合
フリーズしました。使わなければ問題無いのでサンプルでは使用していません。

オリジナルのサンプルは、チャート等煩雑な構成になっているので、
こちらのサンプルでは、外部ソース化したユーザーコントロールも
使用せずにシンプルなものになっています。
( Main.mxml と、ライブラリがあればビルドできます )

FlexBook の構成方法は単純で、扉はあっても無くても良く、それ以外は
実装したコンテナが全てページになるという仕掛けです。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
	xmlns:mx="http://www.adobe.com/2006/mxml"
	initialize="initData();"
	xmlns:controls="qs.controls.*"
	xmlns:effects="qs.effects.*"
	backgroundGradientColors="[#000000, #282828]"
	backgroundColor="#282828"
	paddingTop="40"
>

<mx:Script>
<![CDATA[

	import mx.controls.*;
	import mx.events.*; 
	import mx.formatters.*;
	import flash.external.*;

	// *********************************************************
	// ログ表示
	// *********************************************************
	public function firebug(data:Object):void {
	
		var fmt:DateFormatter = new DateFormatter();
	
		fmt.formatString = "YYYY/MM/DD HH:NN:SS";
		var logdt:String = fmt.format( new Date );
	
		ExternalInterface.call(
			"console.log", logdt,
			data+""
		);
	
	}

	// *********************************************************
	// アプリケーションの初期化
	// *********************************************************
	public function initData():void {

		// 再生イベントの発生間隔
		myVid.playheadUpdateInterval = 1;

		// プログレスバーの初期化
		progressBar.setProgress(0, 100);

		// JavaScript に公開するメソッドの登録
		ExternalInterface.addCallback("flexPlay", Play);
		ExternalInterface.addCallback("flexPause", Pause);
		ExternalInterface.addCallback("flexStop", Stop);

	}

	// *********************************************************
	// イベントテスト
	// *********************************************************
	public function state_check(e:mx.events.VideoEvent):void {

		firebug(e.state);

	}

	// *********************************************************
	// 再生ヘッド位置の表示
	// *********************************************************
	public function playhead_Update(e:mx.events.VideoEvent):void {
		progressBar.setProgress(
			e.playheadTime,
			e.currentTarget.totalTime
		);
	}

	// *********************************************************
	// JavaScript 用のインターフェイス
	// *********************************************************
	public function Play():void {

			myVid.play();

	}
	public function Pause():void {

			myVid.pause();

	}
	public function Stop():void {

		myVid.autoRewind=true;
		myVid.stop();
		myVid.autoRewind=false;

	}

]]>
</mx:Script>

<controls:FlexBook id="book" 
	paddingTop="60"
	width="850" height="510"
	horizontalCenter="0"
	animateCurrentPageIndex="true"
	activeGrabArea="corner"
	edgeAndCornerSize="50" 
	itemSize="halfPage"
	>

	<!--表紙定義-->
	<controls:cover>
		<mx:Canvas
			backgroundColor="#FFFFFF" color="#000000"
		>
			<mx:Label
				text="ようこそいらっしゃいました"
				fontSize="20"
				horizontalCenter="0"
				verticalCenter="0"
				width="100%" textAlign="center"
			/>
		</mx:Canvas>
	</controls:cover>
	
	<!--1ページ目-->
	<mx:Canvas
		backgroundColor="#FFFFFF" color="#000000"
	>
		<mx:Label
			text="物語は・・・・"
			fontSize="20"
			horizontalCenter="0"
			verticalCenter="0"
			width="100%" textAlign="center"
		/>
	</mx:Canvas>
	
	<!--2ページ目-->
	<mx:Canvas
		backgroundColor="#FFFFFF" color="#000000"
	>
		<mx:Label
			text="ある時突然始まったのです。"
			fontSize="20"
			horizontalCenter="0"
			verticalCenter="0"
			width="100%" textAlign="center"
		/>
	</mx:Canvas>
	
	<!--3ページ目-->
	<mx:VideoDisplay
		source="sample.flv"
		id="myVid"
		autoPlay="false" autoRewind="false"
		playheadUpdate="playhead_Update(event)"
		complete="progressBar.setProgress(100,100)"
		ready="state_check(event)"
		stateChange="state_check(event)"
	/>
	
	<!--4ページ目-->
	<mx:VBox
		backgroundColor="#FFFFFF" color="#000000"
		paddingLeft="20"
	>
		<mx:HBox
			backgroundColor="#FFFFFF" color="#000000"
			paddingTop="20"
			paddingLeft="20"
			paddingBottom="20"
		>
			<mx:Button
				label="Play"
				click="myVid.play();"
				width="60"
			/>
			<mx:Button
				label="Pause"
				click="myVid.pause();"
				width="60"
			/>
			<mx:Button
				label="Stop"
				click="myVid.autoRewind=true;myVid.stop();myVid.autoRewind=false;"
				width="60"
			/>
	
	
		</mx:HBox>
		<mx:ProgressBar
			id="progressBar"
			mode="manual"
			label=""
			width="300"
		/>
	</mx:VBox>
	
	<!--5ページ目-->
	<mx:Canvas
		backgroundColor="#FFFFFF" color="#000000"
	>
		<mx:Label
			text="さて・・・"
			fontSize="20"
			horizontalCenter="0"
			verticalCenter="0"
			width="100%" textAlign="center"
		/>
	</mx:Canvas>
	
	<!--6ページ目-->
	<mx:Canvas
		backgroundColor="#FFFFFF" color="#000000"
	>
		<mx:Label
			text="またのおこしをお待ちしております"
			fontSize="20"
			horizontalCenter="0"
			verticalCenter="0"
			width="100%" textAlign="center"
		/>
	</mx:Canvas>

</controls:FlexBook>


</mx:Application>