Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Simple String Manipulation.



I have been using the textscript class for a few groovy text effects but I have a problem where punctuation is concerned. Given that the class breaks a string up into individual text fields for each character in a string, all special characters are displayed as their html notation.What I would like to do is alter the string so that the characters work correctly. eg. & #032; becomes '



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 01-17-2007, 12:47 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

String Manipulation : Pad A String.length
hi,
i have an array of track/artist titles

_level0.trkList = [object #218, class 'Array'] [
0:[object #219, class 'Object'] {
label:"Jeff Beck - Space for the Papa",
data:"spacepapa.mp3",
__ID__:0
},
1:[object #220, class 'Object'] {
label:"Jeff Beck - Another Place",
data:"anotherplace.mp3",
__ID__:1
},

i wish to add the array to a track info listbox component,
in such a way that the individual items in the array are
padded with spaces -" ", so as the length of the shortest
string equals the length of the longest string,

my listbox output is now -
Jeff Beck - Space for the Papa| * from time array
Jeff Beck - Another Place| * from time array

by adding spaces i would like it to be-
Jeff Beck - Space for the Papa| * from time array
Jeff Beck - Another Place"""""""| * from time array

does anyone know how to do this ?

many thanks for any help,

String Manipulation
Im thinking about creating an application which loads text from an external file and displays it on screen.

What I need to do is some way of making sure that the text string has the apropriate format where words are not split in half when a new line is added.

Does anyone know of any good examples like this?

String Manipulation
I have looked on this board for some help, but I still cant get this to work for me.

I would just like to do three things to a string.
I am making a form that returns calculations depending on user input. It deals with money.

I need to have all variables to contain the .xx (cents)

so 1 should be 1.00 and 12.5 should be 12.50.

also I need to only show two places after the decimal point.

One other thing, is I need to write up a check to see if the variable already contains a . or not, and if it doesn't to add the .xx or .x0.

I hope Im making sense. I have tried doing the .indexOf('.'), but it doesnt seem to work, It doesnt return anything.

String Manipulation?
I have a string that outputs in a dynamic textfield
I am trying to get each item on a new line...

I got advice from someone last night that did not work...
that was use /n or <br> with html formattting on....

So here is the actual line of code

body = "APPLICANT:"+name+"DAYPHONE:"+dayphone+"EVEPHONE:" +evephone+"E-mail:"+email+"MAILING ADDRESS:"+mailaddress;


I would like it to read

APPLICANT:name
DAYPHONE:313-896-8956
etc...........

String Manipulation
I have a movie which POSTs variables out to......ah dont matter - the backend of the site.

during the movie i use a variable called "childAge_1". How do i change that var name to "CHILDBIRTH_DATE-1". Ive started using this.....

name=_parent._name; //gets "childAge_1"
outputName=name.split("Age_1");

so now i get "child," errr dont know what way to tackle this....scared....help!

Cheers

String Manipulation
I've looked a bit over the ActionScript associated with strings, and there doesn't seem to be very easy ways to manipulate them. For instance, let's say I have the sentence "My name is Bob.", and I want to remove the word "name" and return "My is Bob.".

I'm not even sure how I would do this in ActionScript. Anyone want to fill me in?

String Manipulation Q?
On the main timeline, I have these variables set...........




Code:
path = "";
songs = " TRACK1,TRACK2,TRACK3,TRACK4,TRACK5,TRACK6,TRACK7,T
RACK8,TRACK9,TRACK10";
artists = "Dr John,John Lee Hooker,Eric Clapton,Stevie Ray Vaughn,Stevie Ray Vaughn,Average White Band,ZZ Top,Queen,Aerosmith,Allman Brothers";
titles = "Wrong Place,Boom Boom,Tore Down,Taxman,GuitarHurricane,Funky Music,Low Rider,Fat Bottom Girls,Pink,Midnight Rider";
sizes = "1,2,3,4,5,6,7,8,9,10";
total = 10;

Inside a MC I have a textbox named "songlist". The actions on the MC containing the "songlist" are..........


Code:
onClipEvent (load) {
artists = ..:artists.split(",");
titles = ..:titles.split(",");
for (i=0; i<artists.length; (i++)) {
songlist = artists[i] + " - " + titles[i] + "
";
}
}

This only displays the last artist and last song in the variable list. I would like to have the list populate with all the songs and artists. Any suggestions/help???

Thx
Regards
~GD~

Help With String Manipulation
Hey.. First off, a confession.. For some reason, string manipulation sometimes confuses me.. So i need a little help getting started with an experiment..

I'd like to have an input text box. The user would type in a model number (for intranet at work), or a partial model number. Depending on what the user types in, a list box is populated with exact and/or possible matches.. I know how to work with exact data, but can someone show me how to check against certain characters and find possible matches?

The possible models numbers can be hardcoded or dynamic, doesnt matter.. Just want to try to understand the principle behind doing this, so i can modify it and try to get it to work like i want it to...

thanks in advance to anyone who helps..

-myk

Help With String Manipulation
I'm pulling a value from an xml document ie..Agricultural Equipment, and applying it to a variable called "name". I want to take the value of "name" and create an swf file. the problem is that the names vary in length and they contain a space. The length is an issue, I want to get rid of the space and use the variable "name" as the newly created swf file.

Anyone have a good suggestion for doing this?

Thank you,

String Manipulation
Hello,

I need some help here doing a string manipulation,

I have on php output like this

month1=January&. fair1 / 18 to 22 . fair2 25 to 29
&month2=April&. fair11 to 4 . fair2 28 to 4
&&n=5

I need to make flash read how many fairs there are inside each month, so I can create my buttons.

Any ideia?

I'm triing this flash code,

var lv:LoadVars = new LoadVars();
lv.load("php/listar_news.php");
lv.onLoad = function(sucesso) {
if (sucesso) {
for (knews=1; knews<this.n; knews++) {
var noticias:String = this["mes"+knews];
for (kn=0; kn<noticias.length; kn++) {
noticia = noticias[kn].split("
");
getURL("javascript:alert('"+noticias[0]+"')");
}
}
}
};

Thanks a lot,

Pluda

String Manipulation?
I have a simple string that I'm passing using jsfl and I need to keep the double quotes and can't seem to figure out how to do it.

jsfl = "_root.gotoAndPlay('up');";

That works for single quotes but doesn't for double quotes?...

Thanks

String Manipulation
How's it going?

I need to do some string manipulation. I need to take a string in the form "artist - song" and extract both the artist and the song and store them in seperate variables.

Any pointers in the right direction?

Thanks,
Saveth

Here is my unsuccessful attempt


Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
songTitle = xmlNode.childNodes[8].childNodes[0];

// TRYING TO ATTEMPT SPLIT
buyButton = xmlNode.childNodes[8].childNodes[0];
storedStringArray = buyButton.split("-");
songName = storedStringArray[storedStringArray.length-1];

songTitle = songTitle_txt.text.toUpperCase();
songTitle = songTitle_txt.text.searchReplace(" - ", ": ");
songTitle_txt.autoSize = true;
buy_mc._x = songTitle_txt._x+songTitle_txt._width+5;
buy_mc._y = songTitle_txt._y;
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://www.crylounge.com/shoutcast.php");

function loadNewXML() {
xmlData.load("http://www.crylounge.com/shoutcast.php");
}

setInterval(loadNewXML, 10000);

String.prototype.searchReplace = function(str, rep, chr) {
var t = (chr<0) ? this.substr(chr) : this.substr(0, chr);
var s = str.length;
var r = rep.length;
var p = t.indexOf(str);
while (p != -1) {
t = t.substr(0, p)+rep+t.substr(p+s);
p = t.indexOf(str, p+r);
}
return (chr) ? (chr<0) ? this.substr(0, this.length+chr)+t : t+this.substr(chr) : t;
};

buy_mc.buy_btn.onRelease = function() {
getURL("http://www.google.com", "_blank");
}

=== String Manipulation Problem Please Help ===
Hi all,

I want to make a function that transform some texte into numbers.
a = 1
b = 2
c = 3
d = 4
e = 5
f = 6
g = 7
h = 8
i = 9
j = 0
k = 1
....

I have made a small function but it doesn't work and I don't know why !
Here is my funstion :


function mf (texte) {
alpha = "abcdefghijklmnopqrstuvwxyz";
for (j=1; j<=length(alpha); j += 1) {
if (j<10) {
eval(substring(alpha, j, 1)) = substring(j, 1, 1);
} else {
eval(substring(alpha, j, 1)) = substring(j, 2, 1);
}

}
for (i=1; i<=length(texte); i += 1) {
lettre = substring(texte, i, 1);
lettre = lettre.toLowerCase();
}
trace (eval(lettre));
}


Please Help !

Urgent Help With String Manipulation
please help! i need to make an encryption program(really simple). i have a text box with the input and one for output and a button. Here is the script:
on(keyPress "<enter>"){
function letter(letter){
LETTER=new String(letter)
I=new String(i)
for(i=0; i<alpha.length; i++){
if(LETTER==alpha[i]){
this.number=I
}
}
}
encodeInString=new String(encodeIn)
encodeArray=encodeInString.split("");
for(i=0; i<encodeArray.length; i++){
letterArray[i]=new letter(encodeArray[i])
}
encodeOut=letterArray[0].number;
}

obviously, this doesnt work

can anyone please show me how to take a sentence, and convert each of the letters into numbers depending on what the letter is(ie: a=0, b=1)

then i need to do an operation on them, and turn them back into letters. can anyone help!?

Gurus, Help With String Manipulation
thanks a lot of someone can help with this one.

my string takes the form of path to a .swf that looks like this: "video/test.swf" where test may be any name for the .swf and any length. for example it might be video/bigmovie.swf or video/thebadmovie.swf etc.

i need to extract everything inbetween the"/" and the"." so i can use that to reference a frame label that has special info for that .swf

any ideas?

thanks.

--grish

Variables And String Manipulation
I've been pulling my hair out at this very simple problem.

I want to load a variable from an external text file and use that variable in a sound class, here's my code:

Text data file:

Quote:





&toPlay=http://domain.com/Some Song.mp3&






Actionscript:

Quote:





//load variables from external text file
_root.loadVariables("http://domain.com/temp.txt");

//stick the variable from that text file into the sound class
//what am I doing wrong? it makes complete sense in my head
soundContainer = new Sound(this);
soundContainer.loadSound(toPlay, true);

String Manipulation In Function
I'm using a function to call multiple button actions, so I don't have to rewrite code for each button... here's the script:


Code:
function btnSelect(num){
var btnA = "btn" + num;
btnA.onRelease = function(){
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[num], 1);
desc_txt.text = description[num];
picture_num();
}
}
}
btnSelect("0");
btnSelect("1");
btnSelect("2");
btnSelect("3");
btnSelect("4");
This is all part of a clip which loads pictures externally... each of the buttons (which are mc's) are named btn0, btn1, etc.... any ideas how to make this work??

String Manipulation Problems
Argh. Confusing problem:


actionscript Code:






Original
- actionscript Code





// format the address
if ( _root.cache["cache_" + id + "_address"].indexOf('<br/>') < 1 and _root.cache["cache_" + id + "_address"].indexOf('<br />') < 1)
{
var address_array:Array = _root.cache["cache_" + id + "_address"].split(",");
}

for (var i = 0; i< address_array.length; i++)
{
address_string += (address_array[i] + ",<br>");

trace(address_string);
}

var final_address_string:String = address_string.substr(0, (address_string.length-5));

_root.infoDisplay.flag_address.htmlText = final_addess_string;






 // format the address    if ( _root.cache["cache_" + id + "_address"].indexOf('<br/>') < 1 and _root.cache["cache_" + id + "_address"].indexOf('<br />') < 1)    {        var address_array:Array = _root.cache["cache_" + id + "_address"].split(",");    }            for (var i = 0; i< address_array.length; i++)    {           address_string += (address_array[i] + ",<br>");                trace(address_string);    }        var final_address_string:String = address_string.substr(0, (address_string.length-5));        _root.infoDisplay.flag_address.htmlText = final_addess_string;



The original address:

Code:


67 St. James's St, London, SW1A 1PH



The trace():

Code:


undefined67 St. James's St,<br>
undefined67 St. James's St,<br> London,<br>
undefined67 St. James's St,<br> London,<br> SW1A 1PH,<br>



Displayed in the TextField:

Code:


undefined



Eh?

Actionscript String Manipulation Question
any help would be grrreat i posted my question over here:

it is one of those questions that you fk actionscript pros will be able to do blindfolded, but its beyond me...

check it out!

http://www.flashkit.com/board/showth...hreadid=506283

--grish

Character Substitution/string Manipulation
i want to take a phone number in the format 111-222-3333

strip out the dashes to make it 1112223333

seems simple but i am hung

please help

String Manipulation In Action Scripts
Hey guys,

I have (an apparently) simple question.... How do u edit strings in AS? I want to combine, strip and seperate strings.

Thanks for your help

JP

String Manipulation Removing Words Between Delimiters
I am trying to remove words that occur between delimiters in a string.(this can also be an array if it helps any..)

These words have to be saved to different variables:
ie:
"This is the /string/that/has/to have the words 'string' 'that' and 'has' copied out"
var1 = "string"
var2 = "that"
and
var3 ="has"


I am not sure if this is possible but any ideas are welcome.
any body help?

Thx
Shaf

String Manipulation With "this" Object
I have a button within a movie clip that passes an identifier to a function like so:

on (release)
{
_root.getname(this);
}

The function recieves "this" as "_level0.mc_main_menu.game0"

I want to treat the returned value as a string & get the value "game0" from it.

How do I do this?

Am I right in saying that "this" is an object, and I need to convert it to a string first?

p.s - in case your interested - the value "game0" matches an xml node & the function plays a movie clip which is populated by the node attributes.

Simple %&$#& String Loops
why can't I get this to work. I have 17 MC's that slide out to the right. They are named "slide01" through "slide17". Inside each of them are 20 frame motion tweens, on the 10th frame of each, I want it to go play the next. Here is my code, which will give me "slide11" and "slide111" instead of "slide02" and "slide03".
code:
var myString = new String(this._name);
var stringer = myString.substr(5,2);
var doneStr = stringer + 1;
_parent["slide" + doneStr].gotoAndPlay(2);

Simple String Question
Hi,

I want to determine if a certain world is included in a text string.

For example:
myVariable:String = "See the red dog";

How can I find out if the word "red" is in this string? What is the action script to do this?

Thanks.

Simple String Question
I have a really really simple question that has got me wound around a gear here,

How do you include quotation marks in to a string that contains a variable?

For Example:
messageString = "<NEW_CLIENT userName = " + "+ userName+" + "/>";

userName is the variable

Thanks in advance,

Abbreviating A Simple String?
Hello,
I'm wondering if in the middle of a string I can call to a variable to help complete the string. In other words, let's say I'm a few layers in and I want to do this:

on (release) {
tellTarget ("_root.container.boxes.clip.E1") {
gotoAndStop("help");
}
}

Can I set it up to instead call to a _root variable? Let's say I've got a variable on the _root that chanegs, sometimes it's E1, sometimes it's E2, etc. Can I do something like this?:

on (release) {
tellTarget ("_root.container.boxes.clip.[_root.var]") {
gotoAndStop("help");
}
}

This doesn't work, nor do any of the syntax variations I can think of. Is there a way to pull this off?

Thanks!

Simple String Question
Hey folks,
Is there a flash method for replacing a substring with a string?

Thanks in advance, Abstract2069

Simple String Handling
Doesnt seem to be so simple

Trying to take the string value of a button passed to a function and add "_mc" on the end! It just keeps returning undefined? Any ideas?

function openBox(){
var newName = this.split("_level0.");
trace(newName);
var newName2 = newName.split("Btn");
trace(newName2);
var newName3 = newName2+"_mc";
//_root[newString]._visible = true;
trace(newName3);
}

It's not even working when I switch to substr

String Var Simple Problem
Hi guys,

I'm having a hard time setting a XML value as a String for some reason. I'm sure it's easy but nothing works today.

Anyways, I tried pushing it to a string var but that doesn't work. My solution is easy but I'm pretty sure it's not the right way to go about it.


PHP Code:



preloader.add("" + xmlvar.over + ""); 




The quotes forces it into a string but like I said, it's probably not the right way to go about it... IE "xmlvar.over:String"

Little help?

Simple, Convert String To Number
alright simple question, converting string to number whats wrong with the code?

boxNumber = "01";
boxNumberObject = new Object(boxNumber);
answer = boxNumberObject.valueOf();

i just want the value of a string that the user gives me? any answers? thanks people.

Simple Variable String Assembly
Hi all,

I have been trying to work this out for some time, hope you can help...

i would like to build a variable name so that i can call it's value into a text box mc called textBox.

I have tried like this:

picNumber = 1
textBox.copyText =_root.pic+picNumber+Content;

but flash thinks this is 3 different variables - instead of one that reads: _root.pic1Content;

humpppfff!!!

tnx

Extracting Just Numbers From A String... Help (should Be Simple?)
Hi - I'm stumped here. I'm trying to extract just numbers from a string. Namely, I'm tracing "this" which returns a path : "level0.instance1.subContainer0.subButton0" What I want to do is extract just the numbers so that I get a value of "0100" (or better yet, "100"). I've looked into substr() but it's only numbers in a sequence. Is there any way to do this???

thnx
t

Simple Variable Pass From URL String
help! i know there is a simple solution to this, but I just can't find an answer anywhere. so i'm posting it here in hopes that some kind soul will pitty me and free me from this frustrating pothole.

What i'm trying to do is pass a variable to a flash file via a URL string... i.e.

http://www.needananswer.com?pothole=12

...and for the flash file to be able to receive and use it.

HOW?

Simple String Comparing Problem
I have a seemingly simple problem but have not been able to figure it out. I create a 2 frame project. I use an input text field to collect a string variable and then after the submit button is pressed I proceed to the next frame. The next frame checks the string variable against the string "soccer ball". If they are equal I want to output "winner" (just for testing at the moment). Every way I have tried I cannot get the two to be compared correctly.

guessVar is a variable attached to the input text field

I have tried

if(_root.guessVar == "soccer ball")

and

var answer = "soccer ball";

if(_root.guessVar == answer)

if(String(_root.guessVar ) == String(answer))

and just about anything else I could think of. Can someone please help me with this simple problem? Thanks a million.

Simple Search In Array / String?
Hello,

I need a quite simple function but can't just figure it out yet...

In my flash (e-learning) application i wan't to check a code for the existence of a parameter and start a function if it exists:

code:String = "012345";

if code.somesearchfunction== "1" {

start function 1;

}

if code.somesearchfunction== "2" {

start function 2;

}

and so on....

now it seems i have got to split this string in array first? I would like to just use a function that gives false if the value "1" doesn't exists and continues to find other values.

Thnx for the help!

Simple String To Path Question
Hey, I really feel stupid for not being able to get this to work.

Im trying to store an instance name in a variable and use the variable in the path. Basically, storing test + 2 in testinc and then use testinc as part of the dot path.



Code:

var checkTest:Number = 2;
var testinc:String = "test" + checkTest;
trace (testinc);

page_shell.nextButton.addEventListener(MouseEvent.CLICK , nextClick);




function nextClick(evt:MouseEvent):void {


page_shell.[testinc].alpha = 1;
Can some help me out as to why this doesn't work?

MX04 - Simple Function - Passing Through A String Argument
Hi there.

I have a function that is try to pass through a url to a pop up menu using Javasccript. The pop up works fine but i cant get the url parameter to pass through.

On the root of the movieclip i have:


Code:
function popUp(url : String){
var fullURL = url;
getURL("javascript:NewWindow=window.open('fullURL','myWindow','width=300,height=200,left=400,top=200,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No'); NewWindow.focus(); void(0);");
}
Then on the button i have:


Code:
on (release) {
popUp("www.msurgery.co.uk/contract.php");
}
Thanks for your time.

How Is This Txt Manipulation Done?
Hello,

I need some help please!

I am working on a project where the user picks a font, types a message and can manipulate the text once added. I have searched all over for clues on how this is done with no luck.

I am attaching a .jpg of a site that has something similar that I need to do for reference, and here is the link http:// www.designAShirt.com.

Any help pointing me in the right direction would be greatly appreciated.

xcaliber

XML Manipulation
Hi,

Can anyone tell me how I would go about using E4X XML processing to return the elements labelled "//this" below. I have tried using things like conditions.descendants() which will return the greater and lessThan elements, but that ignores the equalityCondition elements.

Is there some easy solution I am over looking?



Code:
<conditions>
<equalityCondition questionID="id5" response="1" /> // this
<andGroup> // not this
<greaterThanCondition quesitonID="id6" response="-1" /> // this
<lessThanCondition quesitonID="id3" response="2" /> // this
</andGroup> // not this
</conditions>


Thanks in advance

XML Manipulation
Hi, I'm a beginner in this stuf and I want to do in flash a simple prices table (a list) that I "import" from Excel and I transformed in XML throught FileMaker.
I'm lost in many information and I want a good source of information in order to understand that (if possible in portuguese or spanish).

Thanks in advance

OT: XML Manipulation
This is a bit off topic, but not entirely un-Flash related. I'm doing some on-line training that has some questions at the end. I'm converting a course made by somebody else into our system. The existing questions are in an XML format and have various attributes and such that we don't use. Additionally for example their code marks the correct answer with a "1" and we use "true" etc.

I'm hoping to find some kind of tool for manipulating XML in an easy way. Anybody have any tips?

Variable Manipulation
hey
i'm trying to make a guest book, but when i try sending data that has html tags to my php3 script, it gets cut off so what i want to do is replace some of the html tags.

if i type in:
"This is a test message
From PaladinL"
into a text box that has html checked off
the real data looks like this:

<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000">This is a test message</FONT></P><P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000">from PaladinL</FONT></P>

now what i want to know how to do is
transform

<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000">This is a test message</FONT></P>
<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000">from PaladinL</FONT></P>

into
this:
This is a test message
lFrom PaladinL

basically i want to remove all the:
<P ALIGN="LEFT"><FONT FACE="Times New Roman" SIZE="12" COLOR="#000000">

and replace all the:
</FONT></P>
with:
l

how can i do this?
i really need to know how to do this for my guest book
thanks to anyone who helps

Photo Manipulation?
Is there any way to work with photos after they've been brought into Flash? I'm wondering if some of the drawing functions can be used to manipulate them. Also, can I get photos to change scale like text?

Variable Manipulation
This is just a general question in general (Ok, who else likes redundancy?). Um, I've got a text variable in a movie clip within a flash movie. All script within the clip has no problem with manipulating the variable. But when I try to have some script outside of the movie clip interact with the variable, nothing works. I figured it might be addressed something like "movieclip.textvariable=" but that didn't work. Can anybody clue me in? Thanks

Image Manipulation
Is it possible to select a section of an image can copy that section only, rather like a marquee tool in Photoshop??

Graphic Manipulation
I have a 2d graphic animation of a fish, at the moment he follows a path weaving from one end to the other but I want him to swim into (facing) the background then turn the other way (so that he swims deeper into the "sea" and turns around...

I can figure it out and its driving me mad!!!

Any help/ideas will be greatly appreciated.

Cheers

Text Manipulation
I downloaded some text effects off this site, the same ones used in "flash typer". I down loaded it instead of using the typer because there were a few things about it I wanted to change. The only problem is I can't get it to display more than one line of text. I need five single words on five separate lines, the code was written in flash 5 and I'm using MX ....can I get some help please.

Text Manipulation
I downloaded a text effect alot like the ones in the "flash typer". The problem is an entire sentence will be displayed on one line. Can someone tell me how to make it display the text on multiple lines.

Copyright © 2005-08 www.BigResource.com, All rights reserved