Advertisement

02.11.2008 at 04:35PM PST, ID: 23154853
[x]
Attachment Details

How to preload the next 2 pages in a Flipbook/Flexbook

Asked by The_Kingpin08 in Web Languages/Standards, Adobe Flex

Tags: Adobe, Flex, Builder 2

Hi experts!

This is kind of the second part of a general question I had about the best way/how-to preload images in Flex.

My project is a custom version of Ely Greenfield's Flexbook and I'm pretty much done but there's still one big question remaining: how do I preload the next 2 pages in the book?

I think I understand how the preload process works, creating the images object (that will be used as pages) and then using the preloadContent function. This way, I would have no problem preloading every images of the book. However, this is not what I need.

The reason I only want to preload the next 2 pages is because I don't want to use a loading images of creating a low version of every images I have. I plan of having around 100 pages and making a low version of every pages would be a waste of time.

Also, the images can't be embed, so I'll have to load them externally using a function to get the filename. They will always have the same filename, something like "picture001.jpg, picture002.jpg, picture003.jpg..."

With the help of the experts julianopolito on my last question, here's what I've done so far.

Thanks a lot for the help. Have a nice evening.
Frank
Start Free Trial
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>
 
Loading Advertisement...
 
[+][-]02.11.2008 at 05:14PM PST, ID: 20871874

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.11.2008 at 05:36PM PST, ID: 20871951

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 12:01AM PST, ID: 20873101

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 02:06AM PST, ID: 20873590

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 02:40AM PST, ID: 20873745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 09:22AM PST, ID: 20876796

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 09:30AM PST, ID: 20876876

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 05:13PM PST, ID: 20880893

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 09:03PM PST, ID: 20881774

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 01:13AM PST, ID: 20882735

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 02:56PM PST, ID: 20889278

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 09:15PM PST, ID: 20891086

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.14.2008 at 03:15AM PST, ID: 20892395

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.14.2008 at 08:33AM PST, ID: 20894761

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 04:37AM PST, ID: 20909367

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.16.2008 at 08:28PM PST, ID: 20912869

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Web Languages/Standards, Adobe Flex
Tags: Adobe, Flex, Builder 2
Sign Up Now!
Solution Provided By: julianopolito
Participating Experts: 2
Solution Grade: A
 
 
[+][-]02.18.2008 at 01:11PM PST, ID: 20923473

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 07:46AM PST, ID: 20929432

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 08:48AM PST, ID: 20930063

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 10:30AM PST, ID: 20931105

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 11:37AM PST, ID: 20931751

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 01:33PM PST, ID: 20932836

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.19.2008 at 02:52PM PST, ID: 20933419

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.20.2008 at 03:34AM PST, ID: 20936741

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.20.2008 at 04:04AM PST, ID: 20936906

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.20.2008 at 06:35PM PST, ID: 20944479

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 05:03AM PST, ID: 20947216

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 06:07AM PST, ID: 20947758

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 07:06AM PST, ID: 20948328

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628