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.

Interesting note is the presence of two global variables that indicate the size of the original movie. These are enhanced by the presence of the component in the library! The class StageExt, in fact, required at the time of its creation, the passage of the movie size (carry a piece of code):

1
2
3
4
5
6
7
8
9
10
11
] [...]
w : Number , h : Number ) { StageExt function (w: Number , h: Number ) {
"StageExt::constructor" ) ; trace ("StageExt:: constructor");
/ /
__movieWidth = w;
__movieHeight = h;
/ /
addListener ( this ) ; Internships . addListener (this);
}

] [...]

che forniscono rispettivamente la larghezza e l'altezza del MovieClip principale. This step can be avoided by using _global.origWidth and _global.origHeight that provide the width and height of the main MovieClip. The code, therefore, can be rewritten as:

1
2
3
4
5
6
7
8
9
10
] [...]
w : Number , h : Number ) { StageExt function (w: Number , h: Number ) {
"StageExt::constructor" ) ; trace ("StageExt:: constructor");
/ /
__movieWidth = _global. origWidth;
__movieHeight = _global. origHeight;
/ /
addListener ( this ) ; Internships . addListener (this);
}
] [...]

e _global.origHeight . Or if you prefer you can review the entire method onResize() , and refer directly to _global.origWidth and _global.origHeight . However, for completeness, these two global variables are set in the file under the tree UIObjectExtensions.as mx.core.ext . They are set simply by taking the size of the startup stage, namely:

1
2
3
4
5
6
7
8
9
10
11
12
] [...]

/ / The player resizes and centers the stage. We need to know what our original
/ / Stage size is in order to know how we where centered. That the notes FMX
/ / Seems To authoring player incorrectly report the size.
_global . _origWidth == undefined ) if (_global. _origWidth == undefined)
{
. width ; _global. origWidth = Stage . width;
. height ; _global. origHeight = Stage . height;
}

] [...]

All this is obviously a special case and can not be extended as a general case. However, it is interesting to note this type of plots.

One Response to "Flash Movies resizable: Act II"

  1. November 8, 2007 Video Drive Blog »Movies resizable Flash: Act II:

    [...] Daniel Langendorf: [...]

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