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

The_Kingpin08Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

trigger-happyCommented:
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
0
Robinsonx6Commented:
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

0
The_Kingpin08Author Commented:
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
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Robinsonx6Commented:
Note for the following to work the book has to be clicked on first before moving the mouse wheel this draws the applications focus to the books container.


ok first off wrap your book compontent into a canvas the same width and height as your book and give it an id of bookContainer

then add the following code into your creationComplete event in your code youve called it initTimer (but there is no function in your code called that so you will need to add it, but i would create a function called init() as below, so change the creationComplete to creationComplete="init()")

private function init():void{
      book.addEventListener(MouseEvent.MOUSE_WHEEL, onWheel);
//if you wish to call the initTimer function
initTimer();
}

Then add the following private variable to the code

private var _zoomLevel:Number = 1;

next add the following code functions

//
// Handles Mouse Wheel
//
private function onWheel( event : MouseEvent ) : void {
      zoomLevel = event.delta;
}

//
// this function ensures that we can only zoom between 0 and 5
//                  
public function set zoomLevel(delta:Number):void {
      if(_zoomLevel > 0 && _zoomLevel < 5){
            if(delta == 3){
                  if(_zoomLevel < 5){
                        _zoomLevel ++;
                  }
            } else if(delta == -3){
                  if(_zoomLevel > 1){
                        _zoomLevel --;
                   }
              }
              bookContainer.scaleX = zoomLevel;
              bookContainer.scaleY = zoomLevel;

      }
      Alert.show("zooming level" + zoomLevel.toString());
}
                  
[Bindable]
public function get zoomLevel():Number{
            return _zoomLevel;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Robinsonx6Commented:
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
0
The_Kingpin08Author Commented:
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
0
Robinsonx6Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Flex

From novice to tech pro — start learning today.