0 Replies Latest reply on Sep 15, 2011 4:29 PM by melas076

    how to change Image with Text?

    melas076

      dear,

       

      i would like to know how can i change images with texts when i click on the submenu links on the left?

       

      i have 3 MCs and 1 XML file.

       

      1. sub_bg:

       


      function linkF(s:String):Void
      {
        _root.bg.txt.htmlText = s;
      }

       

      2. bg :

       

      stop();
      var styles = new TextField.StyleSheet();
      styles.load("css/main.css");

       

      _root.bg.txt.html = true;
      _root.bg.txt.styleSheet = styles;
      _root.sub_bg.subTXT.html = true;
      _root.sub_bg.subTXT.styleSheet = styles;

       

      var newsXML:XML = new XML();
      newsXML.ignoreWhite = true;
      newsXML.onLoad = function(success) {
              if (success) {
         
      var defaultp:String =  newsXML.childNodes[0].childNodes[1].childNodes[0].firstChild.nodeValue;
      _root.bg.txt.text = defaultp;

       

          for(var i:Number=0;i<newsXML.firstChild.childNodes[1].childNodes.length;i++){
      var tlink:String = newsXML.childNodes[0].childNodes[1].attributes.Name;
      var linkS:String = newsXML.childNodes[0].childNodes[1].childNodes[i].attributes.name;
      var imageS:String = newsXML.childNodes[0].childNodes[1].childNodes[i].attributes.ImgUrl;
      var textS:String = newsXML.childNodes[0].childNodes[1].childNodes[i].childNodes;

       

      _root.sub_bg.subTXT.htmlText += "<a href='asfunction:linkF,"+textS+"'>"+linkS+"</a><br>";
      _root.sub_bg.linktitle.htmlText = tlink;

       

      }
          }
      }

       

      newsXML.load("xml/homes.xml");

       

      3. ImgMC:

      psxml = new XML();
      psxml.onLoad = psViewer;
      psxml.load("xml/homes.xml");
      psxml.ignoreWhite = true;
       
      function psViewer(success) {
      if (success == true){
          rootNode = psxml.firstChild.childNodes[1].childNodes[0].attributes.ImgUrl;
          totalps = psxml.firstChild.childNodes[1].childNodes.length;
          currentps = rootNode;
          currentIndex = 1;
          updateps(rootNode);
          //trace(totalps);
          }
      }

       

      function updateps(newps){
          imagePath = rootNode;
              targetClip.loadMovie(imagePath);
          //trace(imagePath);
              setTimeout(preload,500)
          }

       

      stop();

       

      4. XML file:

       

      <?xml version="1.0" encoding="utf-8"?>
      <content>
        <Home>
          <Body/>
        </Home>
        <Submenu Name="Home">
          <links name="Information" id="0" ImgUrl="images/home/2.jpg"><![CDATA[aaaaaa aaaaaaa aaaaaa]]></links>
          <links name="Solution for SME's" id="1" ImgUrl="images/home/1.jpg"><![CDATA[bbbbbbbb bbbbbbb bbbbbbb ]]></links>
        </Submenu>
      </content>

       

       

      i will appreciate your help.

       

      Regards,

      MELAS