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;
}
}

Through this class becomes a simple MovieClip relocate within the Stage :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
StageExt = new StageExt ( 320 , 256 ) ; if var: = new StageExt StageExt (320, 256);
/ /
scaleMode = "noscale" ; Internships . scaleMode = "noScale";
addListener ( this ) ; Internships . addListener (this);
/ /
prototype . move = function ( x : Number , y : Number ) { MovieClip . prototype. move = function (x: Number , y: Number ) {
_x = x ; this . _y = y ; this. _x = x; this. _y = y;
}
/ /
onResize function () {
"Custom Resize " + this + " - " + se . Left ) ; trace ("Custom Resize" + this + "-" + if. Left);
/ / = Clip_mc._x se.Left;
/ / = Clip_mc._y se.Top;
se . Left , se . Top ) ; clip_mc. move (if. Left, though. Top);
}

In the example the size of the Stage originals are 320 × 256. These should be included and considered as Flash Mode noScale centers movie within the browser. ; OBJECT ed EMBED . Also in the HTML you need to set size as 100%, the opening width for the ' heght ; OBJECT and EMBED .

You should also organize the hierarchy of MovieClip in a timely manner and always consider that the position of a MovieClip diventra now "relative".

3 comments to "StageExt Class: resizable Flash movies"

  1. December 12, 2007 undolog »Blog Archive» Fullscreen Flash on the browser :

    [...] The code to set the fullscreen is very simple and takes advantage of the Stage object discussed in this blog StageExt Class: resizable Flash movies: PLAIN TEXT Actionscript: [...]

  2. December 14, 2008 Larry:

    Hello,
    a question: where should I put these 2 scripts?

    Thank you,
    G.

  3. December 15, 2008 Giovambattista Fazioli :

    @ Larry:

    Hello,
    a question: where should I put these 2 scripts? Thank you,
    G.

    The first "source" is a class that you can put anywhere in your code through education include . The second source is an example of its use. See Actionscript 3.0 for beginners: lesson # 1 on how to set up a simple project in Flash.

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL 


Stop SOPA