Substring ?
Can anyone help me with this problem ?
code ------------------ onClipEvent (enterFrame) { this.onRelease=function(){ wbt=eval(this); trace(wbt); // return _level0.slide1 trace(wbt.substring(3)); //return undefined }; } -------------------------
What am i doing wrong ?
Thanks for any help.
Carla
FlashKit > Flash Help > Flash ActionScript
Posted on: 05-29-2002, 08:41 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Use Substring
i want to cut the content of a variable:
eg:987643
i want it as : 987kb
i know i have to use substring, but how??????
thanks
Substring
if did this
variable="hello"
one=variable.substr(1,1)
then the value of one = e
if I had number=178
how can I take the second number out of this variable and put it into another variable?
Thanks
Substring ?
hi,
i'm trying to make a picture viewer where each picture would be a swf (picture_1.swf, picture_2.swf....)loaded into an empty movieclip.
i want to navigate through the pictures with arrows and i'd like to change the name of the loaded swf by a '+1' command meaning each time i click the arrow picture_1.swf changes to picture_2.swf but i don't know how....
anyone can help me ?
thx a lot !
Substring
I have a string containing "mango.jpg" or "jackfruit.jpg"
If i want to remove .jpg from this string what should i do?
SubString
Hi,
A variable contains some text.
var a="abcde";
I don't want the first 2 characters. How can I use the SubString to get this?
Thanks.
Using .substring, Is There A AS3 Way Of Doing This?
Basically what this code does is use a timer to load text into a dynamic text box progressively...like its typing it out. This all works, and runs awesome when using the flash player, but it runs kind of slow when tested in a browser. I looked up "substring" in the flash help, and it almost looks like this is the AS2 way of doing things...but i don't get any errors or anything. Just wondering if there was a better way to perform this substring function...thanks
Code:
timer.addEventListener(TimerEvent.TIMER, onTick);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete1);
var str_01:String = "blah blah blah";
var timer:Timer = new Timer(2, 100);
var count:int = 0;
beginTimer();
function beginTimer() :void {
timer.start();
}
function onTick(event:TimerEvent) :void {
infoBox_mc.textBox_txt.text = str_01.substring(0, count++);
}
Substring Help
whats the deal with AS 2.0 and substrings? i keep getting an error saying "there is no method with the name substring..."
works fine with AS 1 though...
Substring
Hi
Can anyone explain how to use substr method??
I'm trying to lose a part of the button's name and only add the numbers
this is what i mean
btn1
btn2
btn3
btn4
btn5
And i want flash to extract btn from the name and use the numbers to get url
I heard you can do this with substr method but i'm not really sure how....
Substring Help
whats the deal with AS 2.0 and substrings? i keep getting an error saying "there is no method with the name substring..."
works fine with AS 1 though...
Substring
Hi
Can anyone explain how to use substr method??
I'm trying to lose a part of the button's name and only add the numbers
this is what i mean
btn1
btn2
btn3
btn4
btn5
And i want flash to extract btn from the name and use the numbers to get url
I heard you can do this with substr method but i'm not really sure how....
Substring ?
hi,
i'm trying to make a picture viewer where each picture would be a swf (picture_1.swf, picture_2.swf....)loaded into an empty movieclip.
i want to navigate through the pictures with arrows and i'd like to change the name of the loaded swf by a '+1' command meaning each time i click the arrow picture_1.swf changes to picture_2.swf but i don't know how....
anyone can help me ?
thx a lot !
Get Substring From A String
hey guys!
i need to get a substring value from a string.
ex:
i have this,
_level3._root.newRedMovieClip
i need this,
RedMovieClip
i want to check for a few conditions depending on whether the movie is 'RedMovieClip' or say, 'GreenMovieClip'. don't want to store it anywhere.
i suppose its pretty simple but i am kinda stuck with it. not applying my brains maybe...
thanks in advance.
neo
For ( ) Loop, And Substring
I have been trying to write a loop that goes through a string and counts everything between "<" and ">". so
myVar="<P ALIGN="LEFT"><FONT SIZE="12" COLOR="#000000" FACE="_sans">Type Your Message Here</FONT></P>"
myVarTotal.length= 131
myVar_With_Tags=109
Any Ideas
Substring (flash5)
i'm trying to create a movie that displays tooltips and i'm using the following code:
Code:
targetFullName = _root.objectArray[k];
targetName = targetFullName.substring(8);
a typical value for targetFullName would be "_level0.obj1" but i'm trying to chop off the "_level0." bit.
all i can get it to do is return an empty string, can anyone point me in the right direction.
any help is greatly appreciated (sp?).
- jgo
Substring And Split
I am trying to pass 2 values into a flash movie from the querystring. I've been successfull so far with the following code:
------
myURL = this._url;
myPos1 = myURL.lastIndexOf("?");
whichMenu = myURL.substring(myPos1+1, myURL.length);
myText = whichMenu; <-- just to display result
---
The result I get is:
m=1&s=1
which is perfect cause that means it works! woahho! hehe. What I need to do now is to assign the value of m to a variable in flash and the same thing for the value of s.
I've been rading tutorials but I just cant figure it out. Can someone help please?
Thanks!
MX- Very Simple Substring Use
how do I use this new syntax, help doesnt help.
I want to get a substring from mc's name using
this._name
getting
2nd character to end
myString.substr(start, [length])
thanks mark
How To Replace A Substring..
I think that it is pretty easy but I'm not very skilled in actionscript.
I want to replace every occurences of a substring by another substring in a string.
thanks a lot
Substring Question.
I have a peice of text in an array, which is a variable name, the = sign and the actual variable. I know this is not the best way to do this, but this is how it is and I am unable to change it at this stage.
So...
myArray[3]="note1X=10&"
Normally, to retrieve the variable I would use the following:
trace(substring(myArray[3],8,myArray[3].length-8)) // returns 10
However, the problem with this variable is that the number in the name i.e. note'1' could be any number e.g. note200000X=30 and using the above method would not work because there are more characters.
Is there a way of determining how many characters there are before the equals sign, or is there another way of doing this?
Any help would be much much apreciated.
Thanks in advance,
James
String/substring Help..
I am working with the VALUE of this being returned as my STRING:
Sun, 01 Apr 2007 18:13:03 PDT
Id liek to figure out how I can just get the DATE part..
Sun, 01 Apr 2007 from my string?
Ideally I would like to only have the date in a format like so:
04/01/07
but I'l take whatever help I can get.. (Im tired) LOL
(maybe string/substring solution?) maybe splitting string up my " " (space) and grab the second, third and fourth values in the array? (with look-up table for month?)
Code:
lastBuildDate = XML.firstChild.childNodes[0].lastChild.firstChild.nodeValue;
var dateOnly:String = lastBuildDate.substring(0, -13);
pubDate = dateOnly.toUpperCase();
trace("pubDate: "+pubDate);
[F8] MSDOS Like Substring
I can't find the movie/tutorial that involved making something similar to this.
Box symbol at the end included
Slice Vs. Substring
Is there a significant difference between string.slice and string.substring? They seem identical in every way. Neither changes the original string, either (though the documentation doesn't indicate that for both functions).
Substring Problem
Hi guys ,
I m trying to use the substring function with the this value and its not working
mycode is as fallows:
imHolder[MC[i]].onRelease = function() {
//trace("what is "+imHolder[MC[i]]);
var my_str:String=this;
trace("my_str value is "+my_str);
var mySubstring:String = my_str.substring(1,4);
trace(mySubstring);
trace("hi");
the output is :
my_str value is _level0.imHolder.1000-01-011.jpg
undefined
hi
actually i wanna cut the 1000-01-011.jpg from thestring.
If anyone can find whats going wrong please help me
thanks in advance
venu
Confusion Over SubString
I am trying to understand an accessibility example at http://www.adobe.com/devnet/flash/ar...ng_puzzle.html
If the subString notation starts at 0, I don't understand how this works:
ActionScript Code:
pp1.onRollOut =
pp2.onRollOut =
pp3.onRollOut =
pp4.onRollOut =
pp5.onRollOut =
function() {
n1 = Number(subString(this._name,3,4));
takeOut(n1);
}
shouldn't the code ask for "this._name, 2,4"?
SubString Equation
Hello,
I need help.
How to find b
substring(b, 3, 1) * substring(b, 6, 1) == 72
Best regards
X,y Position Of A Substring?
Hello,
Is is possible to find out the x,y position of a substring within a textfield?
I would like to be able to find the position of, say "::smile::" in a textfield and attach an image at that position in a different layer.
Thanks!
Substring Finder
So I'm trying to make a function that checks for a keword in a sentence a user types. When the user types a keyword the program responds uniquely. If the keyword is not found in the sentence the program responds randomly. I have been able to program it to do so but only with one keyword. Unfortunetly I have 15 more keywords with unique responses and I don't want to write 15 different functions for it to run through. Does any one know how I could put this all into one or even two funtions?
Here is the current code:
function checkInput() {
var ncheck:Number = input2.indexOf("keyword");
if (ncheck!= -1){
_root.questionLoader.gotoAndPlay(278);
}else{
_root.questionLoader.gotoAndPlay(31);
}
}
Any help on this would be greatly appreciated. Thanks
Substring Searching
have a function that sends a search term, xmllist & content to be searched with indexes at end of each line to represent item in xmllist. the function then outputs and xmllist of the found nodes that have the search term in them however if the the text in the node has two words or more words that are the same it will add that node however many times that word appears.
How do I prevent this. I have attached the code.
Attach Code
function searchStringInAttribute(list:XMLList, attributelist:String, term:String):XMLList {
var output:XMLList = new XMLList();
//trace("ALIST {" + attributelist + " } ALIST End " + "
");
var i:Number = 0;
var pos:Number = 0;
var index:int = 0;
var count:int = 0;
while (i > -1) {
pos = attributelist.indexOf(term, i);
if (pos > -1) {
index = int( attributelist.substring(attributelist.indexOf("<", pos)+1, attributelist.indexOf(">", pos)) );
output[count] = list[index];
count++;
i = pos+term.length;
} else {
i = pos;
}
}
return output;
}
Substring Substr
i can't seem to get either method to work. i just want to grab a substring from a string:
Code:
var dt:String=RS.getItemAt(q).articledate;
trace(dt);
trace("sub: "+dt.substr(1, 8));
var dte:String=new String();
dte=dt.substring(1,8);
trace(dte);
i get 'undefined' back
Substring And Split
I am trying to pass 2 values into a flash movie from the querystring. I've been successfull so far with the following code:
------
myURL = this._url;
myPos1 = myURL.lastIndexOf("?");
whichMenu = myURL.substring(myPos1+1, myURL.length);
myText = whichMenu; <-- just to display result
---
The result I get is:
m=1&s=1
which is perfect cause that means it works! woahho! hehe. What I need to do now is to assign the value of m to a variable in flash and the same thing for the value of s.
I've been rading tutorials but I just cant figure it out. Can someone help please?
Thanks!
Variable Substring Question
I have a variable that I am trying to extract a number from. Like this:
Code:
var mov:String = "img1_mc";
So I tried a substring and got a number:
Code:
var num:Number = mov.substring(6, 7);
This returns num = 1. So far so good.
My problems is that my first variable "mov" is going to change to "img10_mc". so when I use the substring my variable is equal to 1 instead of 10. How can i get the number out of this string???
Thanks
Really Strange Substring Problem...
I want to retrieve a number from a filename.
I use this code:
var fileName = "pos02280.xml";
var fileNum = Number(fileName.substring(3,8));
trace(fileNum);
This returns 2280. Without the conversion to a number
it would return '02280'.
But when I use another file, for example pos02250.xml
and exactly the same code something really strange
happens....
var fileName = "pos02250.xml";
var fileNum = Number(fileName.substring(3,8));
trace(fileNum);
Without the number conversion it returns '02250'.
But with the conversion it returns 1192 !??????
How is this possible? Is it a bug? Am I missing something?
Get A Substring From Item In Array
Hi,
i am reading up an array of strings from a text file.
In one part of my code I need to remove the last character from the entry.
for example when traced the entry is
John Smith 065, I want to end up with John Smith 06
please read the comments in the code for more explanation of the problem
Code:
//I loop through my array getting the value and storing it in TargetBase
TargetBase = ThumbsArray[i+1];
//TargetBase = John Smith 065 when traced
//then I try this
DirectoryName = TargetBase.substr(0, length-1);
//DirectoryName returns a blank when traced
what am I doing wrong?
is it something to do with the numbers in the string?
thanks mark
[help] Use Slice, Substr, Or Substring?
I need to split up some strings and was testing out my options... According to my traces, slice, substr and substring all return the EXACT same thing. According to the Flash 8 Help documentation, there should be slight differences (by one character?) but my traces don't show this.
Code:
// pos can be any number less than the length of the total string.
trace(phrase.slice(0,pos));
trace(phrase.substr(0,pos));
trace(phrase.substring(0,pos));
Anyone have any tips on which I should use??
Returning The Correct Substring
I have this string: "Slide21.swf" and I want to return just the number "21". Sometimes this number is 1 digit, sometimes 2, and sometimes 3, so it needs to cut out the word "Slide" and the string ".swf" For the life of me, I can't figure this out. Any ideas?
Using Substring To Splice XML Attribute
Ok. So I have only the concept down but not a clue how to execute it. Heres what I want to do: Use a string from my XML create mutliple substrings then feed them into a comboBox.
Heres what I mean:
<myXML>
<menu itemSizes="Small+Medium+Large" itemName="My Name 0">
<menu itemSizes="Medium+Large" itemName="My Name 1">
<menu itemSizes="Medium+Large+Extra Large" itemName="My Name 2">
</myXML>
Now take itemSizes and use
Small, Medium and Large as data and labels in a comboBox. This is how Im discecting the other attributes currently:
myXML_xml.onLoad = function(success) {
if (success) {
var root:XMLNode = this.firstChild;
for (var i = 0; i<root.childNodes.length; i++) {
var menu:XMLNode = root.childNodes;
// I shortened this dramitically but i just wanted to show you how I was working with them
menus.push({myName:menu.attributes.itemName, myName:menu.attributes.itemName});
var tmp_mc = _root.attachMovie("item_mc", "item_"+i+"_mc", i, {_y:0});
tmp_mc._x = original_x;
original_x += tmp_mc._width+10;
tmp_mc.name_txt.text = menu.attributes.itemName;
};
}
}
// I target my comboBox like this: tmp_mc.cb_mc
Substring Typeout Text
OK, I seriously need some help, on this tutorial on flashkit.com I made it but I want to get the text to start and stop at certain cue points. I'm beginning to lose hope that this isn't possible to accomplish. Click here for Tutorial For example "Testing testing ***pause for 3 seconds*** 1,2,3." Everything for this substring flash is in the tutorial.
Edited: 03/08/2007 at 12:43:36 AM by furryfan87243
Really Strange Substring Problem...
I want to retrieve a number from a filename.
I use this code:
var fileName = "pos02280.xml";
var fileNum = Number(fileName.substring(3,8));
trace(fileNum);
This returns 2280. Without the conversion to a number
it would return '02280'.
But when I use another file, for example pos02250.xml
and exactly the same code something really strange
happens....
var fileName = "pos02250.xml";
var fileNum = Number(fileName.substring(3,8));
trace(fileNum);
Without the number conversion it returns '02250'.
But with the conversion it returns 1192 !??????
How is this possible? Is it a bug? Am I missing something?
Substring + HtmlText = DISASTER *help Please*
Hi guys, what I have is a simple typrewriter effect using substring to reveal content. When new content is loaded in, I want that to replace the current text without clearing the text field. That's easy enough.
The problem is that I'm using htmlText, so when the new content replaces the old, one character at a time, the html tags no longer get read as html . . . any way to fix this? Here is the AS, and and example:
Code:
function TextTyper(targetField, targetData, targetFormat) {
var thisObj = this;
thisObj.charNum = 0;
thisObj.typerField = targetField;
thisObj.typerData = targetData;
thisObj.curData = targetField.entry.htmlText;
thisObj.dataLength = thisObj.typerData.length;
thisObj.typerDur = 20;
thisObj.typerFormat = targetFormat;
thisObj.typerInt=setInterval(thisObj, "executeCallback", thisObj.typerDur);
}
private function executeCallback() {
var thisObj = this;
if (thisObj.charNum<thisObj.typerData.length) {
thisObj.typerField.entry.htmlText = thisObj.typerData.substring(0, thisObj.charNum)+thisObj.curData.substring(thisObj.charNum);
thisObj.charNum += thisObj.dataLength/thisObj.typerDur;
thisObj.typerField.entry.setTextFormat(thisObj.typerFormat);
} else {
thisObj.typerField.entry.htmlText = thisObj.typerData;
thisObj.typerField.entry.setTextFormat(thisObj.typerFormat);
clearInterval(thisObj.typerInt);
}
}
It all works fine but when you have something like:
"<a href="blah.html">Click here!</a>" when it gets replaced with "New Content" it becomes:
"Na href . . .>", then "Ne href . . .>", and so on, meaning Flash no longer recognizes the HTML with the '<' (obviously).
Does anyone have any great ideas?
Thanks in advance!
String.charAt And Substring(str, X, 1)
Code:
var a = "texttexttext";
var i, c, t;
t = getTimer()
for (i = 0; i<20000; i++) {
c = a.charAt(5);
}
trace(getTimer()-t);
t = getTimer()
for (i = 0; i<20000; i++) {
c = substring(a, 5, 1);
}
trace(getTimer()-t);
Output:
1264
632
I was doing this testing after I've read Flash MX Quicktips for Developers, at this very site. Quote:
Use the class methods as much as possible (instead of older substring(), etc.) to take advantage of the speed increase.
Which is incorrect. Hope somebody deletes this sentence in future.
How Do I Do A Substring Or Character Replace In Variable?
I am loading an external veriable & I need to replace one or more characters within the string that loads from within flash. I suspect i have to use charAt and loop through each character or something, but i'm not sure how that's done.
So say I want to replace *all* instances of the character "@" in the variable I have just loaded with another character = "!" (or whatever).
I can also see that I might like to change whole words = eg *all* instance of the word "foo" change to "blah".
Any ideas or code fragments appreciated.
String Substring Detection Crap
I want to make an if else loop detecting the first couple of words in a sentence, such as:
if(thestring.(whatever code to detect the first, say, 25 characters)=="I want to go to the store"){
gotoAndStop(2)
}
anyone know the code for it to detect the first 25 characters? I know its something short and fairly simple, its just slipped my mind...
[MX04] Need Some Help W/using Substring() To Limit XML Text
i am using XML to populate buttons in a playlist for an mp3 player... Occasionally, the track title and artist name contain too many characters to fit in the dynamic textfield in each button. In these buttons, what i would like to do (simply for aesthetics) is, remove all the extra characters that don't fit in the textfield, including an additional 3, and trail out the text with "..."
I know I would need to use something in a form like this: (this is the bit of code that populates the text in the buttons)
Code:
playlist["btn"+i].txt = checkDigits(i+1)+". "+songTitel[i].substring(0, some_number)+"...";
but how do i find out how many characters will fit in the textfield?... because it varies with each song title/artist, due to the variation in character widths of the font. Is there a way to supply the width in pixels of the textfield, and use some other bit of code to determine how many characters in each title/artist entry will fit, so i can cut off the text and append the "..."???
any help would be appreciated. Hopefully i'm being clear enough here... if not, ask me whatever else you may need to know.
thanks in advance!!!
[F8] Substring On External Text File
Hi everyone. I've been having an issue that should be fairly easy to resolve but have been unable to figure it out even after various searches through the documentation, these forums, and the net. What I am trying to do is read in a text file generated from a batch file that lists various directories and then do a substring on the line break so that I can retrieve data from each line.
Here is an example of what the text file will look like:
directories.txt:
Quote:
directories =
C:DataSet01Run01
C:DataSet01Run02
C:DataSet01Run03
C:DataSet01Run04
C:DataSet02Run01
C:DataSet02Run02
C:DataSet03Run01
C:DataSet03Run02
C:DataSet03Run03
C:DataSet03Run04
C:DataSet03Run05
Right now in flash I have this code setup on a frame to load the text and convert it into an array so that I can do a loop to go through each line and find out the run and set numbers, but the split string function doesn't seem to be working.
Here is the actionscript code:
Quote:
var textFileData:LoadVars = new LoadVars();
var filestructure_txt:String = "";
textFileData.onLoad = function (src:String):Void {
filestructure_txt = textFileData.directories;
}
textFileData.load("filestructure.txt");
var filestructure_array:Array = filestructure_txt.split("
");
arraylength = filestructure_array.length;
I know that the load file command is working properly because a dynamic field set to show filestructure_txt shows the data properly; however, for some reason when I display the array length, it is only 1 and all the data is stored in [0] rather than the various indexes that should have been created by the split. This leads me to think that the split string is not functioning as it should. I set up a test where I used a string "a
b
c
" instead of the externally loaded file and it worked, so it must be something such as the externally loaded file isn't being recognized as a String type? Any ideas on why the split string isn't functioning properly? Thanks!
Substring Searching Text Prevent Finding Duplicates
I have a function that sends a search term, xmllist & content to be searched with indexes at end of each line to represent item in xmllist. the function then outputs and xmllist of the found nodes that have the search term in them however if the the text in the node has two words or more words that are the same it will add that node however many times that word appears.
How do I prevent this. I have attached the code.
Code:
function searchStringInAttribute(list:XMLList, attributelist:String, term:String):XMLList {
var output:XMLList = new XMLList();
//trace("ALIST {" + attributelist + " } ALIST End " + "
");
var i:Number = 0;
var pos:Number = 0;
var index:int = 0;
var count:int = 0;
while (i > -1) {
pos = attributelist.indexOf(term, i);
if (pos > -1) {
index = int( attributelist.substring(attributelist.indexOf("<", pos)+1, attributelist.indexOf(">", pos)) );
output[count] = list[index];
count++;
i = pos+term.length;
} else {
i = pos;
}
}
return output;
}
Vista - IE - Firefox - Document.location.search.substring
I have been passing a variable to flash via flashvars by grabbing the 'document.location.search.substring(0)'.
This has worked consistently until Vista came along.
IE and Firefox both now crash - Hard - when using this - document.location.search.substring(0)
Anyone else experiencing this?
Any ideas for a work around?
Basically, I just need to pass a variable to flash (within an html page) via the url.
Substring Searching Text Prevent Finding Duplicates
have a function that sends a search term, xmllist & content to be searched (with indexes at end of each line to represent item in xmllist). the function then outputs and xmllist of the found nodes that have the search term in them however if the the text in the node has two or more words that are the same it will add that node however many times that word appears.
How do I prevent this. I have attached the code.
Code:
function searchStringInAttribute(list:XMLList, attributelist:String, term:String):XMLList {
var output:XMLList = new XMLList();
var i:Number = 0;
var pos:Number = 0;
var index:int = 0;
var count:int = 0;
while (i > -1) {
pos = attributelist.indexOf(term, i);
if (pos > -1) {
index = int( attributelist.substring(attributelist.indexOf("<", pos)+1, attributelist.indexOf(">", pos)) );
output[count] = list[index];
count++;
i = pos+term.length;
} else {
i = pos;
}
}
return output;
}
|