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 (5 votes, average: 4.00 out of 5)
Loading ... Loading ...
If you found this post useful, please consider a small donation.
» 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.

7 Responses

  1. V34 says:

    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 says:

    Hi this is a sample image used in this example enjoy

  3. Nat Panviroj says:

    Thanks a lot.

  4. André Scofano says:

    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 says:

    excelent!! como puedo lograr ke avance mas rapido?

  6. bordako says:

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

    Gracias!

  7. carol says:

    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;

Leave a Reply

flash games company