Articles Tagged 'onResize'

Resizable Flash movies: Act II

Returning to the Post StageExt Class: resizable Flash movies here is an even easier to get the same effect, only if the library for our movie is at least one Flash component!

Create a symbol, a red square 100 × 100 and put it in stages resizeWindow calling. Enter in the library, not on the Stage, any component, such as a TextInput, and enter the following code in the first frame of the movie.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
managers . SystemManager ; import mx. managers. SystemManager;
/ /
scaleMode = "noscale" Internships . scaleMode = "noScale"
/ /
/ / SystemManager.init ();
( "resize" , resizeWindow ) ; SystemManager. AddEventListener ("resize", resizeWindow);
/ /
= function ( Void ) : Void { resizeWindow. resize = function (Void): Void {
Object = SystemManager . screen ; var s: Object = SystemManager. screen;
_width = s . width ; this. _width = s. width;
_height = s . height ; this. _height = s. height;
_x = Math . round ( s . x ) ; this. _x = Math . round (s. x);
_y = Math . round ( s . y ) ; this. _y = Math . round (s. y);
}
( ) ; resizeWindow. resize ();

The line 6 (SystemManager.init ();) can be omitted.

Continued ...

StageExt Class: resizable Flash movies

The technique Fullsize (hall for Fullscreen - of which more later) was, until recently, mainly used in Flash applications (RIAs), made ​​so by a more or less complex user interface, where the container (Adobe AIR , browser or standalone player) scaled by the user, forcing a repositioning of the objects making up the movie. The downsizing of the container obviously follows a drawing function, or Refresh MovieClip can reposition or redesign the runtime interface to the new size of the container. Today this technique is also used in more advanced websites or articulated, very pious rendondo attractive interface. The implementation of this technique is quite simple and essentially uses the native Flash Stage object and introduced with version MX. For its implementation here is a class that allows to obtain the coordinates of the Stage :

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/ **
*
* @ File StageExt.as
* @ Author Giovambattista Fazioli (@ g.fazioli undolog.com)
* @ Web http://www.undolog.com
* @ @ Email g.fazioli undolog.com
* /
{class StageExt
/ / Release
__release : String = "1.0" ; __release private var: String = "1.0";
/ / Properties
__movieWidth : Number = 0 ; __movieWidth private var: Number = 0;
__movieHeight : Number = 0 ; __movieHeight private var: Number = 0;
__left : Number = 0 ; __left private var: Number = 0;
__right : Number = 0 ; __right private var: Number = 0;
__top : Number = 0 ; __top private var: Number = 0;
__bottom : Number = 23 ; __bottom private var: Number = 23;
/ /
w : Number , h : Number ) { StageExt function (w: Number , h: Number ) {
"StageExt::constructor" ) ; trace ("StageExt:: constructor");
/ /
__movieWidth = w;
__movieHeight = h;
/ /
addListener ( this ) ; Internships . addListener (this);
}
/ **
* OnResize () event
* /
onResize ( ) { onResize private function () {
"StageExt::onResize " + Stage . width + ", " + Stage . height ) ; trace ("StageExt: onResize" + Stage . width + "" + Stage . height);
/ /
Number = Math . round ( Stage . width ) ; var sw: Number = Math . round ( Stage . width);
Number = Math . round ( Stage . height ) ; var sh: Number = Math . round ( Stage . height);
Number = Math . round ( this . __movieWidth ) ; var ow: Number = Math . round (this. __movieWidth);
Number = Math . round ( this . __movieHeight ) ; Oh var: Number = Math . round (this. __movieHeight);

/ / The x coordinate (top left)

__left = - Math . floor ( ( ( sw - ow ) / 2 ) ) ; this. __left = - Math . floor (((sw - ow) / 2));
__top = - Math . floor ( ( ( sh - oh ) / 2 ) ) ; this. __top = - Math . floor (((sh - h) / 2));

/ / The x coordinate (top right)

__right = Math . round ( ( sw + ow ) / 2 ) ; this. __right = Math . round ((sw + ow) / 2);

/ / The y coordinate (bottom)

__bottom = Math . round ( ( sh + oh ) / 2 ) ; this. __bottom = Math . round ((sh + O) / 2);
}
/ **
* Refresh ()
* /
Refresh ( ) { public function refresh () {
onResize ();
}
/ **
* Left - get
* /
get Left ( ) : Number { public function get Left (): Number {
__left ) ; return (__left);
}
/ **
* Top - get
* /
get Top ( ) : Number { public function get Top (): Number {
__top ) ; return (__top);
}
/ **
* Right - get
* /
get Right ( ) : Number { public function get Right (): Number {
__right ) ; return (__right);
}
/ **
* Bottom - get
* /
get Bottom ( ) : Number { public function get Bottom (): Number {
__bottom ) ; return (__bottom);
}
/ **
* MovieWidth - get / set
* /
get MovieWidth ( ) : Number { MovieWidth public function get (): Number {
__movieWidth ) ; return (__movieWidth);
}
set MovieWidth ( v : Number ) { MovieWidth public function set (v: Number ) {
__movieWidth = v;
}
/ **
* MovieHeight - get / set
* /
get MovieHeight ( ) : Number { MovieHeight public function get (): Number {
__movieHeight ) ; return (__movieHeight);
}
set MovieHeight ( v : Number ) { MovieHeight public function set (v: Number ) {
__movieHeight = v;
}
}

Continued ...