Flash CS4 Help needed (virtual tour/panorama)

Associate
Joined
7 May 2009
Posts
837
Hi, I want to create a sort of virtual tour using a panoramic image, all I want is for the user to control the image going left and right, so even if it is clicking a button to go left/right or moving the cursor to the left/right and the image moving left/right.

I have looked everywhere for tutorials but they just dont give enough information or are too complicated for what I want to create.

So can anyone help me or even point me to a simple tutorial please :(

Thank you.
 
Started one at uni the other day, its very basic, as it stands it will continue until the image itself leaves the stage which i understand isn't ideal but you can probably work that out, if not im sure my friend managed to get his to stop or someone else could expand on it.

And i've just noticed it you again BiGT bet this is your un work again :p

This goes within the .fla file, call the instance of the image on screen imageBar.

Code:
stage.addEventListener (Event.ENTER_FRAME,moveBar);

var xpos:int = 0;

function moveBar (evt:Event) {

	if (mouseX < 30) {
		imageBar.x = xpos += 5;
	}

	if (mouseX>520) {
		imageBar.x = xpos -=5;
	}

}

And this goes in an actionscript file you call pictures (also call the class of the image you're using pictures) NOTE: This .as file must be in the same location as the .fla.

Code:
package {
	import flash.events.*;
	import flash.display.*;

	public class pictures extends MovieClip {
		var xpos:int = 0;

		function pictures () {
			stage.addEventListener (Event.ENTER_FRAME,movePictures);
		}



		function movePictures (evt:Event) {



			if (MovieClip(root).mouseX < 30) {
				this.x=xpos += 5;
			}


			if (MovieClip(root).mouseX>520) {
				this.x=xpos-=5;
			}

		}

	}
}

Result is this:
http://megaswf.com/view/f294dcc33137061554e8d8e98d04c27b.html


EDIT: Failing that take a look at this Exactly the same thing but non object orientated so slightly easier and it has some kind of smoothing/acceleration applied.

Failing that an even easier way would be to use buttons as you said which is very basic it's probably as simple as mouse event that when activated it just adds + or - a value to the X position of what ever you want.
 
Last edited:
Haha yes it is me again, but I only ask on the forum after I have searched everywhere, Its my first year so I am a noob with flash and bloody hell it's just so annoying!

Thanks very much for your help mate, I really need more practice in this, but its my last assignment of the year and a group work which everyone has abandoned apart from me :( I honestly have tried but I am just going to go with the simple buttons option, Im gonna lose my hair with all this stress!
 
Just one last question, I dont know what term to use when googling, but is there a way to make a button start/go when putting the curser over the button instead of clicking it?

Thank you.
 
Got some help from a friend for this since i had a total mind blank so you owe him a pint too.
Code:
/* btn = the name of the button
   Event listerner adding a function called mouseOver to a MOUSE_OVER event*/
btn.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);

/* The function mouseOver which contains two more event listeners one for an
   Enter frame which allows something to run on every frame, the other to 
   remove it on a MOUSE_OUT event*/
function mouseOver(evt:MouseEvent):void
{
  addEventListener(Event.ENTER_FRAME, repeat);
 addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
}

/* The repeat function as defined above. Put in here the action you want to
   repeat on every frame eg square.x += 5; */
function repeat(evt:Event):void
{
  //what you want it to do
}

/* Second part removing the event listeners when the mouse is no longer over
   butotn*/
function mouseOut(evt:MouseEvent):void
{
  removeEventListener(Event.ENTER_FRAME,repeat);
  removeEventListener(MouseEvent.MOUSE_OUT,mouseOut);
}

And what kind of multimedia deisgn course doesn't teach you some basic flash? They've had me doing this for the last two terms.
 
ha, we only did Flash for one project then moved on to something else, we did very minor things, plus pretty bad teachers.

Thank you and your friend for this, will get cracking on and tell you how I get on with it!

thanks once again!
 
Back
Top Bottom