Link to home
Start Free TrialLog in
Avatar of The_Kingpin08
The_Kingpin08

asked on

Is it possible to zoom a picture over 100%?

Hi experts,

I decided to learn the Flex language, and even though I've done some Flash before, I feel completely lost right now!

I found an open source flipbook version of Flex (http://www.quietlyscheming.com/blog/components/flexbook/) and I'd like to customize it.

What I'm trying to do right now is pretty simple: I want to be able to zoom a page over 100% (up to 300% if possible) of it's size when the user click it.

To do this, I have use the FlexBook image browser example (found here http://demo.quietlyscheming.com/book/FullPage.html) but the zoom only streches the pictures to 100%. Also, unlike this example I'm gonna use image that are gonna fill the entire page.

I would really appreciate if someone could helpe me out or give me some hints on how to do this.
I post my code below, so feel free to let me know if you need more information.

Thanks a lot and have a nice day.
Frank

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://www.adobe.com/2006/mxml" xmlns:l="*" layout="absolute" 
	xmlns:controls="qs.controls.*"
	creationComplete="initTimer();" xmlns:containers="qs.containers.*"
	viewSourceURL="/source/FlexBook.zip"
	>
<!--
Copyright (c) 2006 Adobe Systems Incorporated
 
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.
-->	
 
	<Script>
		<![CDATA[
			import mx.containers.Form;
			import mx.core.UIComponent;
			import mx.controls.Alert;
			
			public  function focusOn(target:*):void
			{
				if(landscape.selection.length == 1 && landscape.selection[0] == target)
				{
					landscape.selection = []; 
					Alert.show("Zoomout")
				}
				else
				{
					landscape.selection = [target];
					Alert.show("Zoomin")
				}				
			}
			
			[Bindable] public var dataSet:Array;
		]]>
	</Script>
	
	<containers:Landscape width="70%" top="40" bottom="1" paddingLeft="1" paddingTop="1" paddingBottom="1" paddingRight="1" id="landscape"  zoomLimit="none" clipContent="false" cachePolicy="on">			
		<Canvas width="100%" height="100%" >
			<controls:FlexBook id="book" y="47" left="40" right="40" top="40" height="80%" animateCurrentPageIndex="true" showCornerTease="true" edgeAndCornerSize="80" itemSize="halfPage">
 
				<!-- Book's cover -->
				<controls:cover><controls:SuperImage maintainAspectRatio="true" width="100%" height="100%" source="images/page001.jpg" click="focusOn(event.currentTarget)" /></controls:cover>
				
				
				<controls:itemRenderer>
				<Component>
					<VBox>								
						<controls:Zoomer>
							<controls:SuperImage maintainAspectRatio="true" width="100%" height="100%" data="{data.slice(0,data.indexOf(','))}" click="outerDocument.focusOn(event.currentTarget)" />
						</controls:Zoomer>
					</VBox>
				</Component>
				</controls:itemRenderer>
				
				<!-- Images of the other pages of the book -->
				<String>images/page002.jpg</String>
				<String>images/page003.jpg</String>
				<String>images/page004.jpg</String>
			</controls:FlexBook>
			
		</Canvas>
	</containers:Landscape>	
</Application>

Open in new window

Avatar of trigger-happy
trigger-happy
Flag of Philippines image

I think that scaling beyond 100% is possible through xscale and yscale properties, but an option that you can do in case you can't do that is to scale the image all the way to 200% outside of flex using something like photoshop or imagemagick. You can then import the image and scale it down to 50% and then give the users an option to scale it to 100% as needed. This is one alternative you can do if flex does not allow you to zoom beyond 100%.

--trigger-happy
we use a Canvas called Canvas3D to place our book / pages into, then use a slider called sldZoom for the zoom level then use the following function in the code snippet to perform the zoom .

of course would be sexyier to use the mouse whell event, if you need the code to do this cleanly let me know and ill post the code through



public function zoomBook() : void {
	canvas3D.scaleX = sldZoom.value;
	canvas3D.scaleY = sldZoom.value;
}

Open in new window

Avatar of The_Kingpin08
The_Kingpin08

ASKER

I would really appreciate if you could post it: it looks pretty amazing, and that's exactly what I'm trying to do!
If you prefer to email me, feel free to do it.

Thanks a lot for your help.
Frank
the_kingpin_@hotmail.com
ASKER CERTIFIED SOLUTION
Avatar of Robinsonx6
Robinsonx6
Flag of Mauritius image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
know the code above works as i use exactly this myself against the flipbook

if i can help at all in future with your flipbook project please post your question and let me know youve posted a question

cghrmauritius@gmail.com
Wow, this is really awesome Robinsonx6!

I'm taking a chance by asking this, but would there be a way to zoom on 1 specific page instead of the whole book?

Also, when you zoom larger than 100% of the page scale, it usually expand outside of the screen but no scrollbar appear. I guest I must use javascript to show them when I zoom?

Thanks so much for the help, I will definately have more questions about the flexbook so I'll let you know!

Thanks,
Frank
The scroll bars issue will sort itself out if you put the Canvas you created into a fixed Canvas on the page

its a bit like a desk containing a container which holds the book

the desk will show the scroll bars this is because you are zooming the book within the desk


zoom specific page this is another question to be postwede but yes its possible