dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: 360 scrolling of images

  1. #1
    Senior Member
    Join Date
    May 2005
    Location
    Wisconsin
    Posts
    181

    360 scrolling of images

    I want to scroll these image 360 degrees. Right now i can go end to end but it will not recylcle the image. Is there any code out there that will do this? How would i fix the code i have to accomplish this?

    Working swf file
    http://www.wisc-online.com/prototype.../fvtctour1.swf

    Source code link
    http://www.wisc-online.com/prototype...ur/images1.zip

    Code:
    //******************* Scroll Function for Large Images *******************************
    var maxSpeed:uint = 10;
    imageArea.addEventListener(MouseEvent.MOUSE_MOVE, scrollin);
    function scrollin(event:MouseEvent):void {
    	// Reposition the mc's y to the middle of stage
    	//imageArea.y = stage.stageHeight / 2;
    	imageArea.x = stage.stageWidth / 2;
    	//
    	// Find the stage's centre point
    	var midPt:uint = stage.stageWidth / 2;
    	var hiPt:uint = stage.stageHeight/2;
    	//
    	// Find the difference between the mouseX and midPt
    	var diff:int = mouseX - midPt;
    	var Hdiff:int = mouseY - hiPt;
    	//
    	// To convert it to percentage
    	var perc:Number = diff / midPt;
    	var hiPerc:Number = Hdiff/hiPt;
    	//
    	// Finally moving it base on the percentage
    	//imageArea.x += perc * maxSpeed;
    	imageArea.x = 0-(mouseX)*(imageArea.width/800 -1);
    	imageArea.y = 0-(mouseY)*(imageArea.height/600 -1);
    
    }
    Josh
    Multimedia Programmer
    flashmajic.com

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518

    Maybe try something like this...

    Code:
    import caurina.transitions.*;
    
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    import flash.display.*;
    
    //Creates new image loader
    var imageLoader:Loader;
    //Holder variable for the image to load
    var ImageID:String = new String();
    var bmp:Bitmap;
    function loadImage(url:String):void {
    	// Set properties on my Loader object 
    	imageLoader = new Loader();
    	imageLoader.load(new URLRequest(url));
    	imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
    	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    }
    
    function imageLoaded(e:Event):void {
    	// Load Image 
    	imageArea.addChild(imageLoader);
    	bmp = new Bitmap();
    	imageArea.addChild(bmp);
    	bmp.x=imageLoader.content.width;
    	bmp.bitmapData=new BitmapData(imageLoader.content.width,imageLoader.content.height);
    	bmp.bitmapData.draw(imageLoader);
    	imageArea.addEventListener(MouseEvent.MOUSE_OVER, startScroll);
    	imageArea.addEventListener(MouseEvent.MOUSE_OUT, stopScroll);
    }
    
    function imageLoading(e:ProgressEvent):void {
    	// Use it to get current download progress 
    	// Hint: You could tie the values to a preloader :) 
    }
    //******************************************************************************************
    //++++++++++++++++++++++++ Buttons for images and Map ++++++++++++++++++++++++++++++++++++++
    //******************************************************************************************
    //
    //Variable to determine if you loaded an image already
    var ImgLoaded:Number=0;
    imagescolling.img1_mc.addEventListener(MouseEvent.MOUSE_UP, newbtn);
    imagescolling.img1_mc.file="images1/1.jpg";
    imagescolling.img2_mc.addEventListener(MouseEvent.MOUSE_UP, newbtn);
    imagescolling.img2_mc.file="images1/2.jpg";
    imagescolling.img3_mc.addEventListener(MouseEvent.MOUSE_UP, newbtn);
    imagescolling.img3_mc.file="images1/3.jpg";
    
    function newbtn(event:MouseEvent):void {
    	ImageID=event.currentTarget.file;
    	imageArea.x=0;
    	imageArea.y=0;
    	if (ImgLoaded>0) {
    		imageArea.removeChild(imageLoader);
    		imageArea.removeChild(bmp);
    		loadImage(ImageID);
    	} else {
    		loadImage(ImageID);
    	}
    	ImgLoaded++;
    }
    //******************* Scroll Functions for Large Images *******************************
    var maxSpeed:uint=50;
    
    function startScroll(event:Event):void {
    	event.currentTarget.addEventListener(Event.ENTER_FRAME, doScroll);
    }
    function doScroll(event:Event):void {
    	if (mouseX>0&&mouseX<stage.stageWidth&&mouseY>30&&mouseY<530) {
    		if (mouseX<stage.stageWidth/2) {
    			imageArea.x = imageArea.x + (maxSpeed/((100*mouseX)/(stage.stageWidth/2)));
    		} else if (mouseX>stage.stageWidth/2) {
    			imageArea.x = imageArea.x + -1 * (maxSpeed/((100*(stage.stageWidth-mouseX))/(stage.stageWidth/2)));
    		}
    		if (imageArea.x<=0-(imageArea.width/2)) {
    			imageArea.x=0;
    		} else if (imageArea.x > 0) {
    			imageArea.x = 0-(imageArea.width/2);
    		}
    	}
    }
    function stopScroll(event:Event):void {
    	event.currentTarget.removeEventListener(Event.ENTER_FRAME, doScroll);
    }
    //++++++++++++++++++++++++++++++++ Buttons End +++++++++++++++++++++++++++++++++++++++++++++++
    //
    //++++++++++++++++++++ This code Controls The Scrolling Thumbnails +++++++++++++++++++++++++++
    var minScroll:Number=0;
    var maxScroll:Number=track.width-handler.width;
    var draging:Boolean=false;
    var bounds:Rectangle=new Rectangle(handler.x,handler.y,maxScroll,0);
    handler.buttonMode=true;
    handler.addEventListener(MouseEvent.MOUSE_DOWN,beginDrag);
    
    function beginDrag(event:MouseEvent):void {
    	handler.startDrag(false,bounds);
    	draging=true;
    	handler.addEventListener(Event.ENTER_FRAME,checkingProgress);
    	stage.addEventListener(MouseEvent.MOUSE_UP,endDrag);
    }
    function endDrag(event:MouseEvent):void {
    	handler.stopDrag();
    	draging=false;
    }
    
    function checkingProgress(event:Event):void {
    	var procent:Number=handler.x/maxScroll;
    	if (draging) {
    		Tweener.addTween(imagescolling,{x:(-procent*(imagescolling.width - 790)),time:2});
    	}
    }
    //++++++++++++++++++++++++++++ End Scrollign Thumbnails Code ++++++++++++++++++++++++++++++++++++

  3. #3
    Senior Member
    Join Date
    May 2005
    Location
    Wisconsin
    Posts
    181
    WOW Thats sweet. Thats jsut what i needed. I wish i coudl begin to understand hwat you did tyo make it work.

    Ill be spending the next few hours trying to understand how its working.

    Thanks a bunch!
    Josh
    Multimedia Programmer
    flashmajic.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center