1 Reply Latest reply on Dec 13, 2011 5:40 AM by Pooja Kuber

    Problem splitting a string

    Zolotoj Level 3

      I am having a problem splitting a string.

      Here is my code:

      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                     xmlns:mx="library://ns.adobe.com/flex/mx"

                     creationComplete="init()"

                     xmlns:s="library://ns.adobe.com/flex/spark">

          <fx:Script>

              <![CDATA[

                  private var helper1:Helpers;

                  private function init():void

                  {

                      helper1 = new Helpers();

                  }

              ]]>

          </fx:Script>

          <s:layout>

              <s:VerticalLayout/>

          </s:layout>

         

          <s:HGroup>

              <s:Panel id="Panel1"

                       height="100" width="100"

                       title="Panel 1">

                  <s:Button id="setCB"

                            click="helper1.getChildFromPath(this, 'abc.123')"/>

              </s:Panel>

          </s:HGroup>

      </s:Application>

       

      package

      {

          import flash.display.DisplayObject;

          import flash.display.DisplayObjectContainer;

       

          public class Helpers

          {

              public function Helpers()

              {

              }

              public function getChildFromPath(base:DisplayObjectContainer, path:String):void

              {

                  var pathAsArr:Array = path.split(".");

                  // here pathAsArr.length is zero.      

              }

          }

      }

       

      Any idea?

       

      Thanks

        • 1. Re: Problem splitting a string
          Pooja Kuber Level 2

          Hi Zolotoj,

           

          The code running fine for me. Its splitting the values and thus the array length coming out as 2.

           

          captured.jpg

          I followed the following steps:

          Ran the application

          Clicked on the button

          traced the pathAsArr variable

           

          Is there other test case? Please let me know will try to find out the solution for your issue.

           

          Thanks and Best regards,

          ---------------------------------------------------------------------- -------------------

          Pooja Kuber | pkuber@infocepts.com | www.infocepts.com

          --------------------------------------------------------------------- --------------------