Flash-XML aide

  • elektric
  • Graduate
  • Graduate
  • Avatar de l’utilisateur
  • Inscription: Sep 20, 2004
  • Messages: 130
  • Loc: Mexico
  • Status: Offline

Message Septembre 5th, 2007, 5:57 pm

Bonjour, J'ai besoin d'aide ici, j'ai ce menu XML simple qui est une liste d'articles tirés à partir d'un fichier xml comme ceci:

Code: [ Select ]
<lasvillas>
<villas>
<nombre>Diosa de la luna</nombre>
<link>1</link>
</villas>
<villas>
<nombre>Hacienda de Santa Rita</nombre>
<link>2</link>
</villas>
</lasvillas>
  1. <lasvillas>
  2. <villas>
  3. <nombre>Diosa de la luna</nombre>
  4. <link>1</link>
  5. </villas>
  6. <villas>
  7. <nombre>Hacienda de Santa Rita</nombre>
  8. <link>2</link>
  9. </villas>
  10. </lasvillas>


vous trouverez une valeur <link>, au lieu d'utiliser cette valeur comme un lien vers un autre fichier, j'ai besoin de ce à un onPress à prendre à l'utilisateur d'un autre cadre sur ma ligne de temps, ie. gotoAndPlay...

J'imagine que je dois créer un clip vide pour chaque groupe de valeurs sur mon xml et lui donner une action, mais comment?


Ceci est mon actionscript courant juste au cas où vous en avez besoin.
Code: [ Select ]
headlineXML = new XML();
headlineXML.onLoad = myLoad;
headlineXML.load("villasrsst.xml");

function myLoad(ok) {
    if (ok == true) {
        Publish(this.firstChild);
    }
}

function Publish(HeadlineXMLNode) {
    if (HeadlineXMLNode.nodeName.toUpperCase() == "LASVILLAS") {
        content = "";
        lasvillas = HeadlineXMLNode.firstChild;
        while (lasvillas != null) {
            if (lasvillas.nodeName.toUpperCase() == "VILLAS") {
                lead = "";
                mylink = "";
                element = lasvillas.firstChild;
                i = 30;
                while (element != null) {
                    if (element.nodeName.toUpperCase() == "NOMBRE") {
                        lead = element.firstChild.nodeValue;
                    }
                    if (element.nodeName.toUpperCase() == "LINK") {
                        mylink = element.firstChild.nodeValue;
                    }

                    element = element.nextSibling;
                }
                // Like HTML with link to external page
                //content += "<font size='+2' color='#3366cc'><a href='"+mylink+"'>"+lead+"</a></font><br><br>";
                
                // trying to build the same but whish to make this a button with a onPress like function.
                content += lead+"<br><br>";
                txt.htmltext=content;
            }
            lasvillas = lasvillas.nextSibling;
        }
    }
}
  1. headlineXML = new XML();
  2. headlineXML.onLoad = myLoad;
  3. headlineXML.load("villasrsst.xml");
  4. function myLoad(ok) {
  5.     if (ok == true) {
  6.         Publish(this.firstChild);
  7.     }
  8. }
  9. function Publish(HeadlineXMLNode) {
  10.     if (HeadlineXMLNode.nodeName.toUpperCase() == "LASVILLAS") {
  11.         content = "";
  12.         lasvillas = HeadlineXMLNode.firstChild;
  13.         while (lasvillas != null) {
  14.             if (lasvillas.nodeName.toUpperCase() == "VILLAS") {
  15.                 lead = "";
  16.                 mylink = "";
  17.                 element = lasvillas.firstChild;
  18.                 i = 30;
  19.                 while (element != null) {
  20.                     if (element.nodeName.toUpperCase() == "NOMBRE") {
  21.                         lead = element.firstChild.nodeValue;
  22.                     }
  23.                     if (element.nodeName.toUpperCase() == "LINK") {
  24.                         mylink = element.firstChild.nodeValue;
  25.                     }
  26.                     element = element.nextSibling;
  27.                 }
  28.                 // Like HTML with link to external page
  29.                 //content += "<font size='+2' color='#3366cc'><a href='"+mylink+"'>"+lead+"</a></font><br><br>";
  30.                 
  31.                 // trying to build the same but whish to make this a button with a onPress like function.
  32.                 content += lead+"<br><br>";
  33.                 txt.htmltext=content;
  34.             }
  35.             lasvillas = lasvillas.nextSibling;
  36.         }
  37.     }
  38. }


Merci à l'avance.
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Septembre 5th, 2007, 5:57 pm

  • IceCold
  • Guru
  • Guru
  • Avatar de l’utilisateur
  • Inscription: Nov 05, 2004
  • Messages: 1254
  • Loc: Ro
  • Status: Offline

Message Septembre 6th, 2007, 7:05 am

il suffit de créer un nouveau clip dans votre bibliothèque (Ctrl + F8) et place à l'intérieur d'un texte dynamique et appeler son exemple: dtext
Exporter le film pour ActionScript (clic droit sur it-> lien-> nom de liaison -> nommez-le "link")
Ensuite, pour chaque lien lire à partir du fichier XML, joindre le film et définir ses coordonnées et son texte.
à savoir:
Code: [ Select ]
// create first a holder for the links:
this.createEmptyMovieClip("mcLinks", 100); // or any other depth or next highest depth
nLinkIndex = 0;
while (... read xml ...)
{
 ....
  mylink = element.firstChild.nodeValue;
  crtLink = mcLinks.attachMovie("link", "link"+nLinkIndex, nLinkIndex);
  crtLink._x = x; // set x and y according to your needs
  crtLink._y = y;
  crtLink.dtext.text = myLink;
  crtLink.dtext.autoSize = true;
  crtLink.onRelease = function()
  {
    // jump somewhere, function of the link, best to a frame with a name read from xml file
   // i.e.: _root.gotoAndPlay("frame_name");
  }
}
  1. // create first a holder for the links:
  2. this.createEmptyMovieClip("mcLinks", 100); // or any other depth or next highest depth
  3. nLinkIndex = 0;
  4. while (... read xml ...)
  5. {
  6.  ....
  7.   mylink = element.firstChild.nodeValue;
  8.   crtLink = mcLinks.attachMovie("link", "link"+nLinkIndex, nLinkIndex);
  9.   crtLink._x = x; // set x and y according to your needs
  10.   crtLink._y = y;
  11.   crtLink.dtext.text = myLink;
  12.   crtLink.dtext.autoSize = true;
  13.   crtLink.onRelease = function()
  14.   {
  15.     // jump somewhere, function of the link, best to a frame with a name read from xml file
  16.    // i.e.: _root.gotoAndPlay("frame_name");
  17.   }
  18. }

thats nature de tous.
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”
  • elektric
  • Graduate
  • Graduate
  • Avatar de l’utilisateur
  • Inscription: Sep 20, 2004
  • Messages: 130
  • Loc: Mexico
  • Status: Offline

Message Septembre 11th, 2007, 6:00 pm

Cool, merci, je vais essayer le plus vite possible.

Afficher de l'information

  • Total des messages de ce sujet: 3 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 60 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC