BnB-Aurelien | Merci de vos réponses, j'ai essayé ta méthode Abais, mais comme je l'ai précisé, je ne peux pas intégrer de caractères dans mon textField tout simplement car il n'y a pas de textField. Je n'ai plus de problème avec les accents quand il s'agit d'un loader avec une zone de texte dynamique et un loader xml externe. La le problème semble tout autre.
Comme programme pour éditer mon xml, j'ai essayé avec Dreamweaver, Microsoft Web Developer et le Notepad, c'est toujours pareil tant que j'enregistre bien en utf-8, mon xml marche avec les accents sur mes autres documents contenant ce fameux textfield.
Je vous mets tout mon code Actionscript qui est assez complexe. Merci d'avance.
Code :
- //import ease tweens
- import mx.transitions.Tween;
- import mx.transitions.easing.*;
- //set original thumb to alpha 0
- thumbHolder.inThumbHolder._visible = false;
- //set menu controls to invisible in the beginning
- menuBack_mc._visible = false;
- menuNext_mc._visible = false;
- //attach the description text for the main text
- this.attachMovie("descriptionText","descriptionText",this.getNextHighestDepth());
- //hide description text in the beginning
- descriptionText._alpha = 0;
- descriptionText._visible = false;
- //attach the over movie clip - for picture rollover
- this.attachMovie("over","over",this.getNextHighestDepth());
- //disable and hide over mc
- over.enabled = false;
- over._visible = false;
- //variables
- lastThumb = 0;
- pic = 0;
- startX = 0;
- startY = 0;
- currentTotal = 0;
- //hide objects for the start
- loader._alpha = 0;
- bg._alpha = 0;
- xClose._alpha = 0;
- //------------------------------------Load XML Data
- function loadXML(success) {
- if (success) {
- xmlNode = this.firstChild;
- thumb = [];
- image = [];
- txt = [];
- total = xmlNode.childNodes.length;
- //for loop for each picture
- for (i=0; i<total; i++) {
- thumb[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
- image[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
- txt[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
- }
- //Colors from XML file
- backColor = this.firstChild.attributes.backColor;
- //set main picture background color
- bgColor = new Color(bg.inBg);
- bgColor.setRGB(backColor);
- xCloseColor = this.firstChild.attributes.xCloseColor;
- //set main picture close button color (the big X)
- xColor = new Color(xClose);
- xColor.setRGB(xCloseColor);
- controlsOutColor = this.firstChild.attributes.controlsOutColor;
- controlsOverColor = this.firstChild.attributes.controlsOverColor;
- //set menu control colors
- menuBackOut = new Color(menuBack_mc);
- menuBackOut.setRGB(controlsOutColor);
- menuNextOut = new Color(menuNext_mc);
- menuNextOut.setRGB(controlsOutColor);
- //thumb attributes
- columns = Number(this.firstChild.attributes.thumbColumns);
- rows = Number(this.firstChild.attributes.thumbRows);
- spacer = Number(this.firstChild.attributes.spacer);
- //total images per page
- totalPerPage = columns*rows;
- //width of each thumbnail
- thumbWidth = Number(this.firstChild.attributes.thumbWidth);
- thumbHeight = Number(this.firstChild.attributes.thumbHeight);
- //border size of main pic background
- border = Number(this.firstChild.attributes.border);
- //if the total of pictures is larger than
- //total per page, then show menu controls
- if (total>totalPerPage) {
- menuBack_mc._visible = true;
- menuNext_mc._visible = true;
- }
- //build first page of thumbs
- buildThumbs(0);
- } else {
- trace("Error loading XML" );
- }
- }
- xmlData = new XML();
- xmlData.ignoreWhite = true;
- xmlData.onLoad = loadXML;
- xmlData.firstChild.childNodes[0].firstChild.nodeValue
- xmlData.load("work.xml" );
- //-----------------------------------FUNCTIONS
- //position menu controls
- menuBack_mc._x = 32.5-(menuBack_mc._width/2);
- menuBack_mc._y = 225-(menuBack_mc._height/2);
- menuNext_mc._x = 900-32.5-(menuNext_mc._width/2);
- menuNext_mc._y = 225-(menuNext_mc._height/2);
- //menu controls on rollover
- menuBack_mc.onRollOver = function() {
- //color arrow on rollover
- menuBackOver = new Color(menuBack_mc);
- menuBackOver.setRGB(controlsOverColor);
- };
- menuNext_mc.onRollOver = function() {
- //color arrow on rollover
- menuNextOver = new Color(menuNext_mc);
- menuNextOver.setRGB(controlsOverColor);
- };
- //menu controls on rollout
- menuBack_mc.onRollOut = function() {
- //color arrow on rollout
- menuBackOut = new Color(menuBack_mc);
- menuBackOut.setRGB(controlsOutColor);
- };
- menuNext_mc.onRollOut = function() {
- //color arrow on rollout
- menuNextOut = new Color(menuNext_mc);
- menuNextOut.setRGB(controlsOutColor);
- };
- //---------------------------------
- //thumb rollover function
- function menuRollOver(mc) {
- //alpha to 100 on thumb that has rollover
- alphaTw = new Tween(thumbHolder["e"+int(mc)], "_alpha", Regular.easeOut, 35, 100, 15, false);
- }
- //thumb rollout function
- function menuRollOut(mc) {
- //alpha back to 35 on thumb that has rollout
- alphaTw = new Tween(thumbHolder["e"+int(mc)], "_alpha", Regular.easeIn, 100, 35, 15, false);
- }
- //resize thumbs to XML attributes
- function resizeThumbs(mc) {
- //resize background
- mc.bg._width = thumbWidth;
- mc.bg._height = thumbHeight;
- //center preloader
- mc.preloader_txt._x = (thumbWidth/2)-(mc.preloader_txt._width/2);
- mc.preloader_txt._y = (thumbHeight/2)-(mc.preloader_txt._height/2)+5;
- }
- //build thumbnails function
- function buildThumbs(n) {
- startX = 0;
- startY = 0;
- currentTotal = 0;
- //X and Y position on where to start thumbnails
- xPos = ((900-((thumbWidth*columns)+(spacer*columns-1)))/2)+(spacer/2);
- yPos = ((450-((thumbHeight*rows)+(spacer*rows-1)))/2)+(spacer/2);
- //remove old thumbnails
- for (i=0; i<total; i++) {
- removeMovieClip(thumbHolder["e"+int(i)]);
- }
- //for loop for each picture
- for (i=n; i<total; i++) {
- //while total thumbs per page is not met
- if (currentTotal<totalPerPage) {
- //duplicate main thumbnail
- var e:MovieClip = thumbHolder.inThumbHolder.duplicateMovieClip("e"+i, i);
- //resize thumbnails to XML attributes
- resizeThumbs(e);
- //position thumbnails
- e._x = xPos+(thumbWidth+spacer)*((currentTotal)%columns);
- e._y = yPos+(thumbHeight+spacer)*(int((currentTotal)/columns));
- //load thumbnail
- e.thumbLoader.loadMovie(thumb[i]);
- //thumbnail loading
- _root["thumbInterval"+i] = setInterval(checkProgressThumbs, 1, e, i);
- //record thumbnails
- lastThumb++;
- currentTotal++;
- //assign thumbnail position
- e.num = i;
- //set thumb to alpha 35 when loaded
- e._alpha = 35;
- //thumbnail on release
- e.onRelease = function() {
- //assign current pic
- pic = this.num;
- //load picture
- menuRelease(this.num);
- };
- //thumbnail rollover
- e.onRollOver = function() {
- menuRollOver(this.num);
- };
- //thumbnail rollout
- e.onRollOut = e.onReleaseOutside=function () {
- menuRollOut(this.num);
- };
- }
- }
- //position and load text which tells what pictures user is looking through
- menu_txt._x = xPos;
- menu_txt._y = yPos-menu_txt._height;
- menu_txt.autoSize = "left";
- menu_txt.text = n+1+" - "+lastThumb+" / "+total;
- }
- //back arrow on release function
- menuBack_mc.onRelease = function() {
- //if not the first page
- if (lastThumb>totalPerPage) {
- //assign current thumbs
- lastThumb = lastThumb-totalPerPage-currentTotal;
- //load thumbs
- buildThumbs(lastThumb);
- }
- };
- //next arrow on release function
- menuNext_mc.onRelease = function() {
- //if not the last page
- if (lastThumb<total) {
- //load thumbs
- buildThumbs(lastThumb);
- }
- };
- //----------------------------------------------------
- //align objects when main picture loads
- function alignObjects() {
- //if there is a picture description
- if (descriptionText.description_txt.text != "" ) {
- //load and position text and text background
- descriptionText.description_txt.autoSize = "left";
- descriptionText.description_txt._width = loader._width-10;
- descriptionText.bg._width = loader._width;
- descriptionText.bg._height = descriptionText.description_txt._height+10;
- }
- //position picture description text holder
- descriptionText._x = loader._x;
- descriptionText._y = loader._y+loader._height-descriptionText.bg._height;
- //position the main loader centered on the stage
- loader._x = 450-(loader._width)/2;
- loader._y = 200-(loader._height)/2;
- //position and stretch the main picture background
- bg._x = 450;
- bg._y = 200;
- bg.inBg._width += (loader._width+border-bg.inBg._width)/4;
- bg.inBg._height += (loader._height+border-bg.inBg._height)/4;
- //position and stretch main picture rollOver movieclip
- over._x = 450-(loader._width)/2;
- over._y = 200-(loader._height)/2;
- over._width = loader._width;
- over._height = loader._height;
- //position the main picture close button
- xClose._x = loader._x+loader._width+(border/2)+30;
- xClose._y = loader._y+(loader._height/2);
- }
- //initialize the main picture - get everything ready
- function initPic() {
- //function "hidePage" from the main INDEX file
- // - this will hide the main page within the main file,
- // when the main picture is brought up
- _root.hidePage();
- //fade out objects
- alphaTw = new Tween(menuBack_mc, "_alpha", Regular.easeOut, 100, 0, 15, false);
- alphaTw = new Tween(menuNext_mc, "_alpha", Regular.easeOut, 100, 0, 15, false);
- alphaTw = new Tween(menu_txt, "_alpha", Regular.easeOut, 100, 0, 15, false);
- //disable/enable objects
- xClose.enabled = true;
- menuBack_mc.enabled = false;
- menuNext_mc.enabled = false;
- //for loop to fade out / disable all thumbnails
- for (i=0; i<total; i++) {
- _root["thumbsOutInterval"+i] = setInterval(thumbsAlphaOut, 5, i);
- thumbHolder["e"+int(i)].enabled = false;
- }
- //set initial bg position and size
- bg.inBg._width = 50;
- bg.inBg._height = 50;
- bg._x = 450;
- bg._y = 200;
- }
- //load main picture function
- function loadPic(mc) {
- //hide and disable objects
- loader._alpha = 0;
- descriptionText.enabled = false;
- descriptionText._visible = false;
- xClose.enabled = false;
- bg.enabled = false;
- over.enabled = false;
- over._visible = false;
- //load main picture
- loader.loadMovie(image[mc]);
- //load main description text
- descriptionText.description_txt.htmlText = txt[mc];
- //loading / fading function
- this.onEnterFrame = function() {
- //get picture size
- bLoaded = loader.getBytesLoaded();
- bTotal = loader.getBytesTotal();
- //fade in picture background
- if (bg._alpha<100) {
- bg._alpha += 10;
- }
- //if picture has not loaded
- if (bLoaded != bTotal) {
- //show percentage loaded
- bg.preloader_txt.text = Math.round((bLoaded/bTotal)*100);
- //if picture is loaded
- } else if (bLoaded>=bTotal && bLoaded>100 && bTotal>100) {
- bg.preloader_txt.text = "100";
- //call align objects function
- alignObjects();
- //fade in close button
- if (xClose._alpha<100) {
- xClose._alpha += 10;
- }
- //if picture background is in the right position
- if ((bg.inBg._width>loader._width+(border-1)) && (bg.inBg._width<loader._width+(border+1)) && (bg.inBg._height>loader._height+(border-1)) && (bg.inBg._height<loader._height+(border+1))) {
- //hide preloader
- bg.preloader_txt.text = "";
- //fade in main picture
- if (loader._alpha<100) {
- loader._alpha += 10;
- }
- //if picture has faded in to alpha 100
- if (loader._alpha>=100) {
- //enabled objects
- xClose.enabled = true;
- over.enabled = true;
- over._visible = true;
- //if there is a picture description
- if (descriptionText.description_txt.text != "" ) {
- //enable picture description
- descriptionText.enabled = true;
- descriptionText._alpha = 0;
- descriptionText._visible = true;
- }
- //if picture has loaded, delete the function
- delete this.onEnterFrame;
- }
- }
- }
- };
- }
- //menu release function
- function menuRelease(mc) {
- //call function to initialize image
- initPic();
- //call function to load image
- loadPic(mc);
- }
- //main picture on press function
- //if user clicks on the main picture, it will load the next one
- over.onPress = function() {
- //if not the last picture
- if (pic<total-1) {
- pic++;
- loadPic(pic);
- }
- };
- //main picture rollOver function - to show the picture description
- over.onRollOver = function() {
- alphaTw = new Tween(descriptionText, "_alpha", Regular.easeIn, 0, 100, 7, false);
- };
- //main picture rollOut function - to hide the picture description
- over.onRollOut = function() {
- alphaTw = new Tween(descriptionText, "_alpha", Regular.easeIn, 100, 0, 7, false);
- };
- //main picture close button (big X) on Release function
- xClose.onRelease = function() {
- //enable menu controls
- menuBack_mc.enabled = true;
- menuNext_mc.enabled = true;
- //fade in/out objects
- alphaTw = new Tween(menuBack_mc, "_alpha", Regular.easeOut, 0, 100, 15, false);
- alphaTw = new Tween(menuNext_mc, "_alpha", Regular.easeOut, 0, 100, 15, false);
- alphaTw = new Tween(menu_txt, "_alpha", Regular.easeOut, 0, 100, 15, false);
- alphaTw = new Tween(xClose, "_alpha", Regular.easeOut, 100, 0, 5, false);
- alphaTw = new Tween(loader, "_alpha", Regular.easeOut, 100, 0, 5, false);
- alphaTw = new Tween(bg, "_alpha", Regular.easeOut, 100, 0, 5, false);
- //for loop for each thumbnail to fade in and enable it
- for (i=0; i<total; i++) {
- _root["thumbsInInterval"+i] = setInterval(thumbsAlphaIn, 5, i);
- thumbHolder["e"+int(i)].enabled = true;
- }
- //function "showPage" from the main INDEX file
- // - this will show the main page within the main file,
- // when the main picture is closed down
- _root.showPage();
- //disable all main picture objects
- xClose.enabled = false;
- bg.enabled = false;
- over.enabled = false;
- over._visible = false;
- descriptionText.enabled = false;
- descriptionText._visible = false;
- };
- //function which loads the thumbnails
- function checkProgressThumbs(e, i):Void {
- //get thumbnail size
- bLoaded = e.thumbLoader.getBytesLoaded();
- bTotal = e.thumbLoader.getBytesTotal();
- //percent loaded
- pLoaded = Math.round((bLoaded/bTotal)*100);
- //if thumbnail has not loaded yet
- if (bLoaded<bTotal) {
- //hide thumbnail - alpha to 0 for fade in
- e.thumbLoader.enabled = false;
- e.thumbLoader._alpha = 0;
- //show percent loaded on thumbnail holder
- e.preloader_txt.text = pLoaded;
- //if thumbnail is loaded
- } else if (bLoaded>=bTotal && bLoaded>100 && bTotal>100) {
- //hide preloader
- e.preloader_txt.text = "";
- //fade in thumbnail
- if (e.thumbLoader._alpha<100) {
- e.thumbLoader._alpha = e.thumbLoader._alpha+10;
- }
- //if thumbnail has faded in to alpha 100, clear interval
- if (e.thumbLoader._alpha>=100) {
- clearInterval(_root["thumbInterval"+i]);
- }
- }
- }
- //function to fade out thumbnails when thumbnail is clicked on
- function thumbsAlphaOut(i):Void {
- //fade thumb out
- thumbHolder["e"+int(i)]._alpha = thumbHolder["e"+int(i)]._alpha-5;
- //if faded out to alpha 0, clear interval
- if (thumbHolder["e"+int(i)]._alpha<=0) {
- clearInterval(_root["thumbsOutInterval"+i]);
- }
- }
- //function to fade in thumbnails when main picture is closed down
- function thumbsAlphaIn(i):Void {
- //fade thumb in
- thumbHolder["e"+int(i)]._alpha = thumbHolder["e"+int(i)]._alpha+5;
- //if faded in to alpha 100, clear interval
- if (thumbHolder["e"+int(i)]._alpha>=35) {
- clearInterval(_root["thumbsInInterval"+i]);
- }
- }
|
|