-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.as
executable file
·158 lines (125 loc) · 5.66 KB
/
Main.as
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package {
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import caurina.transitions.*;
//import flashx.textLayout.formats.Float;
public class Main extends MovieClip {
/********************************************************/
/** variabili **********************************************/
// sfondo
private var tile:Background = new Background(new Material05(0,0));
// fullscreen
private var fullscreen:Full;
// musica
private var mySound:Sound;
private var myChannel:SoundChannel = new SoundChannel();
private var myTransform:SoundTransform = new SoundTransform();
// player
private var contenitoreTotale:SceltaGioco;
// variabili globali
public var currentScreen:MovieClip;
/********************************************************/
/** costruttore *****************************************/
public function Main()
{
var swfStage:Stage = this.stage;
swfStage.quality = "medium";
swfStage.scaleMode = StageScaleMode.NO_SCALE;
swfStage.align = StageAlign.TOP_LEFT;
swfStage.showDefaultContextMenu = false;
//swfStage.displayState = StageDisplayState.FULL_SCREEN; // visibile solo nel .exe
stage.addEventListener(Event.RESIZE, gestisciResize);
addEventListener(Event.ADDED_TO_STAGE,init);
addEventListener(Event.REMOVED_FROM_STAGE,destroy);
}
private function init(evt:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE,init);
trace("The application settings have been loaded!");
// creo il mio oggetto di tipo SceltaGioco
contenitoreTotale = new SceltaGioco();
// assegno l'altezza in base alle proporzioni e calcolo la nuova larghezza
/*
var ratio:Number = contenitoreTotale.width/contenitoreTotale.height;
altezzaGlobale = stage.stageHeight;
contenitoreTotale.height = altezzaGlobale;
larghezzaGlobale = contenitoreTotale.height*ratio;
contenitoreTotale.width = larghezzaGlobale;
*/
// aggiungo allo stage la mia home e la setto come schermo corrente
addChild(contenitoreTotale);
currentScreen = contenitoreTotale;
/** TWEENER *****************************************/
Tweener.addTween(currentScreen,{x:((stage.stageWidth - contenitoreTotale.sfondoRiferimento.width) / 2),time:1.2,transition:"easeoutelastic"});
Tweener.addTween(currentScreen,{y:((stage.stageHeight - contenitoreTotale.sfondoRiferimento.height) / 2),time:1,transition:"easeoutelastic"});
/** NORMALE *****************************************/
/*
player.x=stage.stageWidth /2 - player.width/2;
trace("player.width: " + player.width);
player.y=stage.stageHeight/2 - player.height/2;
trace("player.height: " + player.height);
*/
/** SFONDO *****************************************/
addChildAt(tile,0);
/** MUSICA *****************************************/
/*
mySound = new Sound();
mySound.addEventListener(Event.COMPLETE, onSoundLoaded);
mySound.load(new URLRequest("audio/musica.mp3"));
myChannel = mySound.play(0,1000);
myTransform.volume = 0.1;
myChannel.soundTransform = myTransform;
// mySound.close();
function onSoundLoaded(event:Event):void
{
trace("MUSICA SOTTOFONDO CARICATA");
}
*/
}
// DESTROY
private function destroy(evt:Event):void
{
removeEventListener(Event.REMOVED_FROM_STAGE,destroy);
removeChild(currentScreen);
}
/********************************************************/
/** metodi **********************************************/
// RESIZE / FULLSCREEN
private function gestisciResize(e:Event):void {
// assegno l'altezza in base alle proporzioni e calcolo la nuova larghezza
var ratio:Number = stage.stageWidth/currentScreen.sfondoRiferimento.width;
trace("RATIO: "+ratio);
var proporzioneX:Number = currentScreen.sfondoRiferimento.width*ratio;
contenitoreTotale.scaleX = ratio;
trace("pprop"+proporzioneX);
var proporzioneY:Number = currentScreen.sfondoRiferimento.height*ratio;
contenitoreTotale.scaleY = ratio;
trace("pprop"+proporzioneY);
Tweener.addTween(currentScreen,{x:((stage.stageWidth - proporzioneX) / 2),time:1.2,transition:"easeoutelastic"});
Tweener.addTween(currentScreen,{y:((stage.stageHeight - proporzioneY) / 2),time:1,transition:"easeoutelastic"});
/*
Tweener.addTween(currentScreen,{x:((stage.stageWidth - currentScreen.sfondoRiferimento.width) / 2),time:1.2,transition:"easeoutelastic"});
Tweener.addTween(currentScreen,{y:((stage.stageHeight - currentScreen.sfondoRiferimento.height) / 2),time:1,transition:"easeoutelastic"});
*/
/** PULSANTE FULLSCREEN *****************************************/
/*
Tweener.addTween(fullscreen,{x:((stage.stageWidth - fullscreen.width) - 20),time:1.2,transition:"easeoutelastic"});
Tweener.addTween(fullscreen,{y:((stage.stageHeight - fullscreen.height) - 20),time:1,transition:"easeoutelastic"});
*/
/** NORMALE *****************************************/
/*
player.x = (stage.stageWidth - player.width) / 2;
player.y = (stage.stageHeight - player.height) / 2;
fullscreen.x = (stage.stageWidth - fullscreen.width) - 20 ;
fullscreen.y = (stage.stageHeight - fullscreen.height) - 20 ;
*/
glow_mc.x = (stage.stageWidth - glow_mc.width) / 2;
glow_mc.y = (stage.stageHeight - glow_mc.height) ;
/** TESTO *****************************************/
//txtDimentions.text = (stage.stageWidth - player.width).toString() + "x" + (stage.stageHeight).toString();
};
}
}