Solved

Script problem

Posted on 2006-06-12
3
170 Views
Last Modified: 2010-04-03
Hi experts,

This script is working fine with one ' but when I have two of them it removes the first one... What should I do?

function stringHTML1(s) {
      var my_str = new String(s);
      var my_array = my_str.split("'");
      var tmp_str = "";
      if (my_array.length != 1) {
            for (var i = 0; i<my_array.length; i++) {
                  tmp_str += my_array[i];
                  if (i == my_array.length-2) {
                        tmp_str += "'";
                  }
            }
            return tmp_str;
      } else {
            return s;
      }
}
0
Comment
Question by:cabou
3 Comments
 
LVL 7

Accepted Solution

by:
furmiga earned 250 total points
ID: 16889495
Hi there

i tried this and it might be what you are looking for

function stringHTML1(s)
{
    var my_str = new String(s);
    var my_array = my_str.split("&apos;");
    var tmp_str = "";
    if (my_array.length != 1)
    {
        for (var i = 0; i<my_array.length; i++)
        {
          tmp_str += my_array[i];
          if (i+1 < my_array.length)
          {
                tmp_str += "'";
          }
        }
        return tmp_str;
        //trace(tmp_str);
    }
    else
    {
        return s;
    }
}

i made a button

    on(release)
{
      stringHTML1('1111111111&apos;2222222222&apos;3333333333')
}

traced 1111111111'2222222222'3333333333

is this what you want ?
}
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16890889
If you mean to say, that when you have two functions then first one is gets replaced with second one....

if yes, then here is the solution:
--------------
you should use different name for both functions:

function stringHTML1(s) {
 /// code here
}

function stringHTML2(s) {
 /// code here
}

:-Aneesh
0
 

Author Comment

by:cabou
ID: 16891995
Hi,

Again great work

few things:

1)I need to be able to use "apos", please include the function to do it like in the previous flash. They were a problem with your function, please use the following.

function stringHTML1(s)
{
    var my_str = new String(s);
    var my_array = my_str.split("&apos;");
    var tmp_str = "";
    if (my_array.length != 1)
    {
        for (var i = 0; i<my_array.length; i++)
        {
         tmp_str += my_array[i];
         if (i+1 < my_array.length)
         {
                tmp_str += "'";
         }
        }
        return tmp_str;
        //trace(tmp_str);
    }
    else
    {
        return s;
    }
}

2) The links are not working (they also need to open in the same page)

3) Can you please ad a param, so I can have a diferent background on the link page.

4) to finish can you please ad a 1px black borber when the mouse is over a label-link

Again thanks a lot

Erez
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now