ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Hide Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes

Language Reference only
Filters: AIR 32.0 and earlier, Flash Player 32.0 and earlier, Flash Lite 4
Flex 4.6 and earlier, Flash Pro CS6 and earlier
Hide Filters
flash.geom 

Matrix  - AS3

Packagesx

Top Level
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

Language Elements

Global Constants
Global Functions
Operators
Statements, Keywords & Directives
Special Types

Appendixes

What's New
Compiler Errors
Compiler Warnings
Run-Time Errors
Migrating to ActionScript 3
Supported Character Sets
MXML Only Tags
Motion XML Elements
Timed Text Tags
List of deprecated elements
Accessibility Implementation Constants
How to Use ActionScript Examples
Legal notices
Packageflash.geom
Classpublic class Matrix
InheritanceMatrix Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

The Matrix class represents a transformation matrix that determines how to map points from one coordinate space to another. You can perform various graphical transformations on a display object by setting the properties of a Matrix object, applying that Matrix object to the matrix property of a Transform object, and then applying that Transform object as the transform property of the display object. These transformation functions include translation (x and y repositioning), rotation, scaling, and skewing.

Together these types of transformations are known as affine transformations. Affine transformations preserve the straightness of lines while transforming, so that parallel lines stay parallel.

To apply a transformation matrix to a display object, you create a Transform object, set its matrix property to the transformation matrix, and then set the transform property of the display object to the Transform object. Matrix objects are also used as parameters of some methods, such as the following:

  • The draw() method of a BitmapData object
  • The beginBitmapFill() method, beginGradientFill() method, or lineGradientStyle() method of a Graphics object

A transformation matrix object is a 3 x 3 matrix with the following contents:

Matrix class properties in matrix notation

In traditional transformation matrixes, the u, v, and w properties provide extra capabilities. The Matrix class can only operate in two-dimensional space, so it always assumes that the property values u and v are 0.0, and that the property value w is 1.0. The effective values of the matrix are as follows:

Matrix class properties in matrix notation showing    assumed values for u, v, and w

You can get and set the values of all six of the other properties in a Matrix object: a, b, c, d, tx, and ty.

The Matrix class supports the four major types of transformations: translation, scaling, rotation, and skewing. You can set three of these transformations by using specialized methods, as described in the following table:

TransformationMethodMatrix valuesDisplay resultDescription
Translation (displacement) translate(tx, ty) Matrix notation of translate method parameters Illustration of translate method effects Moves the image tx pixels to the right and ty pixels down.
Scaling scale(sx, sy) Matrix notation of scale method parameters Illustration of scale method effects Resizes the image, multiplying the location of each pixel by sx on the x axis and sy on the y axis.
Rotation rotate(q) Matrix notation of rotate method properties Illustration of rotate method effects Rotates the image by an angle q, which is measured in radians.
Skewing or shearing None; must set the properties b and c Matrix notation of skew function properties Illustration of skew function effects Progressively slides the image in a direction parallel to the x or y axis. The b property of the Matrix object represents the tangent of the skew angle along the y axis; the c property of the Matrix object represents the tangent of the skew angle along the x axis.

Each transformation function alters the current matrix properties so that you can effectively combine multiple transformations. To do this, you call more than one transformation function before applying the matrix to its display object target (by using the transform property of that display object).

Use the new Matrix() constructor to create a Matrix object before you can call the methods of the Matrix object.

View the examples

Learn more

Related API Elements



Public Properties
 PropertyDefined By
  a : Number
The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
Matrix
  b : Number
The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
Matrix
  c : Number
The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
Matrix
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  d : Number
The value that affects the positioning of pixels along the y axis when scaling or rotating an image.
Matrix
  tx : Number
The distance by which to translate each point along the x axis.
Matrix
  ty : Number
The distance by which to translate each point along the y axis.
Matrix
Public Methods
 MethodDefined By
  
Matrix(a:Number = 1, b:Number = 0, c:Number = 0, d:Number = 1, tx:Number = 0, ty:Number = 0)
Creates a new Matrix object with the specified parameters.
Matrix
  
Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object.
Matrix
  
Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two.
Matrix
  
