?
Solved

Script problem

Posted on 2006-06-12
3
Medium Priority
?
214 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

765 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