Advertisement
Advertisement
| 02.11.2008 at 04:35PM PST, ID: 23154853 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: |
<?xml version="1.0" encoding="iso-8859-2"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
xmlns:local="*"
xmlns:qs="qs.controls.*"
xmlns:effects="qs.effects.*"
xmlns:containers="qs.containers.*"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.controls.Image;
import qs.caching.ContentCache;
import qs.controls.flexBookClasses.FlexBookEvent;
import qs.controls.flexBookClasses.FlexBookPage;
private function initApp():void{
/* This function is called when the application is loaded. */
var pages:XMLList = pages;//gets all the images to preload. This is where my problem comes into play...
for(var i:int=0; i<pages.length(); i++){
ContentCache.getCache().preloadContent(pages[i]);//preload every pages but I need to load only the next 2...
}
myIssueID=Application.application.parameters.myissueid;
sessionID=Application.application.parameters.sessionid;
}
/* Returns the session ID used to build the image path */
private function getSessionID():String{
return Application.application.parameters.sessionid;
}
/* Returns the book ID used to build the image path */
private function getMyBookID():String{
return Application.application.parameters.myissueid;
}
/* Returns the root used to build the image path */
private function getRootPath():String{
return Application.application.parameters.rootpath;
}
/* This is the function that builds the image path */
private function getFile(fileName:String):String{
return this.getRootPath() + "VirtualIssue/fileStream.aspx?filename=" + fileName + "&SessionID="+this.getSessionID()+"&MyIssueID="+this.getMyIssueID();
}
private function loadContent(event:FlexBookEvent):void{
//this event is dispatched by each page that appears after turn. It's the function that is gonna created the next pages based on the preloaded images.
//Right now it replace the image filename to load a high resolution one instead, but since I'm only gonna have 1 version of each one of them, this is useless. I simply don't know how to correctly load the cached image!
//in this case the event.renderer is the mx:Image
var page:MyImagePage = MyImagePage(event.renderer);
//Check to see it is not null
if(Boolean(page)){
//change its source to the high res version
page.theImage.source = String(page.theImage.source).replace("_low","");
}
}
]]>
</mx:Script>
<mx:XMLList id="pages" xmlns="">
<images>
<cover><image high="getFile('picture001.jpg')" /></cover>
<back><image high="getFile('picture008.jpg')" /></back>
<image high="getFile('picture002.jpg')" />
<image high="getFile('picture003.jpg')" />
<image high="getFile('picture004.jpg')" />
<image high="getFile('picture005.jpg')" />
<image high="getFile('picture006.jpg')" />
<image high="getFile('picture007.jpg')" />
</images>
</mx:XMLList>
<qs:FlexBook id="book" y="47" top="40" horizontalCenter="0" width="718" height="500"
animateCurrentPageIndex="true"
showCornerTease="true"
edgeAndCornerSize="30"
itemSize="halfPage"
hardbackCovers="false"
hardbackPages="false"
turnEnd="loadContent(event)"
>
<qs:itemRenderer>
<mx:Component className="MyImagePage">
<mx:VBox>
<qs:Zoomer>
<mx:Image id="theImage" source="{data}" />
</qs:Zoomer>
</mx:VBox>
</mx:Component>
</qs:itemRenderer>
</qs:FlexBook>
</mx:Application>
|