1 Reply Latest reply on Sep 24, 2008 8:34 AM by Rothrock

    Adding CDATA to an existing xml and flash asset

    danka21819
      Hi, I am a front end web designer/developer and analyst...struggling with putting an accordian flash xml menu together. I have it done except I need to add a simple trademark symbol circle with r. I am struggling with how to do this since I am not savvy in actioncript. I assume the best way is to add it is with a CDATA child node, but do not know how or whatever is the best way to get this done since am on a tight deadline. I need someone to explain step by step what I have to do to get this simple addition resolved. Attached are the links to home page and code for the xml file. The left navigation is the asset that I need to add the trademark symbol under about, about ADHERE. Thanks so much in advance!!!!!!
      [URL=http://www.nodcreative.com/natrecor_sliced/natrecor_index.html]index page with flash xml menu asset[/URL]

      xml code:

      <?xml version="1.0" encoding="UTF-8"?>
      <accodion>


      <item name="HOME">


      </item>


      <item name="ABOUT">


      <item name= "ABOUT ADHERE<![CDATA[write]]>"></item>

      <item name="Medical Information" url=" http://www.jnj.com?ref=Random">




      </item>
      <item name="About SCIOS" url=" http://www.jnj.com?ref=Random">
      </item>


      </item>

      <item name="INTERACTIVE DOSING INFORMATION">


      <item name="Indications and Usage" url=" http://www.jnj.com?ref=Random"></item>


      <item name="Contraindications" url=" http://www.jnj.com?ref=Random"></item>
      <item name="Warnings" url=" http://www.jnj.com?ref=Random"></item>
      <item name="Dosage and Administration" url=" http://www.jnj.com?ref=Random"></item>




      </item>
      <item name="RESOURCES AND TOOLS">

      <item name="NATRECOR PI" url=" http://www.jnj.com?ref=Random"></item>
      <item name="About Heart Failure" url=" http://www.jnj.com?ref=Random"></item>
      <item name="Stages of Heart Failure" url=" http://www.jnj.com?ref=Random"></item>
      <item name="NATRECOR Dosing Information" url=" http://www.jnj.com?ref=Random"></item>
      <item name="Patient Management Resources" url=" http://www.jnj.com?ref=Random"></item>


      </item>
      <item name="US PRESCRIBING INFORMATION">
      </item>
      <item name="IMPORTANT SAFETY INFORMATION ref=http://www.jnj.com">

      </item>

      <item name="REGISTRATION ref=http://www.jnj.com">

      </item>

      </accodion>

      FLASH actionscript is as follows:





      // The accordion
      var accordion = this

      // The item list
      var itemList = []



      //-----------------------------------------------------------
      // SETTINGS
      //-----------------------------------------------------------


      //-------------PROPERTIES----------------

      // Separation between the buttons
      var separation = 1.5

      // Tabulation between the buttons and the margin
      var tabulation = 10

      // if true, it cant be more than one items opened at the same time (only for the first buttons, POWERFUL, MENU ,ACCORDION, ets).
      var autoClose = true

      // if true, it cant be more than one subItems opened at the same time.
      var subItemAutoClose = true

      // if true, open and close all the subItems at the same time.
      var openAll = false

      // The height of the button
      var itemHeight = 21

      // The width of the button
      var itemWidth = 230

      // If true, show the light over the button
      var light = true

      // The ease of the menu opening
      var openEase = 2.5

      // The ease of the menu closing
      var closeEase = 2.5

      // The rollOut color fade speed
      var rollOutFade = 8



      //-------------COLORS----------------


      // The color of the button
      var buttonColor = 0xa

      // The roll over color
      var rollOverColor = 0xCCCCCC

      // The arrow color
      var arrowColor = 0xCCCCCC

      // The arrow color on roll over
      var rollOverArrowColor = 0x000000

      // The text color
      var TextColor = 0xFFFFFF

      // The text color on roll over
      var rollOverText = 0x000000



      //-----------------------------------------------------------
      // LOADING XML
      //-----------------------------------------------------------

      // The xml data
      var xmlSource:XML = new XML

      // Loading the xml
      xmlSource.onLoad = function(success:Boolean):Void {

      // When the load finishs...
      if (success) {

      // The first node of the xml
      xmlRoot = xmlSource.firstChild

      // The item nodes
      xmlItems = xmlRoot.childNodes

      // The total of items
      total = xmlItems.length

      // Creating the buttons
      for (i=0; i<total; i++){

      // Attaching the buttons
      accordion.attachMovie("item", "item" + i, i)

      // The button reference
      itemList = accordion["item"+i]

      // The first node of the item node
      itemList
      .xmlRoot = xmlItems

      // The separation between subitems
      itemList
      .separation = separation

      // Tabulation between the subitems and the margin
      itemList .tabulation = tabulation

      // subItems auto close
      itemList
      .subItemAutoClose = subItemAutoClose

      // The subitems height
      itemList .itemHeight = itemHeight

      // The subitems width
      itemList
      .itemWidth = itemWidth

      // shows/hides the subitems light
      itemList .light = light

      // The subitems color
      itemList
      .buttonColor = buttonColor

      // The roll over color
      itemList .rollOverColor = rollOverColor

      // The arrow color
      itemList
      .arrowColor = arrowColor

      // the arrow color on roll over
      itemList .rollOverArrowColor = rollOverArrowColor

      // The text color
      itemList
      .TextColor = TextColor

      // The roll over text color
      itemList .rollOverText = rollOverText

      // the opening easing
      itemList
      .openEase = openEase

      // The closing easing
      itemList .closeEase = closeEase

      // The roll over fade speed
      itemList
      .rollOutFade = rollOutFade

      // open all
      itemList .openAll = openAll

      }

      }

      }

      // ignore white
      xmlSource.ignoreWhite = true;
      // Loads the .xml file
      xmlSource.load("accordion.xml");



      // Aligning the items each one below the other
      this.onEnterFrame=function(){

      // Does the align to ALL the items
      for (i=1; i<total; i++){

      // Aligning the items
      itemList
      ._y = itemList[i-1]._y + itemList[i-1].mask._height + itemList[i-1].button._height + separation

      }
      // The cursor position
      cursor._x = _xmouse
      cursor._y = _ymouse

      }

      // Opens the items
      onMouseDown = function (){

      // Does this to all the buttons
      for (i=0; i<total; i++){

      // If is clicked
      if (itemList .button.hitTest(cursor)){

      // Shows the current item
      showCurrent(itemList
      )

      }

      }

      }

      // Shows the button clicked
      showCurrent=function(current){

      // Does this to all the buttons
      for (i=0; i<total; i++){

      // Does this to all the buttons exept the clicked
      if (itemList !=current){

      // Close the other items if autoclose = true
      if (autoClose){

      // Close the other items
      itemList
      .openBox=false

      // fades the roll over effect of the other items
      itemList .over = false

      }

      //Does this to the clcked item only
      } else {

      // If it has sub items
      if (total>0){

      //Hides them if its open
      if (itemList
      .openBox){

      itemList .openBox=false

      //Shows them if its closed
      } else {

      itemList
      .openBox=true

      }
      // If it has no subitems goes to the link
      } else {

      getURL(xmlRoot.attributes.url, _self)

      }
      }
      }
      }


        • 1. Re: Adding CDATA to an existing xml and flash asset
          Rothrock Level 5
          Please don't cross-post in a bunch of forums. Also when adding code to a post, please use the attach code button. That keeps the formatting and makes it easier to read. Your code is far too long and way to unformatted to really understand quickly.

          I don't know why you would need a CDATA node to get the registered symbol. If the XML file you are working with is saved as unicode (UTF-8) the symbol should come across just fine. Just putting the UTF-8 at the beginning doesn't tell whatever program you are using to save as UTF-8!

          Do you know how to make the registered symbol? On windows it is ALT -0174 (use the keypad for those numbers).

          Once you've got the symbol in your XML the next step is to check if Flash is loading it correctly. When you are in the testing environment go to the Debug menu and select List Variables. The trace window will show all the variables -- and there are probably a lot! Search/Find something close to the symbol and see if the trace window shows the symbol correctly. If it does then Flash is readying it correctly and if it isn't showing you have problems with your textfield. If it isn't showing correctly then your XML file isn't UTF-8.

          If it is textfield problems I wouldn't know what to do since it is inside a component. Post back with your findings.