MovieClip
875
The movie clip coordinates were expressed using
_x
and
_y
, because those are the MovieClip
properties that you use to set the
x
and
y
values for MovieClips. However, your generic object
uses
x
and
y
without the underscore. The following code converts the
x
and
y
values to the
local coordinates:
var myPoint:Object = {x:0, y:0}; // Create your generic point object.
this.createEmptyMovieClip("myMovieClip", this.getNextHighestDepth());
myMovieClip._x = 100; // _x for movieclip x position
myMovieClip._y = 100; // _y for movieclip y position
myMovieClip.globalToLocal(myPoint);
trace ("x: " + myPoint.x); // output: -100
trace ("y: " + myPoint.y); // output: -100
You can extend the methods and event handlers of the MovieClip class by creating a subclass.
Availability:
ActionScript 1.0; Flash Player 5
Parameters
pt
:Object
- The name or identifier of an object created with the generic Object class. The
object specifies the
x
and
y
coordinates as properties.
Example
Add the following ActionScript to a FLA or AS file in the same directory as an image called
photo1.jpg:
this.createTextField("coords_txt", this.getNextHighestDepth(), 10, 10, 100,
22);
coords_txt.html = true;
coords_txt.multiline = true;
coords_txt.autoSize = true;
this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());
target_mc._x = 100;
target_mc._y = 100;
target_mc.loadMovie("photo1.jpg");
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
var point:Object = {x:_xmouse, y:_ymouse};
target_mc.globalToLocal(point);
var rowHeaders = "<b> \t</b><b>_x\t</b><b>_y</b>";
var row_1 = "_root\t"+"\t"+_ymouse;
var row_2 = "target_mc\t"+point.x+"\t"+point.y;
coords_txt.htmlText = "<textformat tabstops='[100, 150]'>";
coords_txt.ht= rowHeaders;
coords_txt.ht= row_1;
coords_txt.ht= row_2;
coords_txt.ht= "</textformat>";
};
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...