Solved

Script problem

Posted on 2006-06-12
3
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

726 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