La tecnica del Fullsize (anticamera per il Fullscreen - di cui parleremo in seguito) era, fino a poco tempo fa, utilizzata soprattutto nelle applicazioni Flash (RIA), composte quindi da una più o meno complessa interfaccia utente, dove il contenitore (Adobe AIR, Browser o il Player stand-alone) ridimensionato dall'utente, costringeva ad un riposizionamento degli oggetti componenti il filmato. Al ridimensionamento del contenitore segue ovviamente una funzione di disegno o Refresh in grado di riposizionare i MovieClip o ridisegnare runtime l'interfaccia in base alle nuove dimensioni del contenitore. Oggi questa tecnica è utilizzata anche nei siti web più avanzati o articolati, rendondo l'interfaccia estremamente piì accattivante. L'implementazione di questa tecnica è abbastanza semplice e sfrutta sostanzialmente l'oggetto Stage nativo di Flash e introdotto con la versione MX. Per la sua implementazione ecco una classe che permette di ottenere le coordinate dell'area dello Stage:
Actionscript:
-
/**
-
*
-
* @file StageExt.as
-
* @author Giovambattista Fazioli (g.fazioli@undolog.com)
-
* @web http://www.undolog.com
-
* @email g.fazioli@undolog.com
-
*/
-
class StageExt {
-
// release
-
private var __release :String = "1.0";
-
// properties
-
private var __movieWidth :Number = 0;
-
private var __movieHeight :Number = 0;
-
private var __left :Number = 0;
-
private var __right :Number = 0;
-
private var __top :Number = 0;
-
private var __bottom :Number = 23;
-
//
-
function StageExt(w:Number, h:Number) {
-
trace("StageExt::constructor");
-
//
-
__movieWidth = w;
-
__movieHeight = h;
-
//
-
Stage.addListener(this);
-
}
-
/**
-
* onResize() event
-
*/
-
private function onResize() {
-
trace("StageExt::onResize " + Stage.width + ", " + Stage.height);
-
//
-
var sw:Number = Math.round(Stage.width);
-
var sh:Number = Math.round(Stage.height);
-
var ow:Number = Math.round(this.__movieWidth);
-
var oh:Number = Math.round(this.__movieHeight);
-
-
// La coordinata x (in alto a sinistra)
-
-
this.__left = -Math.floor(((sw - ow) / 2));
-
this.__top = -Math.floor(((sh - oh) / 2));
-
-
// La coordinata x (in alto a destra)
-
-
this.__right = Math.round((sw + ow) / 2);
-
-
// La coordinata y (in basso)
-
-
this.__bottom = Math.round((sh + oh) / 2);
-
}
-
/**
-
* Refresh()
-
*/
-
public function Refresh() {
-
onResize();
-
}
-
/**
-
* Left - get
-
*/
-
public function get Left():Number {
-
return (__left);
-
}
-
/**
-
* Top - get
-
*/
-
public function get Top():Number {
-
return (__top);
-
}
-
/**
-
* Right - get
-
*/
-
public function get Right():Number {
-
return (__right);
-
}
-
/**
-
* Bottom - get
-
*/
-
public function get Bottom():Number {
-
return (__bottom);
-
}
-
/**
-
* MovieWidth - get/set
-
*/
-
public function get MovieWidth():Number {
-
return (__movieWidth);
-
}
-
public function set MovieWidth(v:Number) {
-
__movieWidth = v;
-
}
-
/**
-
* MovieHeight - get/set
-
*/
-
public function get MovieHeight():Number {
-
return (__movieHeight);
-
}
-
public function set MovieHeight(v:Number) {
-
__movieHeight = v;
-
}
-
}
Continua a leggere... »
Post correlati