Yep, that’s the one. I go it working. The Flash embed code is not as sexy as I want it to be since I think it will have issues with ActiveX. The AC_RunContent script won’t fire, so I am just using The EMBED and OBJECT code for it.
OK, first, I’m passing the docID into the pageflip document which holds the Flash code like so:
<a href="[~111~]?docID=[*id*]">Page Flip<a>
Document #111 is the pageflip page with the flash code using a blank template (for now):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Prinspiration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #333333;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
height: 100%
width: 100%
}
-->
</style>
</head>
<body>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="[[flippingVars?filter=`width`]]" height="[[flippingVars?filter=`height`]]" id="flippingBook" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="movie" value="assets/flash/flippingBook.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<param name="scale" value="noscale">
<param name="FlashVars"value="xmlConfig=pageflip.xml?docID=[[flippingVars?filter=`pID`]]">
<embed src="assets/flash/flippingBook.swf" quality="high" bgcolor="#ffffff" width="[[flippingVars?filter=`width`]]" height="[[flippingVars?filter=`height`]]" name="flippingBook" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="xmlConfig=pageflip.xml?docID=[[flippingVars?filter=`pID`]]" scale="noscale" />
</object>
</body>
</html>
You’ll see a "flippingVars" snippet. This let’s me pass the variables down into the Flash script. Here’s the code for that:
<?php
$pID = (int) $_GET["docID"];
$filter = (isset ($filter)) ? $filter : 'pID'; // Set the filter
$tvSize = $modx->getTemplateVarOutput(array("pageWidth","pageHeight"),$pID);
$width = $tvSize['pageWidth'] *2;
$height = $tvSize['pageHeight'];
if ($filter == 'width') {
echo $width;
} elseif ($filter == 'height') {
echo $height;
} else {
echo $pID;
}
?>
The XML file is set in MODx, template blank, text/xml filetype and named "pageflip.xml" (I am using fURLs with no file suffix BTW). I make a snippet call on that page to "generateXML" (uncached) and here is the snippet:
<?php
$pID = (int) $_GET["docID"];
if($pID < 1) {
exit("no valid document id received - aborting script");
}
$tvSize = $modx->getTemplateVarOutput(array("pageWidth","pageHeight"),$pID);
$width = $tvSize['pageWidth'];
$height = $tvSize['pageHeight'];
$filter = (isset ($filter)) ? $filter : '.jpg'; // Set the filetype filter
$directory = (isset ($directory)) ? $directory : 'assets/pageimgs/'.$pID.'/normal/'; // Where to look for images
//Set the size (width and height attributes are sent in TVs as pixel dimensions)
$tvWidth = $width * 2; // This sets the total width
$tvHeight = $height;
// read through the directory and filter files to an array
$d = dir($directory);
if ($d) {
while($entry=$d->read()) {
$ps = strpos(strtolower($entry), $filter);
if (!($ps === false)) {
$items[] = $entry;
}
}
$d->close();
sort($items);
}
// Add an xml header and the opening tags
header("content-type:text/xml;charset=utf-8");
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<FlippingBook>';
echo '<width>'.$tvWidth.'</width>';
echo '<height>'.$tvHeight.'</height>';
echo '<scaleContent>false</scaleContent>';
echo '<firstPage>0</firstPage>';
echo '<alwaysOpened> false </alwaysOpened>';
echo '<autoFlip> 50 </autoFlip>';
echo '<flipOnClick> true </flipOnClick>';
echo '<staticShadowsDepth> 1 </staticShadowsDepth>';
echo '<dynamicShadowsDepth> 2 </dynamicShadowsDepth>';
echo '<moveSpeed> 2 </moveSpeed>';
echo '<closeSpeed> 3 </closeSpeed>';
echo '<flipSound>assets/media/01.mp3</flipSound>';
echo '<pageBack> 0x1C90CB </pageBack>';
echo '<loadOnDemand> true </loadOnDemand>';
echo '<cachePages> true </cachePages>';
echo '<cacheSize> 10 </cacheSize>';
echo '<preloaderType> Progress Bar </preloaderType>';
echo '<pages>';
// now, loop through the file list in the target directory
for($i=0; $i<sizeof($items); $i++) {;
echo ' <page>'.$directory.''.$items[$i].'</page>';
}
echo '</pages>';
echo '</FlippingBook>';
?>
That should do it. I still have some display to work out on the resulting page but at least I have it functioning now. I am using the "SWF Object" version of the flipping book BTW.
I have just purchase the HTML edition since it has a nicer interface and functions closer to what I want. It generates the list via a JS file but has "undocumented" XML capablity. I will post once I get that working. Once I tighten this up, I’ll add to the Wiki.