MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 894

Actionscript 2.0 language reference
Table of Contents

Advertisement

For example, if you create a movie clip that is positioned at the point (_x:100, _y:100), and
you pass a local point representing a point near the top-left corner of the movie clip (x:10,
y:10) to the
localToGlobal()
global coordinates, which in this case is (x:110, y:110). This conversion occurs because the x
and y coordinates are now expressed relative to the top-left corner of the Stage rather than the
top-left corner of your movie clip.
The movie clip coordinates were expressed using
properties that you use to set the x and y values for MovieClips. However, your generic object
uses
and
without the underscore. The following code converts the x and y coordinates to
x
y
global coordinates:
var myPoint:Object = {x:10, y:10}; // 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.localToGlobal(myPoint);
trace ("x: " + myPoint.x); // output: 110
trace ("y: " + myPoint.y); // output: 110
You can extend the methods and event handlers of the MovieClip class by creating a subclass.
Availability: ActionScript 1.0; Flash Player 5
Parameters
- The name or identifier of an object created with the Object class, specifying the
pt:Object
x and y coordinates as properties.
Example
The following example converts x and y coordinates of the
(local) coordinates to the Stage (global) coordinates. The center point of the movie clip is
reflected after you click and drag the instance.
this.createTextField("point_txt", this.getNextHighestDepth(), 0, 0, 100,
22);
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
var point:Object = {x:my_mc._width/2, y:my_mc._height/2};
my_mc.localToGlobal(point);
point_txt.text = "x:"+point.x+", y:"+point.y;
};
Mouse.addListener(mouseListener);
my_mc.onPress = function() {
this.startDrag();
};
my_mc.onRelease = function() {
894
ActionScript classes
method, the method should convert the x and y values to
and
_x
, because those are the MovieClip
_y
object, from the movie clip's
my_mc

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF