Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Script problem

Posted on 2006-06-12
3
Medium Priority
?
220 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 1000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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 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…
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.
Suggested Courses

618 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