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

    how to change Image with Text?

    melas076 Level 1

      dear,

       


      I would like to know how to change Image with Text when i click on subtitle?

       

      so i have 3 MC (imgMC, sub_bg and bg) and 1 XML files

       

      this is the code for each MC :

       

      1. 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();

       

      2. sub_bg:


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

       

      3. 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");

       

      4. XML files

       

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

       

       

      I will appreciate your help.

       

      Thanks and regards,

      MELAS