copyColumnFrom(column:uint, vector3D:Vector3D):void
Copies a Vector3D object into specific column of the calling Matrix3D object.
Matrix
  
copyColumnTo(column:uint, vector3D:Vector3D):void
Copies specific column of the calling Matrix object into the Vector3D object.
Matrix
  
copyFrom(sourceMatrix:Matrix):void
Copies all of the matrix data from the source Point object into the calling Matrix object.
Matrix
  
copyRowFrom(row:uint, vector3D:Vector3D):void
Copies a Vector3D object into specific row of the calling Matrix object.
Matrix
  
copyRowTo(row:uint, vector3D:Vector3D):void
Copies specific row of the calling Matrix object into the Vector3D object.
Matrix
  
createBox(scaleX:Number, scaleY:Number, rotation:Number = 0, tx:Number = 0, ty:Number = 0):void
Includes parameters for scaling, rotation, and translation.
Matrix
  
createGradientBox(width:Number, height:Number, rotation:Number = 0, tx:Number = 0, ty:Number = 0):void
Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class.
Matrix
  
Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs.
Matrix
 Inherited
Indicates whether an object has a specified property defined.
Object
  
Sets each matrix property to a value that causes a null transformation.
Matrix
  
Performs the opposite transformation of the original matrix.
Matrix
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
Applies a rotation transformation to the Matrix object.
Matrix
  
Applies a scaling transformation to the matrix.
Matrix
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
setTo(aa:Number, ba:Number, ca:Number, da:Number, txa:Number, tya:Number):void
Sets the members of Matrix to the specified values
Matrix
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
  
Returns a text value listing the properties of the Matrix object.
Matrix
  
Returns the result of applying the geometric transformation represented by the Matrix object to the specified point.
Matrix
  
Translates the matrix along the x and y axes, as specified by the dx and dy parameters.
Matrix
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail

a

property
public var a:Number

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

The value that affects the positioning of pixels along the x axis when scaling or rotating an image.


Example  ( How to use this example )
The following example creates the Matrix object myMatrix and sets its a value.
import flash.geom.Matrix;

var myMatrix:Matrix = new Matrix();
trace(myMatrix.a);  // 1

myMatrix.a = 2;
trace(myMatrix.a);  // 2

b

property 
public var b:Number

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

The value that affects the positioning of pixels along the y axis when rotating or skewing an image.


Example  ( How to use this example )
The following example creates the Matrix object myMatrix and sets its b value.
import flash.geom.Matrix;
 
var myMatrix:Matrix = new Matrix();
trace(myMatrix.b);  // 0

var degrees:Number = 30;
var radians:Number = (degrees/180) * Math.PI;
myMatrix.b = Math.tan(radians);
trace(myMatrix.b);  // 0.5773502691896257

c

property 
public var c:Number

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

The value that affects the positioning of pixels along the x axis when rotating or skewing an image.


Example  ( How to use this example )
The following example creates the Matrix object myMatrix and sets its c value.
import flash.geom.Matrix;

var myMatrix:Matrix = new Matrix();
trace(myMatrix.c);  // 0

var degrees:Number = 30;
var radians:Number = (degrees/180) * Math.PI;
myMatrix.c = Math.tan(radians);
trace(myMatrix.c);  // 0.5773502691896257

d

property 
public var d:Number

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

The value that affects the positioning of pixels along the y axis when scaling or rotating an image.


Example  ( How to use this example )
The following example creates the Matrix object myMatrix and sets its d value.
import flash.geom.Matrix;

var myMatrix:Matrix = new Matrix();
trace(myMatrix.d);  // 1

myMatrix.d = 2;
trace(myMatrix.d);  // 2

tx

property 
public var tx:Number

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

The distance by which to translate each point along the x axis.


Example  ( How to use this example )
The following example creates the Matrix object myMatrix and sets its tx value.
import flash.geom.Matrix;

var myMatrix:Matrix = new Matrix();
trace(myMatrix.tx);  // 0

myMatrix.tx = 50;  // 50
trace(myMatrix.tx);

ty

property 
public var ty:Number

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

