a na j'ai pas utiliser cette technique pour faire cette page.. nan c'est bon j'ai vue le bug et j'ai pu le corriger. Bon quelqu'un m'a aider a le faire.... c'était tout bète perso j'avais oublé de remomer les pages en action scripts...... bon voila pour toi tu voulait faire un truc en xml na.. des photo et de txt en meme temps je sais comment le faire. c'est tout simple 1) alors crée 3 page holder sur ta page flash 2) voici les action scripts pour relier les container et le ficher xml note: qu'il contient aussi des easing transition pour donner un aspect professionel mais aussi plus propre //easing tweens import mx.transitions.Tween; import mx.transitions.easing.*;
//set menu arrows to invisible in the beginning arrowUp_mc._visible = false; arrowDown_mc._visible = false;
//------------------------------LOAD XML DATA
function loadXML(success) { if (success) { xmlNode = this.firstChild; title = []; date = []; description = []; main = []; total = xmlNode.childNodes.length; //for loop for each menu item for (i=0; i<total; i++) { title[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; date[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue; description[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue; main[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue; } //GET COLORS originalMenuTitleColor = this.firstChild.attributes.originalMenuTitleColor; originalMenuDateColor = this.firstChild.attributes.originalMenuDateColor; currentMenuTitleColor = this.firstChild.attributes.currentMenuTitleColor; currentMenuDateColor = this.firstChild.attributes.currentMenuDateColor; mainTitleColor = this.firstChild.attributes.mainTitleColor;
arrowOverColor = this.firstChild.attributes.arrowOverColor; arrowOutColor = this.firstChild.attributes.arrowOutColor; //color up arrow arrowOut = new Color(arrowUp_mc); arrowOut.setRGB(arrowOutColor); //color down arrow on rollout arrowOut = new Color(arrowDown_mc); arrowOut.setRGB(arrowOutColor);
//GET DIMENSIONS menuSpacing = Number(this.firstChild.attributes.menuSpacing); textHolderXStart = Number(this.firstChild.attributes.textHolderXStart); textHolderXFinish = Number(this.firstChild.attributes.textHolderXFinish); mainTextWidth = Number(this.firstChild.attributes.mainTextWidth); scrollbarX = Number(this.firstChild.attributes.scrollbarX);
//create menu createDates(); //load first menu item loadText(0); } else { textHolder.description_txt.text = "Error loading XML file"; } } xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadXML; xmlData.load("news.xml");
//---------------------------------------------------
//create dateMenu movieclip which will hold the menu this.createEmptyMovieClip("dateMenu",this.getNextHighestDepth()); //position the menu dateMenu._x = 25; dateMenu._y = 25; //create a mask for the menu, so it hides the ones off screen this.createEmptyMovieClip("dateMenuMask",this.getNextHighestDepth()); //attach the mask to the movieclip dateMenuMask.attachMovie("dateMask","dateMask",this.getNextHighestDepth()); //position the dateMenuMask dateMenuMask._x = 0; dateMenuMask._y = 25; //Apply the mask dateMenu.setMask(dateMenuMask);
currentDate = 0; dateMenuStartY = 0;
//create the menu function function createDates() { for (i=0; i<total; i++) { //create a button for each menu item dateMenu.attachMovie("dateHolder","a"+i,i); //assign button a = dateMenu["a"+i]; //apply a hit which will last till next button //(No spaces in between - cleaner mouse transition while easing across) a.hit._height = menuSpacing; //apply spacer a._y = dateMenuStartY; dateMenuStartY += menuSpacing;
//assign number for each menu item a.num = i;
//apply text for title and date a.title_txt.autoSize = "left"; a.date_txt.autoSize = "left"; a.title_txt.text = title[i]; a.date_txt.text = date[i];
//on press functions a.onPress = function() { //assign a current menu item currentDate = this.num; //load menu item text loadText(this.num); }; //on rollover function a.onRollOver = function() { menuRollOver(this.num); }; //on rollout function a.onRollOut = function() { menuRollOut(); }; //center menu between 0 and line dateMenu._x = 100-(dateMenu._width/2); //if menu is smaller than stage height, center menu vertically if (dateMenu._height<400) { dateMenu._y = (450/2)-(dateMenu._height/2); //else set the menu at 25, and show arrows } else { dateMenu._y = 25; arrowUp_mc._visible = true; arrowDown_mc._visible = true; } //record number for arrows recordNumber = 1; } }
//CREATE MAIN TEXT
function loadText(i) { //remove scrollbar if showing from before removeMovieClip(scrollbar);
//assign color for title mainTitle = new Color(textHolder.description_txt); mainTitle.setRGB(mainTitleColor);
//No color through ActionScript for the main text because //it is html text, and if there are pictures and such, they //would be colored as well. To change the color of the main text //either click on the text box and change it there, or because //the XML uses CDATA tags, you can use the <font color="#color"> //tags within the XML
textHolder.description_txt.autoSize = "left"; textHolder.main_txt.autoSize = "left"; //set main text width according to the XML attributes textHolder.description_txt._width = mainTextWidth; textHolder.main_txt._width = mainTextWidth; //assign the title and main text textHolder.description_txt.text = description[i]; textHolder.main_txt.htmlText = main[i];
//text to be alpha 0 in beginning for fade in effect textHolder._alpha = 0;
//fade text in alphaTw = new Tween(textHolder, "_alpha", Strong.easeInOut, 0, 100, 25, false); //tween for text move in effect sideTween = new Tween(textHolder, "_x", Strong.easeInOut, textHolderXStart, textHolderXFinish, 25);
//if the text is longer than 400, apply a scroller if (textHolder._height>400) { scroller(); //else just center it on the page } else { textHolder._y = (450/2)-(textHolder._height/2); } }
//---------------MENU COLORS
this.onEnterFrame = function() { //for loop for each menu item for (i=0; i<total; i++) { //original menu title color origTitle = new Color(dateMenu["a"+i].title_txt); origTitle.setRGB(originalMenuTitleColor); //original menu date color origDate = new Color(dateMenu["a"+i].date_txt); origDate.setRGB(originalMenuDateColor); } //current menu title color currTitle = new Color(dateMenu["a"+currentDate].title_txt); currTitle.setRGB(currentMenuTitleColor); //current menu date color currDate = new Color(dateMenu["a"+currentDate].date_txt); currDate.setRGB(currentMenuDateColor);
}; //--------------------BUTTONS
currentPos = dateMenu._y;
//up arrow on release function arrowUp_mc.onRelease = function() { //if not at the first menu item if (recordNumber<>1) { //slide up tween slideUp = new Tween(dateMenu, "_y", Strong.easeInOut, currentPos, currentPos+400, 25); //record current position recordNumber -= 10; currentPos += 400; } }; //down arrow on release function arrowDown_mc.onRelease = function() { //if not at the last menu item if (recordNumber+9<total) { //slide down tween slideDown = new Tween(dateMenu, "_y", Strong.easeInOut, currentPos, currentPos-400, 25); //record current position recordNumber += 10; currentPos -= 400; } };
//ON ROLLOVER arrowUp_mc.onRollOver = function() { //color up arrow on rollover arrowOver = new Color(arrowUp_mc); arrowOver.setRGB(arrowOverColor); }; arrowDown_mc.onRollOver = function() { //color down arrow on rollover arrowOver = new Color(arrowDown_mc); arrowOver.setRGB(arrowOverColor); };
//ON ROLLOUT arrowUp_mc.onRollOut = function() { //color up arrow on rollout arrowOut = new Color(arrowUp_mc); arrowOut.setRGB(arrowOutColor); }; arrowDown_mc.onRollOut = function() { //color down arrow on rollout arrowOut = new Color(arrowDown_mc); arrowOut.setRGB(arrowOutColor); };
//---------------KEY LISTENER
//clearListener is called from the INDEX file when clicked on the //"News" button. This removes the old Key and Mouse listeners so that //the listeners would not overlap. function clearListener() { //For up/down arrow keys Key.removeListener(keyListener); //For page scrolling Mouse.removeListener(mouseListener); }
//key listener for up / down keys var keyListener:Object = new Object(); keyListener.onKeyDown = function() { //UP ARROW if (Key.getCode() == 38) { //if not the first date menu item if (currentDate>0) { //load the date menu item main text loadText(currentDate-1); //record position currentDate--; //if not the first overall and the first on a next page... if (currentDate+1<recordNumber && recordNumber<>1) { //slide up tween slideUp = new Tween(dateMenu, "_y", Strong.easeInOut, currentPos, currentPos+400, 25); //record the position recordNumber -= 10; currentPos += 400; } } } //DOWN ARROW if (Key.getCode() == 40) { //if not the last menu item if (currentDate<(total-1)) { //load the date menu item main text loadText(currentDate+1); //record position currentDate++; //if the last menu item on page if (currentDate+1>recordNumber+9) { //slide down tween slideDown = new Tween(dateMenu, "_y", Strong.easeInOut, currentPos, currentPos-400, 25); //record the position recordNumber += 10; currentPos -= 400; } } } }; Key.addListener(keyListener);
//--------------------DATE MENU ROLLOVER/ROLLOUT
//mouse rollover for each menu item function menuRollOver(mc) { for (i=0; i<total; i++) { //alpha 50 for all menu items dateMenu["a"+i]._alpha = 50; //alpha 100 for highlighted menu item dateMenu["a"+mc]._alpha = 100; } } //mouse rollout for each menu item function menuRollOut() { for (i=0; i<total; i++) { dateMenu["a"+i]._alpha = 100; } }
//--------------------SCROLLER
function scroller() { //set the main text at y=25 textHolder._y = 25; //attach scrollbar this.attachMovie("scrollbar","scrollbar",this.getNextHighestDepth()); //fade in scrollbar alphaScrollbar = new Tween(scrollbar, "_alpha", Strong.easeInOut, 0, 100, 15, false); //position scrollbar scrollbar._y = 25; scrollbar._x = scrollbarX;
//on press function scrollbar.scrollbarBtn.onPress = function() { //user is only able to drag on the scrollbar background this.startDrag(false,scrollbar.scrollbarBG._x,scrollbar.scrollbarBG._y,scrollbar.scrollbarBG._x,scrollbar.scrollbarBG._height-this._height); //Call scrollThumbs function for easing textHolder.onEnterFrame = scrollThumbs; dragging = true;
}; //on release function scrollbar.scrollbarBtn.onRelease = scrollbar.scrollbarBtn.onReleaseOutside=function () { stopDrag(); dragging = false; scrollbar.scrollbarBtn.gotoAndPlay("out"); delete this.onEnterFrame; };
scrollbar.scrollbarBtn.onRollOver = function() { scrollbar.scrollbarBtn.gotoAndPlay("over"); }; scrollbar.scrollbarBtn.onRollOut = function() { scrollbar.scrollbarBtn.gotoAndPlay("out"); }; //text easing function function scrollThumbs() { var easeText = -this._parent.scrollbar.scrollbarBtn._y*(((this._height-this._parent.scrollbar.scrollbarBtn._height)/(this._parent.scrollbar.scrollbarBG._height-this._parent.scrollbar.scrollbarBtn._height))-1); // change .2 for speed this.Y = (easeText-this._y+25)*.2; this._y += this.Y; if (Math.abs(easeText-this._y)<1 && !dragging) { delete this.onEnterFrame; } } // creating the mousewheel function
//When user uses the mouse wheel var mouseListener:Object = new Object();
mouseListener.onMouseWheel = function(delta) { //change the 4 for how much to scroll on single scroll scrollbar.scrollbarBtn._y -= delta*4; if (scrollbar.scrollbarBtn._y<0) { scrollbar.scrollbarBtn._y = 0; } if (scrollbar.scrollbarBtn._y+scrollbar.scrollbarBtn._height>400) { scrollbar.scrollbarBtn._y = 400-scrollbar.scrollbarBtn._height; } //call ease text function textHolder.onEnterFrame = scrollThumbs; };
// adding the listener to the Mouse object Mouse.addListener(mouseListener); } une fois fait tu doit cré tes fichier xml et tes ficher sourcer ou il vas récuperer les pics bon voici les fichier sources <a class="postlink" href="http://www.megaupload.com/?d=5WS5ZUE6">http://www.megaupload.com/?d=5WS5ZUE6</a> sa vas plus t'aides bon je l'ai fait en flash 8 mais perso change de version de flash et prend flash adobe cs4 parceque tou les tuto que je vais commence a faire pour kommunauty sera l'ad sus.. |