Here is the code I am currently using, yet its not exactly want I need… I would like to zoom in on a movie clip as opposed to a static jpg. The reason is I want to add hot spots on the image that reveal callouts… If there is a way to use a movie clip in the place of the jpg, I have been unable to get it to work. Any direction and or assistance would be great, so thanks in advance…
package org.FlepStudio
{
import flash.display.;
import flash.text.;
import flash.events.;
import flash.net.;
import flash.ui.*;
import caurina.transitions.Tweener;
public class Main extends MovieClip
{
private const IMAGE_PATH:String='07_Zoom.jpg';
private var more:More;
private var less:Less;
private var container_mc:MovieClip;
private var original_width:Number;
private var original_height:Number;
private var ratioW:Number;
private var ratioH:Number;
private var boo:Boolean=true;
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE,init);
}
private function init(evt:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE,init);
stage.frameRate=31;
apple_mc.alpha=0.8;
apple_mc.width=apple_mc.height=50;
apple_mc.x=stage.stageWidth/2-apple_mc.width/2;
apple_mc.y=stage.stageHeight/2-apple_mc.height/2;
initMenu();
createContainer();
addMoreAndLess();
loadImage();
}
private function createContainer():void
{
container_mc=new MovieClip();
addChild(container_mc);
}
private function addMoreAndLess():void
{
more=new More();
more.visible=false;
more.mouseEnabled=false;
addChild(more);
less=new Less();
less.visible=false;
less.mouseEnabled=false;
addChild(less);
}
private function loadImage():void
{
var request:URLRequest=new URLRequest(IMAGE_PATH);
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,setProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,setComplete);
loader.load(request);
}
private function setProgress(evt:ProgressEvent):void
{
var percent:uint=(evt.bytesLoaded/evt.bytesTotal)*100;
pre_txt.text=percent+' %';
}
private function setComplete(evt:Event):void
{
apple_mc.stop();
removeChild(apple_mc);
removeChild(pre_txt);
evt.target.loader.removeEventListener(Event.COMPLETE,setComplete);
var bitmap:Bitmap=evt.target.loader.content as Bitmap;
bitmap.smoothing=true;
original_width=bitmap.width;
original_height=bitmap.height;
bitmap.width=stage.stageWidth;
bitmap.height=400;
container_mc.addChild(bitmap);
ratioW=(original_width-stage.stageWidth)/stage.stageWidth;
ratioH=(original_height-stage.stageHeight)/stage.stageHeight;
addMouseListeners();
addPicListeners();
}
private function addMouseListeners():void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE,setMove);
}
private function setMove(evt:MouseEvent):void
{
if(container_mc.hitTestPoint(mouseX,mouseY))
{
Mouse.hide();
if(boo)
{
more.x=mouseX;
more.y=mouseY;
more.visible=true;
less.visible=false;
}
else
{
less.x=mouseX;
less.y=mouseY;
more.visible=false;
less.visible=true;
}
}
}
private function addPicListeners():void
{
container_mc.addEventListener(MouseEvent.MOUSE_DOWN,setPicDown);
}
private function setPicDown(evt:MouseEvent):void
{
evt.target.mouseEnabled=false;
var bitmap:Bitmap=evt.target.getChildAt(0) as Bitmap;
if(!boo)
{
Tweener.addTween(bitmap,{x:0,y:0,width:stage.stageWidth,height:400,time:0.5,transition:"easeOutQuad",onComplete:enableMoreOnly});
}
else
{
var arrX:Number=mouseX*ratioW;
var arrY:Number=mouseY*ratioH;
Tweener.addTween(bitmap,{x:-arrX,y:-arrY,width:original_width,height:original_height,time:0.5,transition:"easeOutQuad",onComplete:enableLessOnly});
}
}
private function enableMoreOnly():void
{
less.visible=false;
more.x=mouseX;
more.y=mouseY;
more.visible=true;
boo=true;
container_mc.mouseEnabled=true;
}
private function enableLessOnly():void
{
more.visible=false;
less.x=mouseX;
less.y=mouseY;
less.visible=true;
boo=false;
container_mc.mouseEnabled=true;
}
public function initMenu():void
{
var etichetta:String='Flash CS3 zoom';
var cm:ContextMenu=new ContextMenu();
var item:ContextMenuItem=new ContextMenuItem(etichetta);
cm.hideBuiltInItems();
cm.customItems.push(item);
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,itemHandler1);
this.contextMenu=cm;
}
private function itemHandler1(event:ContextMenuEvent):void
{
var url:String='http://www.flepstudio.org/';
var request:URLRequest=new URLRequest(url);
navigateToURL(request,'_parent');
}
}
}