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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
|
package config
{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.MouseEvent;
import flash.events.Event;
import clip.Panneau;
import clip.PanneauAutoPromo;
import clip.PanneauPub;
import clip.PanneauEcran2;
import clip.Ecran2;
import clip.LogoFl;
import clip.Newsletter;
import gs.TweenMax;
import gs.easing.Quad;
import gs.events.TweenEvent;
public class Site extends Sprite
{
public var panneau1: Panneau;
public var panneau2: Panneau;
public var panneau3: Panneau;
public var panneau4: Panneau;
public var panneau5: Panneau;
public var panneau6: PanneauAutoPromo;
public var panneau7: PanneauAutoPromo;
public var ecran2: Ecran2;
private var panneauEcran2: PanneauEcran2;
private var panneauPubHaut: MovieClip;
private var panneauPubDroit: PanneauPub;
private var logoHaut: LogoFl;
private var blocNewsletter: Newsletter;
public var sp_contenu: Sprite;
public var sp_haut: Sprite;
private static const centreXStage:int = 1040/2;
private var decalage_ini_pann: Number = 17;
private var decalage_pann: Number = 6;
private var decalage_pann_pub: Number = 6;
private var width_pann: Number = 135;
private var width_pann_pub: Number = 147;
private var timer: Timer;
private var xmouse: Number = mouseX ;
private var ymouse: Number = mouseY;
private var hitTest: Boolean;
private var scale : Number = Number.NEGATIVE_INFINITY;
private var span:Number = 250;
private var icon_min:Number = 135;
private var icon_size:Number = 135;
private var icon_max:Number = 160;
private var trend : Number = 0;
private var posClipX:Number;
private var ratio:Number = Math.PI / 2 / span;
private var amplitude : Number= 10;
private var posXclipInitial :Array;
private var _isHide:Boolean =false ;
private var chargeur:ConfigLoader;
public function Site(param1:ConfigLoader)
{
chargeur = param1;
madeSprite();
}//fin fonction
private function madeSprite():void
{
/**
** CONSTRUCTION DU HAUT
**/
sp_haut = new Sprite();
sp_haut.x = 0;
sp_haut.y= 0;
addChild(sp_haut);
logoHaut = new LogoFl();
sp_haut.addChild(logoHaut);
logoHaut.x =14;
logoHaut.y = 6;
panneauPubHaut= new PanneauPub({x:145, y:6, image: ConfigLoader.pub_1 , reflet:false, largeur:728, hauteur:90, posMaskX:145, posMaskY: 6});
sp_haut.addChild(panneauPubHaut);
blocNewsletter= new Newsletter();
sp_haut.addChild(blocNewsletter);
blocNewsletter.x=880;
blocNewsletter.y=10;
/**
** CONSTRUCTION DU SPRITE CONTENU
**/
sp_contenu = new Sprite();
sp_contenu.x = 0;
sp_contenu.y = 125;
addChild(sp_contenu);
sp_contenu.name = "Contenu";
//ajout des panneau pub
panneauPubDroit= new PanneauPub({x:-150, y:-125, image: ConfigLoader.pub_2 , reflet:true, largeur:300, hauteur:250 , posMaskX:-150, posMaskY: -125 });
panneauPubDroit.x = 873 ;
panneauPubDroit.y = 342;
sp_contenu.addChild(panneauPubDroit);
madePanneau();
}//fin fonction
private function madePanneau():void
{
panneau1 = new Panneau( {
refMonSite:this,
nom:"panneau1",
id_cat:chargeur.xml.panneau[0].@id_cat,
titre:chargeur.xml.panneau[0].titre,
sous_titre:chargeur.xml.panneau[0].sousTitre,
image : ConfigLoader.illus_1,
x:decalage_ini_pann + width_pann / 2,
y:300,
reflet:true
});
panneau2 = new Panneau({
refMonSite:this,
nom:"panneau2",
id_cat:chargeur.xml.panneau[1].@id_cat,
titre:chargeur.xml.panneau[1].titre,
sous_titre:chargeur.xml.panneau[1].sousTitre,
image : ConfigLoader.illus_2,
x:(decalage_ini_pann + width_pann/2 ) + decalage_pann + width_pann ,
y:300,
reflet: true
});
panneau3 = new Panneau({
refMonSite:this,
nom:"panneau3",
id_cat:chargeur.xml.panneau[2].@id_cat,
titre:chargeur.xml.panneau[2].titre,
sous_titre:chargeur.xml.panneau[2].sousTitre,
image : ConfigLoader.illus_3,
x:(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *2,
y:300,
reflet: true
});
panneau4 = new Panneau({
refMonSite:this,
nom:"panneau4",
id_cat:chargeur.xml.panneau[3].@id_cat,
titre:chargeur.xml.panneau[3].titre,
sous_titre:chargeur.xml.panneau[3].sousTitre,
image : ConfigLoader.illus_4,
x:(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *3 ,
y:300,
reflet: true
});
panneau5 = new Panneau({
refMonSite:this,
nom:"panneau5",
id_cat:chargeur.xml.panneau[4].@id_cat,
titre:chargeur.xml.panneau[4].titre,
sous_titre:chargeur.xml.panneau[4].sousTitre,
image : ConfigLoader.illus_5,
x:(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *4 ,
y:300,
reflet: true
});
panneau6 = new PanneauAutoPromo({
refMonSite:this,
nom:"panneau6",
id_cat:chargeur.xml.panneau[5].@id_cat,
titre:chargeur.xml.panneau[5].titre,
sous_titre:chargeur.xml.panneau[5].sousTitre,
image : ConfigLoader.illus_6,
x:(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *5 + decalage_pann_pub,
y:300
});
panneau7 = new PanneauAutoPromo({
refMonSite:this,
nom:"panneau7",
id_cat:chargeur.xml.panneau[6].@id_cat,
titre:chargeur.xml.panneau[6].titre,
sous_titre:chargeur.xml.panneau[6].sousTitre,
image : ConfigLoader.illus_7,
x:(decalage_ini_pann + width_pann/2 ) + (decalage_pann + width_pann) *5 + 2* decalage_pann_pub + width_pann_pub ,
y:300
});
sp_contenu.addChild(panneau1);
sp_contenu.addChild(panneau2);
sp_contenu.addChild(panneau3);
sp_contenu.addChild(panneau4);
sp_contenu.addChild(panneau5);
sp_contenu.addChild(panneau6);
sp_contenu.addChild(panneau7);
posXclipInitial = new Array((panneau1.x - centreXStage), (panneau1.x - centreXStage), (panneau2.x - centreXStage), (panneau3.x - centreXStage), (panneau4.x - centreXStage), (panneau5.x - centreXStage), (panneau6.x - centreXStage), (panneau7.x - centreXStage));
madePanneauEcran2();
}//fin fonction
private function madePanneauEcran2():void
{
panneauEcran2 = new PanneauEcran2();
sp_contenu.addChild(panneauEcran2);
panneauEcran2.visible = false;
panneauEcran2.width = 0;
panneauEcran2.x = decalage_ini_pann + width_pann / 2,
panneauEcran2.y=234;
madeEcran2();
}//fin fonction
private function madeEcran2():void
{
ecran2= new Ecran2(chargeur);
sp_contenu.addChild(ecran2);
ecran2.visible = false;
ecran2.x = 135+17+6;
ecran2.y = 1;
ini();
}//fin fonction
public function ini():void
{
showPanneauIntro();
}//fin fonction
public function showPanneauIntro():void
{
var myTween1 = TweenMax.allTo([panneau1, panneau2, panneau3, panneau4, panneau5 ], 0.5 , {y: (panneau1.taille_panneau.height /2) , alpha:1, delayIncrement:0.1, ease:Quad.easeInOut, overwrite:2 });
var myTween2 = TweenMax.allTo([panneau6, panneau7 ], 0.5 , {y: (panneau6.taille_panneau.height /2) , alpha:1, delay:0.4 , delayIncrement:0.1, ease:Quad.easeInOut, onCompleteAll:end_animPanIntro, overwrite:2 });
}//fin fonction
private function end_animPanIntro():void
{
iniDockPan();
}//fin fonction
private function iniDockPan():void
{
sp_contenu.addEventListener(MouseEvent.MOUSE_MOVE, moveDockPan);
sp_haut.addEventListener(MouseEvent.MOUSE_OVER, stopDockPan);
sp_contenu.addEventListener(Panneau.ONSELECTEDPANDOCK, _hidePannel,true);
sp_contenu.addEventListener(PanneauAutoPromo.ONSELECTEDPANDOCK_AUTOPROMO, _hidePannel,true);
stage.addEventListener(Event.MOUSE_LEAVE,stopDockPan);
sp_contenu.removeEventListener(PanneauEcran2.ONSELECTEDPAN_ECRAN2, _showPanel,true);
panneau1._ini();
panneau2._ini();
panneau3._ini();
panneau4._ini();
panneau5._ini();
panneau6._ini();
panneau7._ini();
//mets le dock ON
_isHide =false;
}//fin fonction
private function moveDockPan(evt:Event):Boolean
{
var i:Number;
var x:Number;
var dx:Number;
var dim:Number;
var largeur_dock:Number = this.parent.width;
var dim_clip_avant:Number = 0;
if (_isHide==false)
{
// Mouse did not move and Dock is not between states. Skip rest of the block.
if((this.xmouse == this.mouseX) && (this.ymouse == this.mouseY) && ((this.scale <= 0.01) || (this.scale >= 0.99))) { return false; }
// Mouse moved or Dock is between states. Update Dock.
this.xmouse = this.mouseX;
this.ymouse = this.mouseY;
// Ensure that inflation does not change direction.
this.trend = (this.trend == 0 ) ? (checkBoundary() ? 0.25 : -0.25) : (this.trend);
this.scale += this.trend;
if( (this.scale < 0.02) || (this.scale > 0.98) ) { this.trend = 0; }
// Actual scale is in the range of 0..1
this.scale = Math.min(1, Math.max(0, this.scale));
// Hard stuff. Calculating position and scale of individual icons.
for(i = 1; i < 8; i++) {
dx = posXclipInitial[i] - ( this.xmouse - largeur_dock/2) ;
dx = Math.min(Math.max(dx, -this.span), this.span);
dim = this.icon_min + (this.icon_max - this.icon_min) * Math.cos(dx * this.ratio) * (Math.abs(dx) > this.span ? 0 : 1) * this.scale ;
sp_contenu.setChildIndex( (this["panneau"+i]), ( (dim_clip_avant>dim) ? 5:7) );
this["panneau"+i].x = posXclipInitial[i] + this.scale * this.amplitude * Math.sin(dx * this.ratio) + centreXStage;
this["panneau"+i].scaleX = this["panneau"+i].scaleY = (1 * dim / this.icon_size);
dim_clip_avant=dim;
//trace( "num=" + i + "--level="+ sp_contenu.getChildIndex(this["panneau"+i]) +"taille="+ this["panneau"+i].width);
}
//trace ("\n\n");
}
return true;
}//fin fonction
private function checkBoundary():Boolean
{
if ((this.ymouse > 100 && this.ymouse < 580 && this.xmouse>6 && this.xmouse<723) || (this.ymouse >100 && this.ymouse <308 && this.xmouse>723 && this.xmouse<1010) )
{
return true;
}else{
return false;
}
}//fin fonction
private function stopDockPan(evt:Event):void
{
var i:int;
for(i = 1; i < 8; i++) {
this["panneau"+i].x = posXclipInitial[i] + centreXStage;
this["panneau"+i].scaleX = this["panneau"+i].scaleY = 1;
}
}//fin fonction
private function stopDockPan2():void
{
var i:int;
for(i = 1; i < 8; i++) {
this["panneau"+i].x = posXclipInitial[i] + centreXStage;
this["panneau"+i].scaleX = this["panneau"+i].scaleY = 1;
}
}//fin fonction
private function _hidePannel(evt:Event) :void
{
//arrete le dock
_isHide =true;
stopDockPan2();
//supprimer les ecouteur
sp_contenu.removeEventListener(MouseEvent.MOUSE_MOVE, moveDockPan);
sp_haut.removeEventListener(MouseEvent.MOUSE_OVER, stopDockPan);
sp_contenu.removeEventListener(Panneau.ONSELECTEDPANDOCK, _hidePannel,true);
sp_contenu.removeEventListener(PanneauAutoPromo.ONSELECTEDPANDOCK_AUTOPROMO, _hidePannel,true);
//mettre en place l'ecran 2
ecran2.setEcran2(evt.target.id_cat);
//faire tourner le panneau 1
var myTween1:TweenMax = TweenMax.to(panneau1, 0.5, {scaleX: 0, alpha:0, ease:Quad.easeInOut });
panneauEcran2.visible = true;
var myTween2:TweenMax = TweenMax.to(panneauEcran2, 0.5, {scaleX: 1, alpha:1, ease:Quad.easeInOut });
//faire disparaitre les autres panneaux
var myTween3 = TweenMax.allTo([panneau2, panneau3, panneau4, panneau5], 0.5 , {y:"-50", alpha:0, delayIncrement:0.1, onCompleteAll:hidePanneau });
//afficher l'ecran 2
showEcran2();
//trace (evt.target.id_cat)
} //fin fonction
private function _showPanel(evt:Event):void
{
ecran2.masque.gotoAndPlay("fin");
//rendre invisible ecran2
sp_contenu.removeEventListener(PanneauEcran2.ONSELECTEDPAN_ECRAN2, _showPanel,true);
sp_contenu.addEventListener(PanneauAutoPromo.ONSELECTEDPANDOCK_AUTOPROMO, _hidePannel,true);
//afficher les panneaux
panneau1.visible= panneau2.visible= panneau3.visible= panneau4.visible= panneau5.visible = true;
showPanneauIntro();
//faire tourner le panneau 1 ET faire tourner le panneau de gauche
var myTween1:TweenMax = TweenMax.to(panneau1, 0.5, {scaleX: 1, alpha:1, ease:Quad.easeInOut, overwrite:2 });
var myTween2:TweenMax = TweenMax.to(panneauEcran2, 0.5, {scaleX: 0, alpha:0, ease:Quad.easeInOut, onComplete:hidePanneau2 ,overwrite:2 });
}//fin fonction
private function showEcran2():void
{
ecran2.visible=true;
ecran2.mask = ecran2.masque ;
ecran2.masque.gotoAndPlay("debut");
}//fin fonction
private function hidePanneau():void
{
sp_contenu.addEventListener(PanneauEcran2.ONSELECTEDPAN_ECRAN2, _showPanel,true);
panneau1.visible= panneau2.visible= panneau3.visible= panneau4.visible= panneau5.visible = false;
}//fin fonction
private function changePanAccueil():void
{
panneauEcran2.visible = true;
TweenMax.to(panneauEcran2, 0.5, {scaleX: 1, alpha:1, ease:Quad.easeInOut, overwrite:false });
}
private function hidePanneau2():void
{
panneauEcran2.visible = false;
}//fin fonction
private function hideEcran2():void
{
ecran2.visible=false;
}
}//fin class
}//fin package |
Partager