The distance by which to translate each point along the y axis.


Example  ( How to use this example )
The following example creates the Matrix object myMatrix and sets its ty value.
import flash.geom.Matrix;

var myMatrix:Matrix = new Matrix();
trace(myMatrix.ty);  // 0

myMatrix.ty = 50;
trace(myMatrix.ty);  // 50
Constructor Detail

Matrix

()Constructor
public function Matrix(a:Number = 1, b:Number = 0, c:Number = 0, d:Number = 1, tx:Number = 0, ty:Number = 0)

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Creates a new Matrix object with the specified parameters. In matrix notation, the properties are organized like this:

Matrix class properties in matrix notation showing assumed values for u, v, and w

If you do not provide any parameters to the new Matrix() constructor, it creates an identity matrix with the following values:

a = 1
b = 0
c = 0
d = 1
tx = 0
ty = 0

In matrix notation, the identity matrix looks like this:

Matrix class properties in matrix notation

Parameters
a:Number (default = 1) — The value that affects the positioning of pixels along the x axis when scaling or rotating an image.
 
b:Number (default = 0) — The value that affects the positioning of pixels along the y axis when rotating or skewing an image.
 
c:Number (default = 0) — The value that affects the positioning of pixels along the x axis when rotating or skewing an image.
 
d:Number (default = 1) — The value that affects the positioning of pixels along the y axis when scaling or rotating an image..
 
tx:Number (default = 0) — The distance by which to translate each point along the x axis.
 
ty:Number (default = 0) — The distance by which to translate each point along the y axis.

Example  ( How to use this example )

The following example creates matrix_1 by sending no parameters to the Matrix() constructor and matrix_2 by sending parameters to it. Notice that matrix_1, which was created with no parameters, results in an identity matrix with the values a=1, b=0, c=0, d=1, tx=0, ty=0.
import flash.geom.Matrix;

var matrix_1:Matrix = new Matrix();
trace(matrix_1);  // (a=1, b=0, c=0, d=1, tx=0, ty=0)

var matrix_2:Matrix = new Matrix(1, 2, 3, 4, 5, 6);
trace(matrix_2);  // (a=1, b=2, c=3, d=4, tx=5, ty=6)
Method Detail

clone

()method
public function clone():Matrix

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object.

Returns
Matrix — A Matrix object.

concat

()method 
public function concat(m:Matrix):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two. In mathematical terms, concatenating two matrixes is the same as combining them using matrix multiplication.

For example, if matrix m1 scales an object by a factor of four, and matrix m2 rotates an object by 1.5707963267949 radians (Math.PI/2), then m1.concat(m2) transforms m1 into a matrix that scales an object by a factor of four and rotates the object by Math.PI/2 radians.

This method replaces the source matrix with the concatenated matrix. If you want to concatenate two matrixes without altering either of the two source matrixes, first copy the source matrix by using the clone() method, as shown in the Class Examples section.

Parameters

m:Matrix — The matrix to be concatenated to the source matrix.

copyColumnFrom

()method 
public function copyColumnFrom(column:uint, vector3D:Vector3D):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 11, AIR 3.0, Flash Lite 4

Copies a Vector3D object into specific column of the calling Matrix3D object.

Parameters

column:uint — The column from which to copy the data from.
 
vector3D:Vector3D — The Vector3D object from which to copy the data.

copyColumnTo

()method 
public function copyColumnTo(column:uint, vector3D:Vector3D):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 11, AIR 3.0, Flash Lite 4

Copies specific column of the calling Matrix object into the Vector3D object. The w element of the Vector3D object will not be changed.

Parameters

column:uint — The column from which to copy the data from.
 
vector3D:Vector3D — The Vector3D object from which to copy the data.

copyFrom

()method 
public function copyFrom(sourceMatrix:Matrix):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 11, AIR 3.0, Flash Lite 4

Copies all of the matrix data from the source Point object into the calling Matrix object.

Parameters

sourceMatrix:Matrix — The Matrix object from which to copy the data.

copyRowFrom

()method 
public function copyRowFrom(row:uint, vector3D:Vector3D):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 11, AIR 3.0, Flash Lite 4

