1/*****************************************************
2*
3*  Copyright 2009 Adobe Systems Incorporated.  All Rights Reserved.
4*
5*****************************************************
6*  The contents of this file are subject to the Mozilla Public License
7*  Version 1.1 (the "License"); you may not use this file except in
8*  compliance with the License. You may obtain a copy of the License at
9*  http://www.mozilla.org/MPL/
10*
11*  Software distributed under the License is distributed on an "AS IS"
12*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
13*  License for the specific language governing rights and limitations
14*  under the License.
15*
16*
17*  The Initial Developer of the Original Code is Adobe Systems Incorporated.
18*  Portions created by Adobe Systems Incorporated are Copyright (C) 2009 Adobe Systems
19*  Incorporated. All Rights Reserved.
20*
21*****************************************************/
22package org.osmf.events
23{
24	import flash.display.DisplayObject;
25	import flash.events.Event;
26
27	/**
28	 * A DisplayObjectEvent is dispatched when the properties of a DisplayObjectTrait change.
29	 *
30	 *  @langversion 3.0
31	 *  @playerversion Flash 10
32	 *  @playerversion AIR 1.5
33	 *  @productversion OSMF 1.0
34	 */
35	public class DisplayObjectEvent extends Event
36	{
37		/**
38		 * The DisplayObjectEvent.DISPLAY_OBJECT_CHANGE constant defines the value
39		 * of the type property of the event object for a displayObjectChange
40		 * event.
41		 *
42		 * @eventType DISPLAY_OBJECT_CHANGE
43		 *
44		 *  @langversion 3.0
45		 *  @playerversion Flash 10
46		 *  @playerversion AIR 1.5
47		 *  @productversion OSMF 1.0
48		 */
49		public static const DISPLAY_OBJECT_CHANGE:String = "displayObjectChange";
50
51		/**
52		 * The DisplayObjectEvent.MEDIA_SIZE_CHANGE constant defines the value
53		 * of the type property of the event object for a mediaSizeChange
54		 * event.
55		 *
56		 * @eventType MEDIA_SIZE_CHANGE
57		 *
58		 *  @langversion 3.0
59		 *  @playerversion Flash 10
60		 *  @playerversion AIR 1.5
61		 *  @productversion OSMF 1.0
62		 */
63		public static const MEDIA_SIZE_CHANGE:String = "mediaSizeChange";
64
65		/**
66		 * Constructor.
67		 *
68		 * @param type Event type.
69		 * @param bubbles Specifies whether the event can bubble up the display list hierarchy.
70 		 * @param cancelable Specifies whether the behavior associated with the event can be prevented.
71		 * @param oldDisplayObject Previous view.
72		 * @param newDisplayObject New view.
73		 * @param oldWidth Previous width.
74		 * @param oldHeight Previous height.
75		 * @param newWidth New width.
76		 * @param newHeight New height.
77		 *
78		 *  @langversion 3.0
79		 *  @playerversion Flash 10
80		 *  @playerversion AIR 1.5
81		 *  @productversion OSMF 1.0
82		 */
83		public function DisplayObjectEvent
84			( type:String
85			, bubbles:Boolean=false
86			, cancelable:Boolean=false
87			, oldDisplayObject:DisplayObject=null
88			, newDisplayObject:DisplayObject=null
89			, oldWidth:Number=NaN
90			, oldHeight:Number=NaN
91			, newWidth:Number=NaN
92			, newHeight:Number=NaN
93			)
94		{
95			super(type, bubbles, cancelable);
96
97			_oldDisplayObject = oldDisplayObject;
98			_newDisplayObject = newDisplayObject;
99			_oldWidth = oldWidth;
100			_oldHeight = oldHeight;
101			_newWidth = newWidth;
102			_newHeight = newHeight;
103		}
104
105		/**
106		 * Old value of <code>view</code> before it was changed.
107		 *
108		 *  @langversion 3.0
109		 *  @playerversion Flash 10
110		 *  @playerversion AIR 1.5
111		 *  @productversion OSMF 1.0
112		 */
113		public function get oldDisplayObject():DisplayObject
114		{
115			return _oldDisplayObject;
116		}
117
118		/**
119		 * New value of <code>view</code> resulting from this change.
120		 *
121		 *  @langversion 3.0
122		 *  @playerversion Flash 10
123		 *  @playerversion AIR 1.5
124		 *  @productversion OSMF 1.0
125		 */
126		public function get newDisplayObject():DisplayObject
127		{
128			return _newDisplayObject;
129		}
130
131		/**
132		 * Old value of <code>width</code> before it was changed.
133		 *
134		 *  @langversion 3.0
135		 *  @playerversion Flash 10
136		 *  @playerversion AIR 1.5
137		 *  @productversion OSMF 1.0
138		 */
139		public function get oldWidth():Number
140		{
141			return _oldWidth;
142		}
143
144		/**
145		 * Old value of <code>height</code> before it was changed.
146		 *
147		 *  @langversion 3.0
148		 *  @playerversion Flash 10
149		 *  @playerversion AIR 1.5
150		 *  @productversion OSMF 1.0
151		 */
152		public function get oldHeight():Number
153		{
154			return _oldHeight;
155		}
156
157		/**
158		 * New value of <code>width</code> resulting from this change.
159		 *
160		 *  @langversion 3.0
161		 *  @playerversion Flash 10
162		 *  @playerversion AIR 1.5
163		 *  @productversion OSMF 1.0
164		 */
165		public function get newWidth():Number
166		{
167			return _newWidth;
168		}
169
170		/**
171		 * New value of <code>height</code> resulting from this change.
172		 *
173		 *  @langversion 3.0
174		 *  @playerversion Flash 10
175		 *  @playerversion AIR 1.5
176		 *  @productversion OSMF 1.0
177		 */
178		public function get newHeight():Number
179		{
180			return _newHeight;
181		}
182
183		/**
184		 * @private
185		 */
186		override public function clone():Event
187		{
188			return new DisplayObjectEvent(type, bubbles, cancelable, _oldDisplayObject, _newDisplayObject, _oldWidth, _oldHeight, _newWidth, _newHeight);
189		}
190
191		// Internals
192		//
193
194		private var _oldDisplayObject:DisplayObject;
195		private var _newDisplayObject:DisplayObject;
196		private var _oldWidth:Number;
197		private var _oldHeight:Number;
198		private var _newWidth:Number;
199		private var _newHeight:Number;
200	}
201}