esempio SWF fullscreen con background in pattern e finestra centrata.
mainWindow e pattern sono i nomi del linkage per i movieclips in libreria contenenti un patter e una finestra da centrare ...
codice:
var createPattern:Function = function( path:Object, pattern:String ):Void {
path.createEmptyMovieClip( 'StageBackground_0', path.getNextHighestDepth() );
path['StageBackground_0'].attachMovie( pattern, pattern, path.getNextHighestDepth() );
var totX:Number = new Number( Math.ceil( Stage.width / path['StageBackground_0']._width ) );
var totY:Number = new Number( Math.ceil( Stage.height / path['StageBackground_0']._height ) );
var c:Number = new Number( 1 );
for( var a:Number = 0; a <= totY; a++ ) {
var newY:Number = ( path['StageBackground_0']._y + path['StageBackground_0']._height ) * a;
for( var b:Number = 0; b < totX; b++ ) {
var newX:Number = ( path['StageBackground_0']._x + this['StageBackground_0']._width ) * b;
var newName:String = 'StageBackground_' + String( c );
path['StageBackground_0'].duplicateMovieClip( newName, path.getNextHighestDepth() );
path[newName].attachMovie( 'pattern', 'pattern', path.getNextHighestDepth() );
path[newName]._x = newX;
path[newName]._y = newY;
c++;
}
}
}
var removePattern:Function = function( path:Object ):Void {
var c:Number = 0;
while( path['StageBackground_'+String(c)] != undefined ) {
path['StageBackground_'+String(c)].removeMovieClip();
c++;
}
}
var stageListener:Object = new Object();
stageListener.path = this;
stageListener.onResize = function():Void {
this.path.removePattern( this.path );
this.path.createPattern( this.path, 'pattern' );
this.path['main'].swapDepths( this.path.getNextHighestDepth() );
}
Stage.scaleMode = 'noScale';
Stage.align= 'TL';
Stage.addListener( stageListener );
stageListener.onResize();
this.createEmptyMovieClip( 'main', this.getNextHighestDepth() );
this['main'].attachMovie( 'mainWindow', 'mainWindow', this.getNextHighestDepth() );
this['main'].onEnterFrame = function():Void {
this._x = Math.floor( Stage.width/2 - this._width/2 );
this._y = Math.floor( Stage.height/2 - this._height/2 );
}