Copies a Vector3D object into specific row of the calling Matrix object.

Parameters

row:uint — The row from which to copy the data from.
 
vector3D:Vector3D — The Vector3D object from which to copy the data.

copyRowTo

()method 
public function copyRowTo(row:uint, vector3D:Vector3D):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 11, AIR 3.0, Flash Lite 4

Copies specific row of the calling Matrix object into the Vector3D object. The w element of the Vector3D object will not be changed.

Parameters

row:uint — The row from which to copy the data from.
 
vector3D:Vector3D — The Vector3D object from which to copy the data.

createBox

()method 
public function createBox(scaleX:Number, scaleY:Number, rotation:Number = 0, tx:Number = 0, ty:Number = 0):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters.

Using the createBox() method lets you obtain the same matrix as you would if you applied the identity(), rotate(), scale(), and translate() methods in succession. For example, mat1.createBox(2,2,Math.PI/4, 100, 100) has the same effect as the following:

     import flash.geom.Matrix;
     
     var mat1:Matrix = new Matrix();
     mat1.identity();
     mat1.rotate(Math.PI/4);
     mat1.scale(2,2);
     mat1.translate(10,20);
     

Parameters

scaleX:Number — The factor by which to scale horizontally.
 
scaleY:Number — The factor by which scale vertically.
 
rotation:Number (default = 0) — The amount to rotate, in radians.
 
tx:Number (default = 0) — The number of pixels to translate (move) to the right along the x axis.
 
ty:Number (default = 0) — The number of pixels to translate (move) down along the y axis.

More examples

Related API Elements


Example  ( How to use this example )

The following example sets the x scale, y scale, rotation, x location, and y location of myMatrix by calling its createBox() method.
package
{
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.geom.Matrix;
    import flash.geom.Transform;
    
    public class Matrix_createBox extends Sprite
    {
        public function Matrix_createBox()
        {
             var myMatrix:Matrix = new Matrix();
             trace(myMatrix.toString());  // (a=1, b=0, c=0, d=1, tx=0, ty=0)
             
             myMatrix.createBox(1, 2, Math.PI/4, 50, 100);
             trace(myMatrix.toString());  
             // (a=0.7071067811865476, b=1.414213562373095, c=-0.7071067811865475, 
             //  d=1.4142135623730951, tx=50, ty=100)
             
             var rectangleShape:Shape = createRectangle(20, 80, 0xFF0000);   
             addChild(rectangleShape);
              
             var rectangleTrans:Transform = new Transform(rectangleShape);
             rectangleTrans.matrix = myMatrix;
        }
        
        public function createRectangle(w:Number, h:Number, color:Number):Shape 
        {
            var rect:Shape = new Shape();
            rect.graphics.beginFill(color);
            rect.graphics.drawRect(0, 0, w, h);
            addChild(rect);
            return rect;
        }
    }
}

createGradientBox

()method 
public function createGradientBox(width:Number, height:Number, rotation:Number = 0, tx:Number = 0, ty:Number = 0):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class. Width and height are scaled to a scaleX/scaleY pair and the tx/ty values are offset by half the width and height.

For example, consider a gradient with the following characteristics:

  • GradientType.LINEAR
  • Two colors, green and blue, with the ratios array set to [0, 255]
  • SpreadMethod.PAD
  • InterpolationMethod.LINEAR_RGB

The following illustrations show gradients in which the matrix was defined using the createGradientBox() method with different parameter settings:

createGradientBox() settingsResulting gradient
width = 25;
     height = 25; 
     rotation = 0; 
     tx = 0; 
     ty = 0;
resulting linear gradient
width = 25; 
     height = 25; 
     rotation = 0; 
     tx = 25; 
     ty = 0;
resulting linear gradient
width = 50; 
     height = 50; 
     rotation = 0; 
     tx = 0; 
     ty = 0;
resulting linear gradient
width = 50;
     height = 50; 
     rotation = Math.PI / 4; // 45 degrees
     tx = 0; 
     ty = 0;
resulting linear gradient

Parameters

width:Number — The width of the gradient box.
 
