Movies resizable Flash: Act II

Thursday, November 8, 2007

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

Create a symbol, a red square 100x100 and put it in the stage calling resizeWindow. Fill in the Library, the Stage, any component, such as a TextInput, and write the following code in the first frame of the movie.

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

Line 6 (SystemManager.init ();) can be omitted.

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

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

This step can be avoided by using _global.origWidth and _global.origHeight providing the width and height of the main MovieClip. The code, therefore, can be rewritten as:

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

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 Stage at startup, namely:

ActionScript
  1. ] [...]
  2. / / The player Resizes and centers the stage. We need to know what our original
  3. / / Stage size is in order to know how we were centered. Note that the FMX
  4. / / Authoring player seems to incorrectly report the size.
  5. _global . _origWidth == undefined ) if (_global. _origWidth == undefined)
  6. (
  7. . width ; _global. origWidth = Stage. width;
  8. . height ; _global. origHeight = Stage. height;
  9. )
  10. ] [...]

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 entanglement.

Related Post

Was this article helpful?: Per nientePocoAbbastanzaMoltoMoltissimo
Loading ... Loading ...

One comment to "Movies resizable Flash: Act II

  1. getAvatar 1.0

Leave a comment

TAG XHTML PERMISSIONS: <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 [as][/as]           // Actionscript [css][/css]         // CSS Style Sheet [html][/html]       // HTML [js][/js]           // Javascript [objc][/objc]       // Objective-C [php][/php]         // PHP [sql][/sql]         // SQL