Accueil > Forum > > > > pb positionnement
pb positionnement
mercredi 14 avril 2010 à 20:01:37 |
pb positionnement

nicodogs
|
Bonjour à tous,
J'aimerais avoir vos lumières car je suis un peu perdu.
J'ai une galerie style slideshow et j'ai quelques pb pour la paramètrer.
Ce swf est externe et est appelé par mon fichier _root. et là pb! Mon scroll souris fonctionne très mal et les éléments ne se positionnent pas exactement où j'aimerais.
Pourriez-vous me donner un petit coup de main pour y voir plus clair?
Ci-joint le code AS.
Merci beaucoup ;)
Code ActionScript :
// DONT MESS BELOW THIS LINE //////////////////////////////////
// filters
import flash.filters.BlurFilter;
// alignment (dont change this)
Stage.align = "TL";
Stage.scaleMode = "noScale";
// include zigo library
import com.mosesSupposes.fuse.*;
ZigoEngine.simpleSetup(Shortcuts,PennerEasing);
// flag for first init
var init:Boolean = false;
// hide preview
preview_MC._visible = false;
// stores the real height of the galleries menu
var menuH:Number;
//flag for the darkScreen
var flagDarkScreen:Boolean = false;
// blur vars
var blurred:BlurFilter = new BlurFilter(10, 10, 1);
var storedBlur:Array = [blurred];
// XML data
var galleryXML:XML = new XML();
galleryXML.ignoreWhite = true;
var imageList:Array = new Array();
var galleryList:Array = new Array();
var configList:Array = new Array();
var bgm:Sound = new Sound(soundLoader);
// moving menuflag
var movingMenu:Boolean = true;
// loader for the image
var shellImage:MovieClip = createEmptyMovieClip("shellImage_MC", 10);
// current image
var currentImage:Number = 0;
//velocity for closing and opening images
var windowTime:Number = 1;
// load xml
galleryXML.load(path);
galleryXML.onLoad = loadHandler;
//audio vars
var playingStatus:Boolean = false;
var stream:Boolean = false;
var songReady:Boolean = false;
/////////////////////////////////////////////////////////////////////////////////////////
// background image path (if you dont want a bg comment or erase the var)
//var bgPath:String = "galleries/bg.jpg";
// first by default gallery loaded
var galleryNumber:Number;
// show menu of galleries
var showGalleries:Boolean;
// allow keyboard navigation
var useNavArrows:Boolean;
// number of items to be displayed by the galleries menu
var nMenuItems:Number;
// panel border
var panelBorder:Number;
// menu bar speed (the higher the slower)
var vel:Number;
// THUMBNAIL SETTINGS ///////////////////////////////////////////
// width and height of the thumbs
var thumbWidth:Number;
var thumbHeight:Number;
// margin between thumbnails
var thumbMargin:Number;
// thumb roll over height for items
var overHeight:Number;
// tool tip colors
var tooltipText:String;
var tooltipBg:String;
// image zoom percent
// set to 100 if you dont want to show zoom
var zoomPercent:Number;
// INFO SETTINGS ///////////////////////////////////////////
// set visibility of info button
var showInfoButton:Boolean;
// messages for the info button
var infoMsg:String;
// messages for the close button
var closeMsg:String;
// messages for the link button
var linkMsg:String;
// messages for the audio button
var audioMsg:String;
// AUDIO SETTINGS ///////////////////////////////////////////
// Specify where audio starts in seconds
var audioOffSet;
// number of loops for the audio
var nLoops:Number;
/////////////////////////////////////////////////////////////////////////////////////////
// thumb MCL
var thumbMCL:MovieClipLoader = new MovieClipLoader();
var thumbLoadListener:Object = new Object();
thumbMCL.addListener(thumbLoadListener);
thumbLoadListener.onLoadInit = function(mc:MovieClip):Void{
//resize
mc._width = thumbWidth;
mc._height = thumbHeight;
}
/////////////////////////////////////////////////////////////////////////////////////////
// load handler
function loadHandler(success:Boolean):Void{
// if not errors while loading...
if(success){
// create list of settings
configList = galleryXML.childNodes[0];
// create list of galleries
galleryList = galleryXML.childNodes[1].childNodes;
if(galleryNumber == undefined){
setConfig(configList);
}
// create list of images
imageList = galleryXML.childNodes[1].childNodes[galleryNumber].childNodes;
// populate gallery
loadThumbnails(imageList);
// if there is not the galleryMenu already
if (!init) {
// put gallery
putGalleryMenu();
// re center
center();
// put background
putBG(bgPath);
// use only if set to true
if(useNavArrows){
keyListener.onKeyDown = keyBoardNav;
}
}
// init
currentImage = -1;
init = true;
}else{
trace("Error loading XML!");
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// puts the galleries menu
function putGalleryMenu():Void{
// if set to on putgallery menu
if(showGalleries){
// put tab to open the menu
attachMovie("galleriesButton_MC", "galleriesButton_MC", 30);
// appear tab with easing
galleriesButton_MC._y = -galleriesButton_MC._height;
ZigoEngine.doTween(galleriesButton_MC, "_y", 0, 1.5, "easeOutExpo", 1);
// center
centerGalleriesTab();
// events
galleriesButton_MC.onPress = function(){
// reset the size of the shellImage
resetZoom();
// put no click dark screen
putDarkScreen();
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// set the configuration list
function setConfig(list):Void{
bgPath = String(list.attributes.bgPath);
galleryNumber = Number(list.attributes.galleryNumber);
if(list.attributes.showGalleries == "true"){
showGalleries = true;
}else{
showGalleries = false;
}
if(list.attributes.useNavArrows == "true"){
useNavArrows = true;
}else{
useNavArrows = false;
}
nMenuItems = Number(list.attributes.nMenuItems);
panelBorder = Number(list.attributes.panelBorder);
vel = Number(list.attributes.vel);
thumbWidth = Number(list.attributes.thumbWidth);
thumbHeight = Number(list.attributes.thumbHeight);
thumbMargin = Number(list.attributes.thumbMargin);
overHeight = Number(list.attributes.overHeight);
tooltipText = String(list.attributes.tooltipText);
tooltipBg = String(list.attributes.tooltipBg);
zoomPercent = Number(list.attributes.zoomPercent);
if(list.attributes.showInfoButton == "true"){
showInfoButton = true;
}else{
showInfoButton = false;
}
infoMsg = String(list.attributes.infoMsg);
closeMsg = String(list.attributes.closeMsg);
linkMsg = String(list.attributes.linkMsg);
audioMsg = String(list.attributes.audioMsg);
audioOffset = Number(list.attributes.audioOffset);
nLoops = Number(list.attributes.nLoops);
}
/////////////////////////////////////////////////////////////////////////////////////////
//puts a dark screen to prevent clicks
function putDarkScreen():Void{
// check if is not open
if(flagDarkScreen){
// change state of the button
galleriesButton_MC.gotoAndStop(1);
//remove darkScreen
darkScreen_MC.removeMovieClip();
// stop nav moving
movingMenu = true;
// blur the gallerie
holder_MC.filters = undefined;
// blur the bg
bg_MC.filters = undefined;
//remove menu items
menuHolder_MC.removeMovieClip();
//switch flag
flagDarkScreen = false;
}else{
// change state of the button
galleriesButton_MC.gotoAndStop(2);
// create movieclip
createEmptyMovieClip("darkScreen_MC", 25);
// fade it
darkScreen_MC._alpha = 0;
ZigoEngine.doTween(darkScreen_MC, "_alpha", 80, 2, "easeOutExpo", 0);
// draw dark square
darkScreen_MC.beginFill(0x000000);
darkScreen_MC.moveTo(0,0);
darkScreen_MC.lineTo(0,0);
darkScreen_MC.lineTo(Stage.width,0);
darkScreen_MC.lineTo(Stage.width,Stage.height);
darkScreen_MC.lineTo(0,Stage.height);
darkScreen_MC.endFill();
// prevent clicks
darkScreen_MC.onRollOver = function(){
// hide cursor
this.useHandCursor = false;
};
// stop nav moving
movingMenu = false;
// blur the gallerie
holder_MC.filters = storedBlur;
// blur the bg
bg_MC.filters = storedBlur;
// stop audio if theres audio
cancelAudio();
// close all thumbs
allThumbsClose();
// reset alpha in all tumbs
allThumbsFadeIn();
// reset original positions
contractThumbs();
// remove info
info_MC.removeMovieClip();
// unload loaded image
shellImage.unloadMovie();
// populate gallery Menu
loadMenuThumbnails(galleryList);
//switch flag
flagDarkScreen = true;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// load thumbnails
function loadThumbnails(list:Array) {
//create holder for the thumbnails
createEmptyMovieClip("holder_MC", 3);
// center holder
centerHolder();
// for each image...
for (var i:Number = 0; i<list.length; i++) {
//new thumb
var thumb:MovieClip = holder_MC.attachMovie("thumb_MC", "thumb_MC_"+i, i);
// center fix
var xCenterFix:Number = thumbWidth/-2;
var yCenterFix:Number = thumbHeight/-2;
// panel size
thumb.panel_MC._width = thumbWidth;
thumb.panel_MC._height = thumbHeight;
// center loaders
thumb.loader_MC._x = xCenterFix;
thumb.loader_MC._y = yCenterFix;
thumb.imageLoader_MC._x = xCenterFix;
thumb.imageLoader_MC._y = yCenterFix;
// center panel
thumb.panel_MC._x = xCenterFix;
thumb.panel_MC._y = yCenterFix;
// load image
//thumb.loader_MC.loadMovie(list[i].attributes.thumb);
thumbMCL.loadClip(list[i].attributes.thumb, thumb.loader_MC);
// pos
var thumbX:Number = i*(thumbWidth + thumbMargin) + thumbMargin - xCenterFix;
// set pos
thumb._x = 1000;
ZigoEngine.doTween(thumb, "_x", thumbX, 1, "easeOutExpo", (i/20) );
//data
thumb.name = list[i].attributes.name;
thumb.number = i;
thumb.thumbLink = list[i].attributes.thumbLink;
//events
thumb.onRollOver = thumbOver;
thumb.onRollOut = thumb.onReleaseOutside=thumbOut;
// if theres thumblink
if(thumb.thumbLink != undefined){
// open link
thumb.onPress = function():Void{
getURL(this.thumbLink, "_blank");
}
}else{
// ... open image
thumb.onPress = thumbPress;
}
}//for
//default first thumbnail
currentImage = 0;
//start moving menu
holder_MC.onEnterFrame = moveBar;
}
/////////////////////////////////////////////////////////////////////////////////////////
// load thumbnails for the menu
function loadMenuThumbnails(list:Array) {
// vars for the thumbs
var menuThumbH:Number = 67;
var menuThumbMargin:Number = 3;
//create menu holder
createEmptyMovieClip("menuHolder_MC", 35);
//create holder for the thumbnails
menuHolder_MC.createEmptyMovieClip("holder_MC", 5);
// create mask for the menuHolder
var maskMC:MovieClip = menuHolder_MC.createEmptyMovieClip("mask_MC", 10);
// widht and height of mask
var maskW:Number = 311;
var maskH:Number = (menuThumbH + menuThumbMargin ) * nMenuItems;
// store the height of the menu (without the masked image heght)
menuH = list.length * (menuThumbH + menuThumbMargin);
// create solid for the mask //309x67
maskMC.beginFill(0xFF0000, 30);
maskMC.moveTo(0,0);
maskMC.lineTo(maskW,0);
maskMC.lineTo(maskW,maskH);
maskMC.lineTo(0,maskH);
maskMC.lineTo(0,0);
maskMC.endFill();
// set maskholder_MC
menuHolder_MC.holder_MC.setMask(maskMC);
//create border panel
var panelMC:MovieClip = menuHolder_MC.attachMovie("galleriesMenuPanel_MC", "panel_MC", 2);
// panel size
panelMC._width = maskMC._width + panelBorder;
panelMC._height = maskMC._height + panelBorder;
// cente panel
panelMC._x = maskMC._x - panelBorder/2;
panelMC._y = maskMC._y - panelBorder/2;
// for each gallery...
for (var i:Number = 0; i<list.length; i++) {
//new thumb
var thumb:MovieClip = menuHolder_MC.holder_MC.attachMovie("menuThumb_MC", "thumb_MC_"+i, i);
// load thumbnail
thumb.loader_MC.loadMovie(list[i].firstChild.attributes.thumb);
// data for the thumbnail
thumb.name_TXT.text = list[i].attributes.name;
thumb.description_TXT.text = list[i].attributes.desc;
// thumb y position
thumb._y = (menuThumbH + menuThumbMargin) * i;
// thumbnail Number
thumb.galleryNumber = i;
// events
thumb.hit_MC.onRollOver = function():Void{
ZigoEngine.doTween(this, "_brightness", 12, 1, "easeOutExpo");
}
thumb.hit_MC.onRollOut = function():Void{
ZigoEngine.doTween(this, "_brightness", 0, 1, "easeOutExpo");
}
thumb.hit_MC.onPress = function():Void{
// load gallery
loadGallery(this._parent.galleryNumber);
}
}
// center holder
centerMenuHolder();
// fade it In
menuHolder_MC._alpha =0;
ZigoEngine.doTween(menuHolder_MC, "_alpha", 100, 1.5, "easeOutExpo", 1);
// start moving
menuHolder_MC.holder_MC.onEnterFrame = moveGalleryBar;
}
/////////////////////////////////////////////////////////////////////////////////////////
// move menu bar with easing
function moveBar():Void {
//if flag on, then move
if (movingMenu) {
// this moviClip
var menu:MovieClip = this;
//calculate new pos
pos = -(_xmouse)*(( menu._width -Stage.width)/Stage.width);
// integer number
pos = Math.round(pos);
// if menu smaller than stage width dont apply easing or movement
if(menu._width > Stage.width){
// set pos and put easing
pos = setPos(menu, pos, 0, Stage.width, Stage.height/2 - thumbHeight/2, Stage.height/2 + thumbHeight/2);
}else{
//center the menu
menu._x = Stage.width/2 - menu._width/2;
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////
function setPos(mc, pos, L, R, T, B) {
//if inside Y boundaies move
if (_ymouse<B and _ymouse>T) {
//if inside X boundaies move
if (_xmouse>L and _xmouse<R) {
// move with easing
mc._x+=(pos - mc._x)/vel;
}// X
}// Y
}
/////////////////////////////////////////////////////////////////////////////////////////
// move menu gallery bar
function moveGalleryBar():Void {
// var fix
var fix:Number = 0;
// Height of the area visible
var areaH:Number = menuHolder_MC.mask_MC._height;
// position of the mouse
var yMouse:Number = _ymouse - menuHolder_MC._y - fix;
// this moviClip
var menu:MovieClip = this;
//calculate new pos
pos = -(yMouse)*(( menuH -areaH)/areaH);
// integer number
pos = Math.round(pos);
// if menu smaller than stage width dont apply easing or movement
if(menu._height > areaH){
// set pos and put easing
//pos = setPos(menu, pos, 0, Stage.width, Stage.height/2 - thumbHeight/2, Stage.height/2 + thumbHeight/2);
menu._y+=(pos - menu._y)/2;
// top bounday
if(menu._y > 0){
menu._y = 0;
}
// bottom bounday
if(menu._y < (areaH-menuH)){
menu._y = areaH-menuH;
}
}else{
//center the menu
//menu._x = Stage.width/2 - menu._width/2 - menuMargins;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
//resort thumbnails positions
function resortThumbs():Void{
for(var i:Number = 0; i < imageList.length; i++){
// actual previous item alias
var actualItem:MovieClip = holder_MC["thumb_MC_"+i];
var prevItem:MovieClip = holder_MC["thumb_MC_"+(i-1)];
//re pos
actualItem._x = prevItem._x + prevItem._width/2;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// thumb events
function thumbPress():Void {
// over only if this is not the current one
// or menu is not moving
if(this.number != currentImage or movingMenu){
// stop audio if theres audio
cancelAudio();
// show loading animation
this.loadingAnimation_MC._visible = true;
// remove tool tip
removeTooltip();
// over animation
ZigoEngine.doTween(this, "_y", 0, 0.8, "easeOutExpo");
// remove previous loaded image
shellImage.unloadMovie();
// set current image
currentImage = this.number;
//stop moving
movingMenu = false;
// reset alpha in all tumbs
allThumbsFadeIn();
// set all other thumbnails original width
allThumbsClose();
// reset original positions
contractThumbs();
//set alpha in this
ZigoEngine.doTween(this.loader_MC, "_alpha", 0 , windowTime*1.5, "easeOutExpo");
// unload previous info
info_MC.unloadMovie();
// lock holder to thumbnail distance
lockThumbnail(this);
// clear previous timers
clearInterval(timerID);
// load image later
timerID = setTimeout(loadImage, windowTime*1000, this);
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// put a close button cursor
function putCursor():Void{
//hide hand and cursor
this.useHandCursor = false;
Mouse.hide();
var cursorMC:MovieClip = attachMovie('glassCursor_MC', 'glassCursor_MC', 1100);
// curosr pos
cursorMC._x = _xmouse;
cursorMC._y = _ymouse;
// follow mouse
cursorMC.startDrag();
}
/////////////////////////////////////////////////////////////////////////////////////////
// remove Close cursor
function removeCursor():Void{
// make sure the cursor is shown
Mouse.show();
// remove movieclip
glassCursor_MC.removeMovieClip();
}
/////////////////////////////////////////////////////////////////////////////////////////
// temps for image size before zoom
var shellWidth:Number;
var shellHeight:Number;
// zooms In image
function zoomIn():Void{
// zoom only if zoomPercent is greater than 100
if(zoomPercent > 100){
// smooth
shellImage_MC.forceSmoothing = true;
// hide info buttons
info_MC._visible = false;
// size
ZigoEngine.doTween(shellImage_MC, "_xscale, _yscale", [zoomPercent, zoomPercent] , 1, "easeOutExpo");
// vars
var xPos:Number = Stage.width/2 - shellImage_MC._width/2 * (zoomPercent/100);
var yPos:Number = Stage.height/2 - shellImage_MC._height/2 * (zoomPercent/100);
// center position
ZigoEngine.doTween(shellImage_MC, "_x", xPos , 1, "easeOutExpo");
ZigoEngine.doTween(shellImage_MC, "_y", yPos , 1, "easeOutExpo");
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// zooms out image
function zoomOut():Void{
// turn off forceSmooting
shellImage_MC.forceSmoothing = false;
// size
ZigoEngine.doTween(shellImage_MC, "_xscale, _yscale", [100, 100] , 1, "easeOutExpo",0 , posInfo);
// vars
var xPos:Number = Stage.width/2 - shellWidth/2;
var yPos:Number = Stage.height/2 - shellHeight/2;
// center position
ZigoEngine.doTween(shellImage_MC, "_x", xPos , 1, "easeOutExpo");
ZigoEngine.doTween(shellImage_MC, "_y", yPos , 1, "easeOutExpo");
// set the pos and visibility of the info panel
function posInfo():Void{
// show info buttons
info_MC._visible = true;
// center info buttons
centerInfo();
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// resets the size of the sheelImage
function resetZoom():Void{
// size
shellImage_MC._xscale = 100;
shellImage_MC._yscale = 100;
// vars
var xPos:Number = Stage.width/2 - shellWidth/2;
var yPos:Number = Stage.height/2 - shellHeight/2;
// center position
shellImage_MC._x = xPos;
shellImage_MC._y = yPos;
}
/////////////////////////////////////////////////////////////////////////////////////////
function thumbOver():Void {
// over only if this is not the current one
// or the menu is moving
if(this.number != currentImage or movingMenu){
// put over others
this.swapDepths(_parent.getNextHighestDepth());
// over animation
ZigoEngine.doTween(this, "_y", -overHeight, 0.8, "easeOutExpo");
// put tool tip if not undefined
if(this.name != undefined){
tooltip(this.name);
}
}else{
//hide hand
this.useHandCursor = false;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
function thumbOut():Void {
// remove tool tip
removeTooltip();
// over animation
ZigoEngine.doTween(this, "_y", 0, 0.8, "easeOutExpo");
}
/////////////////////////////////////////////////////////////////////////////////////////
// loads the big image in the shellImage
function loadImage(item:MovieClip):Void{
// reset the size of the shellImage
resetZoom();
// load image
var imageMCL:MovieClipLoader = new MovieClipLoader();
var imageLoadListener:Object = new Object();
imageMCL.addListener(imageLoadListener);
// events
imageLoadListener.onLoadInit = function(mc:MovieClip):Void{
// when loaded make sure menu is not moving
movingMenu = false;
// hide loading animation
item.loadingAnimation_MC._visible = false;
// stop lock tween
ZigoEngine.removeTween(holder_MC);
// get big image width
var imageW:Number = shellImage._width;
//fade in image
shellImage._alpha = 0;
ZigoEngine.doTween(shellImage, "_alpha", 100, windowTime, "easeOutExpo", windowTime);
// center to current thumbnail or image
holder_MC._x = Stage.width /2 - item._x - item._width/2;
// resize thumb panel
resizeThumb(item);
// expand items
expandThumbs(imageW);
// center to current thumbnail or image
var newPos:Number = Stage.width /2 - item._x - imageW/2 + thumbWidth/2;
ZigoEngine.doTween(holder_MC, "_x", newPos, 1, "easeOutExpo");
//holder_MC._x = newPos;
// reset over growth
//ZigoEngine.doTween(item, "_xscale, _yscale", 100, 0.2, "easeOutExpo");
item._xscale = 100;
item._yscale = 100;
//put info
putInfo();
// center
centerImage();
// roll over
shellImage.onRollOver = function():Void{
// only if zoom is greater than 100
if(zoomPercent > 100){
// put the follow close button
putCursor();
}else{
// remove hand cursor
this.useHandCursor = false;
}
}
// roll out
shellImage.onRollOut = function():Void{
removeCursor();
}
// events for zoom
shellImage.onPress = function():Void{
// zoom
// if it is zoomed already
if(shellImage_MC._xscale > 100){
zoomOut();
}else{
//store temp
shellWidth = shellImage_MC._width;
shellHeight = shellImage_MC._height;
// zooms
zoomIn();
}
}// on press
}
// load image
imageMCL.loadClip(imageList[currentImage].attributes.url, shellImage);
}
/////////////////////////////////////////////////////////////////////////////////////////
// resize thumbnail to the size of the loaded image
function resizeThumb(thumb):Void{
// resize
ZigoEngine.doTween(thumb.panel_MC, "_width", shellImage._width, 0.5, "easeOutExpo");
ZigoEngine.doTween(thumb.panel_MC, "_height", shellImage._height, 0.5, "easeOutExpo");
//thumb.panel_MC._width = shellImage._width;
// center height
ZigoEngine.doTween(thumb.panel_MC, "_y", -shellImage._height/2, 0.5, "easeOutExpo");
}
/////////////////////////////////////////////////////////////////////////////////////////
// expands items around the loaded image
function expandThumbs(imageW:Number):Void{
// expand items to the right
for(var i:Number = (currentImage+1); i < imageList.length; i++){
// item alias
var item:MovieClip = holder_MC["thumb_MC_" + i];
var newPos:Number = item._x + imageW - thumbWidth;
ZigoEngine.doTween(item, "_x", newPos, 1, "easeOutExpo");
//item._x = newPos;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// contract all thumbnails
function contractThumbs():Void{
// contract all items one by one
for(var i:Number = 0; i < imageList.length; i++){
// item alias
var item:MovieClip = holder_MC["thumb_MC_" + i];
var newPos:Number = i*(thumbWidth + thumbMargin) + thumbMargin + thumbWidth/2;
ZigoEngine.doTween(item, "_x", newPos, windowTime, "easeOutExpo");
//item._x = newPos;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// locks target thumbnail
function lockThumbnail(thumb):Void{
// x position value for the locked thumbnail
var lockX:Number;
// calculate postion as the thumbs where closed
// set it to thumbx
var thumbX:Number = thumb.number * thumbWidth;
//set lock x
lockX = Stage.width /2 - thumbX - thumb._width/2;
// move holder
ZigoEngine.doTween(holder_MC, "_x", lockX, 1, "easeOutExpo");
//holder_MC._x = -lockX;
}
/////////////////////////////////////////////////////////////////////////////////////////
// fadeIn all other thumbnails
function allThumbsFadeIn():Void{
for(var i:Number = 0; i < imageList.length; i++){
//set alpha to 100
holder_MC["thumb_MC_" + i].loader_MC._alpha = 100;
// ad again if there was a delay
ZigoEngine.doTween(holder_MC["thumb_MC_" + i].loader_MC, "_alpha", 100, 0.5, "easeOutExpo", 0.5);
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// close all other thumbnails
function allThumbsClose():Void{
for(var i:Number = 0; i < imageList.length; i++){
//set to orginal width
//holder_MC["thumb_MC_" + i].panel_MC._width = thumbWidth;
ZigoEngine.doTween(holder_MC["thumb_MC_" + i].panel_MC, "_width", thumbWidth, 1, "easeOutExpo");
//set to orginal height
ZigoEngine.doTween(holder_MC["thumb_MC_" + i].panel_MC, "_height", thumbHeight, 1, "easeOutExpo");
// set initial y pos
ZigoEngine.doTween(holder_MC["thumb_MC_" + i].panel_MC, "_y", -thumbHeight/2, 1, "easeOutExpo");
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// puts an external background
function putBG(path:String):Void{
// create bg holder
createEmptyMovieClip("bg_MC", 1);
// load image
var bgMCL:MovieClipLoader = new MovieClipLoader();
var bgLoadListener:Object = new Object();
bgMCL.addListener(bgLoadListener);
// events
bgLoadListener.onLoadInit = function(mc:MovieClip):Void{
//fade in background
bg_MC._alpha = 0;
ZigoEngine.doTween(bg_MC, "_alpha", 100, windowTime, "easeOutExpo");
// and center
center();
}
// load background
bgMCL.loadClip(path, bg_MC);
}
/////////////////////////////////////////////////////////////////////////////////////////
// listener for resize
var resizeListener:Object = new Object();
Stage.addListener(resizeListener);
resizeListener.onResize = center;
// function that resizes and centers layout
function center():Void {
bgStretch();
centerHolder();
centerMenuHolder();
centerImage();
centerInfo();
centerGalleriesTab();
stretchDarkScreen();
}
/////////////////////////////////////////////////////////////////////////////////////////
// centers thumbs
function centerHolder():Void{
// stop tweens for the holder
ZigoEngine.removeTween(holder_MC);
// center y
holder_MC._y = Stage.height/2;
// center to current thumbnail or image
holder_MC._x = Stage.width /2 - holder_MC["thumb_MC_"+currentImage]._x
- holder_MC["thumb_MC_"+currentImage]._width/2
+ thumbWidth/2;
}
/////////////////////////////////////////////////////////////////////////////////////////
// centers menu
function centerMenuHolder():Void{
// center to current thumbnail or image
menuHolder_MC._x = Stage.width /2 - menuHolder_MC._width/2;
// center y
menuHolder_MC._y = Stage.height/2 - menuHolder_MC.mask_MC._height/2;
}
/////////////////////////////////////////////////////////////////////////////////////////
// centers the loaded image
function centerImage():Void{
shellImage_MC._x = Stage.width/2 - shellImage_MC._width/2;
shellImage_MC._y = Stage.height/2 - shellImage_MC._height/2;
}
/////////////////////////////////////////////////////////////////////////////////////////
// centers the info for the image
function centerInfo():Void{
info_MC._x = Stage.width/2 - shellImage_MC._width/2;
info_MC._y = Stage.height/2 - shellImage_MC._height/2;
}
/////////////////////////////////////////////////////////////////////////////////////////
// centers the tab button for the galleries menu
function centerGalleriesTab():Void{
galleriesButton_MC._x = Stage.width/2 - galleriesButton_MC._width/2;
}
/////////////////////////////////////////////////////////////////////////////////////////
// strechts the dark screen
function stretchDarkScreen():Void{
darkScreen_MC._width = Stage.width;
darkScreen_MC._height = Stage.height;
}
/////////////////////////////////////////////////////////////////////////////////////////
// stretches the background
function bgStretch():Void{
//vars
var maxW:Number = Stage.width*2;
var maxH:Number = Stage.height*2;
//streth
bg_MC._width = maxW;
bg_MC._height = maxH;
// pos
bg_MC._x = 0;
bg_MC._y = 0;
//keep aspect ratio Height
if(Stage.height > bg_MC._height or Stage.width < bg_MC._width){
bg_MC._height = Stage.height;
bg_MC._xscale = bg_MC._yscale;
}
//keep aspect ratio Width
if(Stage.width > bg_MC._width or Stage.height < bg_MC._height){
bg_MC._width = Stage.width;
bg_MC._yscale = bg_MC._xscale;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// tool tip
var toolMC:MovieClip;
function tooltip(msg:String):Void{
//create instanse of easyToolTip
toolMC = _parent.attachMovie('easyToolTipBalloon_MC', 'easyToolTipBalloon_MC', 1000);
//colors
toolMC.mesage_TXT.textColor = tooltipText;
var colorBar = new Color(toolMC.bar_MC);
var colorArrow = new Color(toolMC.arrow_MC);
colorBar.setRGB(tooltipBg);
colorArrow.setRGB(tooltipBg);
// write text inside tooltip
toolMC.mesage_TXT.text = msg;
// autosize for the text
toolMC.mesage_TXT.autoSize = true;
//resize bar
toolMC.bar_MC._width = toolMC.mesage_TXT._width +20;
toolMC.bar_MC._height = toolMC.mesage_TXT._height + 10;
//move instance around...
toolMC._y = _ymouse - 30;
// change tooltip x postion
if(_xmouse < Stage.width/2){
toolMC._x = _xmouse;
}else{
toolMC._x = _xmouse - toolMC._width + 20;
toolMC.arrow_MC._x = toolMC._width - toolMC.arrow_MC._width-10;
}
toolMC.startDrag();
}
/////////////////////////////////////////////////////////////////////////////////////////
//remove tooltip
function removeTooltip():Void{
//stop draggin and remove
toolMC.stopDrag();
removeMovieClip(toolMC);
}
/////////////////////////////////////////////////////////////////////////////////////////
// puts info over the image
function putInfo():Void{
//put info into stage
attachMovie("info_MC", "info_MC", 20);
//fade info buttons
info_MC._alpha = 0;
ZigoEngine.doTween(info_MC, "_alpha", 100, 1, "easeOutExpo", 1);
// size of infoPanel
info_MC.panel_MC._width = shellImage._width;
info_MC.panel_MC._height = shellImage._height;
//pos of info panel
info_MC.panel_MC._y = 0;
// panel transparency
info_MC.panel_MC._alpha = 0;
// invis
info_MC.panel_MC._visible = false;
// no click for panel
info_MC.panel_MC.onPress = function(){
}
// if set to false, hide info button
info_MC.infoButton_MC._visible = showInfoButton;
// if theres not link dont show link button
var link:String = imageList[currentImage].attributes.link;
if(link == undefined or link == ""){
info_MC.linkButton_MC._visible = false;
}
// if theres not uaddio dont show audio button
var audio:String = imageList[currentImage].attributes.audio;
if(audio == undefined or audio == ""){
info_MC.audioButton_MC._visible = false;
}
// ling button align
info_MC.linkButton_MC._x = info_MC.infoButton_MC._x + info_MC.infoButton_MC._width + 9;
// close button align
info_MC.closeButton_MC._x = shellImage._width - info_MC.closeButton_MC._width*1.5;
// audio align
if(link == undefined or link == ""){
// if theres not link button
info_MC.audioButton_MC._x = info_MC.infoButton_MC._x + info_MC.infoButton_MC._width + 9;
}else{
info_MC.audioButton_MC._x = info_MC.linkButton_MC._x + info_MC.linkButton_MC._width + 9;
}
//set labels
info_MC.infoButton_MC.textLabel = infoMsg;
info_MC.closeButton_MC.textLabel = closeMsg;
info_MC.linkButton_MC.textLabel = linkMsg;
info_MC.audioButton_MC.textLabel = audioMsg;
// events
info_MC.infoButton_MC.onPress = showInfo;
info_MC.closeButton_MC.onPress = closeImage;
// hide hand fo info panel
info_MC.panel_MC.onRollOver = function(){
// hide hand
this.useHandCursor = false;
};
// link button event
info_MC.linkButton_MC.onPress = function(){
// open link in new window
getURL(link, "_blank");
};
// audio button event
info_MC.audioButton_MC.onPress = function(){
// play audio
audioEvent(audio);
};
// roll over events
info_MC.infoButton_MC.onRollOver = miniToolTip;
info_MC.closeButton_MC.onRollOver = miniToolTip;
info_MC.linkButton_MC.onRollOver = miniToolTip;
info_MC.audioButton_MC.onRollOver = miniToolTip;
// roll out
info_MC.infoButton_MC.onRollOut = removeMiniToolTip;
info_MC.closeButton_MC.onRollOut = removeMiniToolTip;
info_MC.linkButton_MC.onRollOut = removeMiniToolTip;
info_MC.audioButton_MC.onRollOut = removeMiniToolTip;
// center info
centerInfo();
}
/////////////////////////////////////////////////////////////////////////////////////////
// display the mini tooltip
function miniToolTip():Void{
// movieclip alias
var mc:MovieClip = this;
// put it over the button
var miniMC:MovieClip = info_MC.attachMovie("miniToolTip_MC", "miniToolTip_MC", 10);
// label
miniMC.text_TXT.text = mc.textLabel;
// align text
miniMC.text_TXT.autoSize = true;
// stretch panel
miniMC.panel_MC._width = miniMC.text_TXT._width+3;
// center arrow for the balloon
miniMC.arrow_MC._x = miniMC.panel_MC._width/2 - miniMC.arrow_MC._width/2;
// position it
miniMC._x = mc._x + mc._width/2 - miniMC._width/2 ;
miniMC._y = mc._y - miniMC._height-3;
}
/////////////////////////////////////////////////////////////////////////////////////////
// removes the mini tool tip
function removeMiniToolTip():Void{
info_MC.miniToolTip_MC.removeMovieClip();
}
/////////////////////////////////////////////////////////////////////////////////////////
// function close image
function closeImage():Void{
// stop and cancel audio if theres audio
cancelAudio();
// close all thumbs
allThumbsClose();
// reset alpha in all tumbs
allThumbsFadeIn();
// reset original positions
contractThumbs();
// remove info
info_MC.removeMovieClip();
// unload loaded image
shellImage.unloadMovie();
// re start the moving
// after 1 second
// clear previous timers
clearInterval(closeTimerID);
// start moving seconds later
closeTimerID = setTimeout(startMovingMenu, (windowTime*1000));
function startMovingMenu(){
movingMenu = true;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// press info
function showInfo():Void{
// change button status
if(info_MC.infoButton_MC._currentframe == 1){
// if not opened...
info_MC.panel_MC._visible = true;
// fade in info panel
ZigoEngine.doTween(info_MC.panel_MC, "_alpha", 80, 1, "easeOutExpo");
// switch status
info_MC.infoButton_MC.gotoAndStop(2);
// put description
putDescription();
}else{
// if opened...
info_MC.panel_MC._visible = false;
// fade out info panel
ZigoEngine.doTween(info_MC.panel_MC, "_alpha", 0, 1, "easeOutExpo");
// switch status
info_MC.infoButton_MC.gotoAndStop(1);
//remove description
info_MC.desc_MC.removeMovieClip();
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// puts description
function putDescription():Void{
// put desc movie
info_MC.attachMovie("desc_MC", "desc_MC", 25);
// align desc_MC
var descMC:MovieClip = info_MC.desc_MC;
descMC._x = shellImage._width/4;
descMC._y = shellImage._height/3.5;
// put name
descMC.name_TXT.text = imageList[currentImage].attributes.name;
// align name
descMC.name_TXT.autoSize = "left";
descMC.name_TXT._y = -(descMC.name_TXT._height + 10);
// align content
//content alias
var contentMC:MovieClip = info_MC.desc_MC.content_MC;
contentMC.description_TXT._width = 300;
// get description
import mx.utils.XMLString;
var descText:String = imageList[currentImage].firstChild.nodeValue;
// descripttion dimensions
contentMC.description_TXT._width = shellImage._width/2;
contentMC.description_TXT._height = shellImage._height/2;
// put description
contentMC.description_TXT.htmlText = XMLString.unescape(descText);
//description align
contentMC.description_TXT.autoSize = "left";
// align scrollbar
//scrollbar alias
var scrollMC:MovieClip = info_MC.desc_MC.scroll_MC;
scrollMC._x = contentMC._x + contentMC._width + scrollMC._width + 10;
scrollMC.track_MC._height = shellImage._height/2;
// mask size
descMC.maskWidth= shellImage._width/2;
descMC.maskHeight = shellImage._height/2;
}
/////////////////////////////////////////////////////////////////////////////////////////
//create keyboard listener
// for keyboard navigation
var keyListener:Object = new Object();
Key.addListener(keyListener);
// keyboard navigation
function keyBoardNav():Void{
//key nav is only when not moving menu
// and galleriesMenu is closed
if(!movingMenu and !flagDarkScreen){
// events for vertical
switch (Key.getCode() ){
case Key.LEFT : moveNavKey('l'); break;
case Key.RIGHT : moveNavKey('r'); break;
}//switch
}// if not moving menu
}
/////////////////////////////////////////////////////////////////////////////////////////
// moves the navigation
function moveNavKey(pos:String):Void{
// remove cursor
removeCursor();
// move left
if(pos == 'l'){
//left boundaries limit
if(currentImage > 0){
// decrease current image
currentImage--;
// change it
changeImage();
}
}
// move right
if(pos == 'r'){
//left boundaries limit
if(currentImage < (imageList.length-1)){
// increment current image
currentImage++;
// change it
changeImage();
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// thumb events
function changeImage():Void {
// stop audio if theres audio
cancelAudio();
// make alias of current humbnail
var currentThumb:MovieClip = holder_MC["thumb_MC_" + currentImage];
// show loading animation
currentThumb.loadingAnimation_MC._visible = true;
// remove tool tip
removeTooltip();
// over animation
ZigoEngine.doTween(currentThumb, "_y", 0, 0.8, "easeOutExpo");
// remove previous loaded image
shellImage.unloadMovie();
//stop moving
movingMenu = false;
// reset alpha in all tumbs
allThumbsFadeIn();
// set all other thumbnails original width
allThumbsClose();
// reset original positions
contractThumbs();
//set alpha in this
ZigoEngine.doTween(currentThumb.loader_MC, "_alpha", 0 , windowTime*1.5, "easeOutExpo");
// unload previous info
info_MC.unloadMovie();
// lock holder to thumbnail distance
lockThumbnail(currentThumb);
// clear previous timers
clearInterval(timerID);
// load image later
timerID = setTimeout(loadImage, windowTime*1000, currentThumb);
}
/////////////////////////////////////////////////////////////////////////////////////////
// when audio is loaded...
function audioLoadHandler():Void{
//debug
//trace(bgm.getBytesLoaded()); trace(bgm.getBytesTotal());
// change state of audio button
info_MC.audioButton_MC.gotoAndStop(3);
// play music
bgm.start(audioOffSet,nLoops);
}
/////////////////////////////////////////////////////////////////////////////////////////
// manages the audio events
function audioEvent(audio:String){
// according to the status
switch(info_MC.audioButton_MC._currentframe){
case 1:
// load for the first time
bgm.loadSound(audio);
bgm.onLoad = audioLoadHandler;
// put loading animation for audio
info_MC.audioButton_MC.gotoAndStop(2);
break;
case 2:
// do nothing
break;
case 3:
// set volume to 0
bgm.setVolume(0);
// change status of button to
info_MC.audioButton_MC.gotoAndStop(4);
break;
case 4:
// set volume to 0
bgm.setVolume(100);
// change status of button to
info_MC.audioButton_MC.gotoAndStop(3);
break;
}
}
////////////////////////////////////////////////////////////////////////////////////////
// cancel the load of audio
function cancelAudio():Void{
bgm.loadSound("idontexist.mp3");
}
/////////////////////////////////////////////////////////////////////////////////////////
// loads the gallery
function loadGallery(n:Number):Void{
// clear previoulsy thumbnails
clearThumbs();
galleryNumber = n;
galleryXML.load(path);
// put no click dark screen
putDarkScreen();
}
/////////////////////////////////////////////////////////////////////////////////////////
// clear previous items from the gallery
function clearThumbs():Void{
for (var i:Number = 0; i<imageList.length; i++) {
holder_MC["thumb_MC_" + i].removeMovieClip();
}
}
|
|
Cette discussion est classée dans : var, mc, number, if, shellimage
Répondre à ce message
Sujets en rapport avec ce message
Gallerie Flash [ par theneoshaman ]
Bonjours amis Flasheurs !Je suis en train de créer une gallerie dynamique en flash (mon dieu, que c'est original !) et j'ai un pb (sans déconner :p)..
Lien sur image dans un diaporama flash ? [ par phobiahz ]
Bonjour a tous !Voila j'ai le code d'un diaporama (fixe mais avec fondu entre les images) dont les images sont chargées dynamiquement a partir d'un fi
galerie photo qui ne s'arrête pas... [ par amandaaa ]
Bonjour,j'ai un petit souci avec la galerie photo de mon site internet.je suis débutante en action script donc je vous remercie d'avance pour votre ai
Attacher plusieurs clips dans un même clip créé dans une classe [ par buzhug35 ]
Bonjour, Mon idée était de créer une horloge par le biais d'une classe UneHorloge à partir de 2 Clips de classes différentes : UnDisque et UneAiguille
Comment insérer plusieurs clips de classe dans un autre clip de classe [ par buzhug35 ]
Bonjour, Mon idée était de créer une horloge par le biais d'une classe UneHorloge à partir de 2 Clips de classes différentes : UnDisque et UneAiguill
menu xml flash [ par marcof ]
Bonjour à tous,J'ai réussi à créer un menu avec un sous menumais je n'arrive pas à mettre un sous menu sous le sous menu :)Si quelqu'un pouvait m'aid
Source diaporama ne fonctionne pas [ par fredflash92 ]
Bonjour,j'utilise le script suivant (que j'ai pris sur ce site) qui gère un diaporama avec des fichiers images externes listés dans un fichier XMLen
aide pour un debutant [ par coreangel ]
bonjour je vien de recup sur le site un diaporama (DIAPORAMA XML AVEC FONDU) de hiltonet j aimerai pouvoir lire des annime .swf mais je sais pas comme
Ajouter du texte depuis mon xml dans loadClip..; au secours [ par barytonlyrique ]
Bonsoir à tous...Je débute en Flash et je souhaite créer une pellicule qui affiche toutes mes images par mon xml et qui navigue droite/gauche selon la
relancer un diaporama XML sur un second XML [ par vegetalain ]
Salut tout le monde... alors voilà, je suis dsl mais je ne sais plus où j'ai pris le code dont je vais vous parler :/ snif.Le code suivant permet de c
Livres en rapport
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|