height:Number — The height of the gradient box.
 
rotation:Number (default = 0) — The amount to rotate, in radians.
 
tx:Number (default = 0) — The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width parameter.
 
ty:Number (default = 0) — The distance, in pixels, to translate down along the y axis. This value is offset by half of the height parameter.

More examples

Related API Elements


Example  ( How to use this example )

The following example sets the x scale, y scale, rotation, x location, and y location of myMatrix by calling its createBox() method.
package
{
    import flash.display.GradientType;
    import flash.display.Sprite;
    import flash.geom.Matrix;
    
    public class Matrix_createGradientBox extends Sprite
    {
        public function Matrix_createGradientBox()
        {
             var myMatrix:Matrix = new Matrix();
             trace(myMatrix.toString());          // (a=1, b=0, c=0, d=1, tx=0, ty=0)
             
             myMatrix.createGradientBox(200, 200, 0, 50, 50);
             trace(myMatrix.toString());          // (a=0.1220703125, b=0, c=0, d=0.1220703125, tx=150, ty=150)
             
             var colors:Array = [0xFF0000, 0x0000FF];
             var alphas:Array = [100, 100];
             var ratios:Array = [0, 0xFF];
             
             this.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, myMatrix);
             this.graphics.drawRect(0, 0, 300, 200);
        }
    }
}

deltaTransformPoint

()method 
public function deltaTransformPoint(point:Point):Point

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty.

Parameters

point:Point — The point for which you want to get the result of the matrix transformation.

Returns
Point — The point resulting from applying the matrix transformation.

identity

()method 
public function identity():void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Sets each matrix property to a value that causes a null transformation. An object transformed by applying an identity matrix will be identical to the original.

After calling the identity() method, the resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0.

In matrix notation, the identity matrix looks like this:

Matrix class properties in matrix notation

invert

()method 
public function invert():void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to undo the transformation performed when applying the original matrix.


Example  ( How to use this example )

The following example creates a halfScaleMatrix by calling the invert() method of doubleScaleMatrix. It then demonstrates that the two are Matrix inverses of one another -- matrices that undo any transformations performed by the other -- by creating originalAndInverseMatrix which is equal to noScaleMatrix.
package
{
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.geom.Matrix;
    import flash.geom.Transform;
    
    public class Matrix_invert extends Sprite
    {
        public function Matrix_invert()
        {
            var rect0:Shape = createRectangle(20, 80, 0xFF0000);   
            var rect1:Shape = createRectangle(20, 80, 0x00FF00);   
            var rect2:Shape = createRectangle(20, 80, 0x0000FF);
            var rect3:Shape = createRectangle(20, 80, 0x000000);
            
            var trans0:Transform = new Transform(rect0);
            var trans1:Transform = new Transform(rect1);
            var trans2:Transform = new Transform(rect2);
            var trans3:Transform = new Transform(rect3);
             
            var doubleScaleMatrix:Matrix = new Matrix(2, 0, 0, 2, 0, 0);
            trans0.matrix = doubleScaleMatrix;
            trace(doubleScaleMatrix.toString());  // (a=2, b=0, c=0, d=2, tx=0, ty=0)
             
            var noScaleMatrix:Matrix = new Matrix(1, 0, 0, 1, 0, 0);
            trans1.matrix = noScaleMatrix;
            rect1.x = 50;
            trace(noScaleMatrix.toString());  // (a=1, b=0, c=0, d=1, tx=0, ty=0)
             
            var halfScaleMatrix:Matrix = doubleScaleMatrix.clone();
            halfScaleMatrix.invert();
            trans2.matrix = halfScaleMatrix;
            rect2.x = 100;
            trace(halfScaleMatrix.toString());  // (a=0.5, b=0, c=0, d=0.5, tx=0, ty=0)
             
            var originalAndInverseMatrix:Matrix = doubleScaleMatrix.clone();
            originalAndInverseMatrix.concat(halfScaleMatrix);
            trans3.matrix = originalAndInverseMatrix;
            rect3.x = 150;
            trace(originalAndInverseMatrix.toString());  // (a=1, b=0, c=0, d=1, tx=0, ty=0)            
        }
        
        public function createRectangle(w:Number, h:Number, color:Number):Shape 
        {
            var rect:Shape = new Shape();
            rect.graphics.beginFill(color);
            rect.graphics.drawRect(0, 0, w, h);
            addChild(rect);
            return rect;
        }
    }
}

