Old experiment: pan through an image with actionscript

This is an experiment made in 2004 translated into a newer version of actionscript.

It’s very simple and needs a lot of improvements and I think you could transform this file into something usable.

The actionscript, all in the first frame, is very simple: the two objects are the_arrow representing the mouse pointer and map representing the image.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Mouse.hide();
_root.attachMovie("map", "map", 1);
_root.attachMovie("the_arrow", "the_arrow", 2, {_x:250, _y:175});
the_arrow.onEnterFrame = function() {
	this._x += (_xmouse-this._x)/5;
	this._y += (_ymouse-this._y)/5;
	dist_x = this._x-250;
	dist_y = this._y-175;
	angle = Math.atan(dist_y/dist_x)/(Math.PI/180);
	if (dist_x<0) {
		angle += 180;
	}
	if (dist_x>=0 and dist_y<0) {
		angle += 360;
	}
	this._rotation = angle;
	deltax = -(this._x-250)/90;
	deltay = -(this._y-175)/90;
	map._x += deltax;
	map._y += deltay;
	if (map._x>1000) {
		map._x = 1000;
	}
	if (map._x<-500) {
		map._x = -500;
	}
	if (map._y>1000) {
		map._x = 1000;
	}
	if (map._y<-650) {
		map._y = -650;
	}
 
};

Being an old experiment, I won’t comment it, but someday I am going to release a newer, released version.

Here it is the source code for you to enjoy.

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 4.17 out of 5)
Loading ... Loading ...
Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 7 comments

  1. V34

    on June 4, 2007 at 3:53 am

    Thanks a lot.
    Looking forward for the newer version.

    I think it’s very impressive you’re doing almost all your project open source.

    - V34

  2. And Mar

    on June 13, 2007 at 4:49 am

    Hi this is a sample image used in this example enjoy

  3. Nat Panviroj

    on September 17, 2007 at 5:56 am

    Thanks a lot.

  4. André Scofano

    on November 9, 2008 at 4:24 am

    Very nice of you putting this experiment on your site. Very simple, easy to understand and i can imagine practical applications.

    Just a question, in line 28, wouldn’t be “.y” insted of “.x”?

    Thanks a lot.

  5. mar

    on November 11, 2008 at 9:41 pm

    excelent!! como puedo lograr ke avance mas rapido?

  6. bordako

    on April 16, 2009 at 7:27 am

    Es buenisimo, lo que estaba buscando; me super sirve!…

    Gracias!

  7. carol

    on January 9, 2010 at 2:26 pm

    Gracias! El tutorial es perfecto….
    Para hacerlo ir mas rapido, tienes que cambiar el numero despues de el (/) en el as.
    Si el numero es menor, va as rapido.
    Yo use 15:
    this._rotation = angle;
    deltax = -(this._x-250)/15;
    deltay = -(this._y-175)/15;