rotate

()method 
public function rotate(angle:Number):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Applies a rotation transformation to the Matrix object.

The rotate() method alters the a, b, c, and d properties of the Matrix object. In matrix notation, this is the same as concatenating the current matrix with the following:

Matrix notation of scale method parameters

Parameters

angle:Number — The rotation angle in radians.

More examples

scale

()method 
public function scale(sx:Number, sy:Number):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Applies a scaling transformation to the matrix. The x axis is multiplied by sx, and the y axis it is multiplied by sy.

The scale() method alters the a and d properties of the Matrix object. In matrix notation, this is the same as concatenating the current matrix with the following matrix:

Matrix notation of scale method parameters

Parameters

sx:Number — A multiplier used to scale the object along the x axis.
 
sy:Number — A multiplier used to scale the object along the y axis.

More examples

setTo

()method 
public function setTo(aa:Number, ba:Number, ca:Number, da:Number, txa:Number, tya:Number):void

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 11, AIR 3.0, Flash Lite 4

Sets the members of Matrix to the specified values

Parameters

aa:Number — the values to set the matrix to.
 
ba:Number
 
ca:Number
 
da:Number
 
txa:Number
 
tya:Number

toString

()method 
public function toString():String

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Returns a text value listing the properties of the Matrix object.

Returns
String — A string containing the values of the properties of the Matrix object: a, b, c, d, tx, and ty.

transformPoint

()method 
public function transformPoint(point:Point):Point

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Returns the result of applying the geometric transformation represented by the Matrix object to the specified point.

Parameters

point:Point — The point for which you want to get the result of the Matrix transformation.

Returns
Point — The point resulting from applying the Matrix transformation.

translate

()method 
public function translate(dx:Number, dy:Number):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0, Flash Player 9, Flash Lite 4

Translates the matrix along the x and y axes, as specified by the dx and dy parameters.

Parameters

dx:Number — The amount of movement along the x axis to the right, in pixels.
 
dy:Number — The amount of movement down along the y axis, in pixels.

More examples

MatrixExample.as

The following example uses the MatrixExample class to show how a large gradient-filled square can be created. This is accomplished with the following steps:
  1. The application creates a new Matrix object myMatrix, and it uses the trace() method to output the default property values for the myMatrix object.
  2. The application calls the createGradientBox() with the width and height parameters set to 200 pixels, no rotation, and the distance to translate along the x and y axes set to 50 pixels.
  3. The application prints the myMatrix object again to show the change after calling createGradientBox().
  4. The application sets up three variables to control how the gradient box is filled:
    • colors: Sets the gradient colors to range between solid red and solid blue.
    • alphas: Sets the opacity to solid.
    • ratios: Sets the distribution of the colors to be equal for both red and blue.
  5. The application calls the graphics method beginGradientFill(), which operates on the myMatrix object, and it calls the lineTo() method, resulting in the gradient-filled box.
package {
    import flash.geom.Matrix;
    import flash.display.Sprite;
    import flash.display.GradientType;

    public class MatrixExample extends Sprite {

        public function MatrixExample() {
            var myMatrix:Matrix = new Matrix();
            trace(myMatrix.toString());    // (a=1, b=0, c=0, d=1, tx=0, ty=0)

            myMatrix.createGradientBox(200, 200, 0, 50, 50);
            trace(myMatrix.toString());    // (a=0.1220703125, b=0, c=0, d=0.1220703125, tx=150, ty=150)

            var colors:Array = [0xFF0000, 0x0000FF];
            var alphas:Array = [1, 1];
            var ratios:Array = [0, 0xFF];
            graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, myMatrix);
            graphics.lineTo(0, 300);
            graphics.lineTo(300, 300);
            graphics.lineTo(300, 0);
            graphics.lineTo(0, 0);
        }
    }
}