ActionScript 3.0 :: Difference Between String(int_myInt) And Int_myInt.toString()?
Jul 21, 2011Are they the same?
String(int_myInt);
and
int_myInt.toString();
Which one should I use to optimize the coding?
Are they the same?
String(int_myInt);
and
int_myInt.toString();
Which one should I use to optimize the coding?
I create an XML object in as3 and set some attributes.
[Code]...
Than I get a string representation of this XML to save it somewhere:
[Code]...
I need to have same results for the same objects to be able comparing hashes of the strings. How can I have same order of attributes always?
Im playing around with the last.fm api... Specifically the "getLovedtracks" call.... [URL] This is a weird one that I have never come across... The above call requires a username to return a track listing so if I hard code the username into my class like this.... var username:string = "aidanmack" No problems the call works... if I make that username equal to a dynamic text box string that has "aidanamck" typed into it..
so something like... var username:string = mystage.textbox.text
the last.fm api wont except this... I get user does not exist But if I check the call with the charles proxy Flash is defo sending the username "aidanmack" So I wonder if its to do with have how last.fms api interprets the string?
It seems as thought whenever you try to treat a class as a String (such as putting it inside of trace() or similar), if that class has a "toString" function, it will get the string from whatever that function returns, and will otherwise return something along the lines of "[object MyClass]".
Are there any more of these special functions?
Also, a bit of a far stretch, is there any way to do this with custom classes, for instance, your class may be a PolarPoint, but people can call "toLinearPoint()" and get an instance of a class which is a LinarPoint but with the same data.
Now, this is simple enough to do manually, but let's say you pass in the PolarPoint in a function where a LinearPoint is expected. Is it possible to make Flash automatically run the toLinearPoint() function if found? Similar to how Flash will run toString automatically if passed in as a String somewhere.
That second part is probably more of a hassle than it is worth though, but it would be REALLY handy if you are unable to extend two classes at once, but want your class to be able to be treated as both.
I am trying to visualise in flash midi file (using an external midi-to-flash library)Is there a way to tell the difference between Violin, Viola, Cello & Contrabass in a midi file. I get these values for instruments (ignore the numbers):
1-Flute 13
2-Oboe 15
3-Clarinet 14
4-Bassoon 16
5-French Horn 18
6-Trumpet 17
7-Timpani 26
8-String Ensemble 1 3
9-String Ensemble 1 3
10-String Ensemble 1 3
11-String Ensemble 1 3
12-String Ensemble 1 3
13-Acoustic Grand Piano 5
14-Acoustic Grand Piano 5
15-Acoustic Grand Piano 5
16-Acoustic Grand Piano 5
As you can see, all the strings get the same "String Ensemble" value..one way to do it is to ask for each note if it is high (65>) or low (50<) etc and by that deciding roughly the instrument type (for a specific note). but since these values are random and not accurate - that doesn't seperate them right (especially since diffrent tools still have shared note height values). Is it written (cello, violin...) somewhere in the midi file?
Is there a way to assume it?I have 5 tracks of strings. is it possible to assume (for example) that the first 2 are violins, 3rd is Cello etc? or they are all mixed?
I have an array which has strings for the key instead of numbers. when i use .toString() on this array, it does not output a string, leading me to believe that .toString only works when you have numerical keys. Is there an easy way I could compare two of the above arrays?
View 9 RepliesI think i am lost with basics itself. What is the difference between these two. String object is an instance of String Class.
[Code]...
I've looked in the user manual and I can't find any reference to toString() for syntax information. Isn't there a parameter for me to use to specify the string lenght? And whether to add leading zeros or not?Here's the code I need to add leading zeros:
playbutt.addEventListener(MouseEvent.CLICK, playSound);
function playSound(e:Event){ SoundMixer.stopAll(); var num:Number = Math.ceil(Math.random()*43); bigNum.text = num.toString(); var path:String = "Track No" +
[code].....
So I have a flashobject which I need to pass a formatted DateTime string to.
My code:
string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
which outputs as: 2009-09-16 22:26:45
However when it is actually output to HTML and swfobject it renders it as:
so.addVariable("inNowDate","2009-09-16+22%3a25%3a13");
I think this is messing up a calculation that the flash object does based off the current time. Do I need to encode or decode this?
We have a lot of objects for which we like to implement a simple toString to output attributes of the object. Some of these attributes may be complex objects themselves. Is there any standard, or simply just a best practice for a style? I'm thinking something like:
[SimpleClassName] { prop1:value, prop2:value }
In which case a nested value would look like:
[SimpleClassName] { prop1:value, prop2:[NestedObject] { prop3:value}}
We are using Java but I find myself asking the same question in most languages!
Is it fine to display the output of Array.toString() to the user, or is there a possibility that the string format could change in future versions of ActionScript 3 or other compilers?
View 3 RepliesI have seen this done and not done on different occations... why do we need to override clone() and toString() in custom events?
Have an array which contains items in a comma delimited list such as below:
Code:
men,women,kids
outdoor,adventure
holidays,adventure
Am trying to use toString().split to further seperate them into individual entries in the array and it ain't working.
[Code]...
I'm doing a AS3 project in Eclipse and trace alot of values. I though it would be nice to have a toString() function in every class, at the bottom of each class as the last function, but i dont want to do this by hand for 500+ files. Is there a quick and good way of doing this automated?
View 1 RepliesI have the actionscript code here for a bubble popping game. When the game starts, bubbles fall down from the top of the game to the bottom and score is kept for the most bubbles clicked or popped in 30 seconds.The size of the bubble is defined by the initialize method in the code, and uses ToString() to calculate the score. ToString gives me a 1061: Call to a possibly undefined method Random through a reference with static type uint. This error which I cannot figure out where it comes from.[code]
View 4 Repliesim going through ASDG, page by page, and learning everything from scratch. he's explaining datatypes, i.e. strings, numbers, booleans, arrays, etc...i get that. then he goes into explaining how to convert datatypes from numbers to strings using "toString" , and then strings to numbers using "Number()"...and then later, strings to booleans and stuff. My question is this. where someone would want to turn a number into a string or a string into a number? and how would someone even turn a string into a number? i dont understand how that works.
View 5 RepliesI've got a Vector of ViewToActionMap objects, which have following constructor:
public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,
[code].....
In Actionscript and Adobe Flex, I'm using a pattern and regexp (with the global flag) with the string.match method and it works how I'd like except when the match returns multiple occurrences of the same word in the text. In that case, all the matches for that word point only to the index for the first occurrence of that word. For example, if the text is "cat dog cat cat cow" and the pattern is a search for cat*, the match method returns an array of three occurrences of "cat", however, they all point to only the index of the first occurrence of cat when i use indexOf on a loop through the array. I'm assuming this is just how the string.match method is. I want to find the specific indices of every occurrence of a match, even if it is of a word that was already previously matched.
how the string.match method is and if so
I'm using:
[Code]...
But I keep getting an "Error #2030: End of file was encountered." This is (probably) because the class I'm serializing is too big for the "String" object type in AS3. Is there a limitless object for storing an array of characters (or better yet binary), or am I going to have to make my own class? (like one with an array of strings)
I am trying to include double quotes in a string but logic says it would just close the string. I know in html you would use something like ". In flash...I havent the slightest.Anyone know how to go about this?
View 1 RepliesI have a String variable in my flex (flash builder 4) application containing CSV data. I need to allow the user to download this data to a local file. For example, giving them a "csv" button to click and it might present them with a save file dialog (and I would be sending the contents of my string variable).Is this possible / how ?I am using the ResuableFX component for the datagrid to csv. This the code I ended up with that works to save the string to a text file for the user (in a web browser):
var dg2CSV:DataGrid2CSV = new DataGrid2CSV();
dg2CSV.includeHeader=true;
dg2CSV.target=adgEncounters;
[code]......
I really don't understand why this won't work? I've made a test which sends some POST data to a script on my page which works fine.[code]
View 14 RepliesI'm using a pattern and regexp (with the global flag) with the string.match method and it works how I'd like except when the match returns multiple occurrences of the same word in the text. In that case, all the matches for that word point only to the index for the first occurrence of that word. For example, if the text is "cat dog cat cat cow" and the pattern is a search for cat*, the match method returns an array of three occurrences of "cat", however, they all point to only the index of the first occurrence of cat when i use indexOf on a loop through the array. I'm assuming this is just how the string.match method is (although please let me know if i'm doing something wrong or missing something!). I want to find the specific indices of every occurrence of a match, even if it is of a word that was already previously matched.
View 1 RepliesBasically I'm trying to output the contents of an XML document into a dynamic text field (as loaded - not just its node values and content - the entire thing - into a variable called _root.log). The text field is set to show the variable value of _root.log.This is the actionscript...
PHP Code:
var newProfileXML:XML= new XML("<contacts result='true'><contact name='John Doe'/><contact name='Jane Doe'/></contacts>");
[code].....
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs. at Error$/throwError() at flash.net::URLVariables/decode() at flash.net::URLVariables() at flash.net::URLLoader/onComplete()
[Code]...
I get following Error when trying to pass variables via URLRequestMethod.POST;
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
Is there a method for string URL Encoding?
I am trying to make a contact form. When I test the form, I get the following error message in the Output:
[Code]....
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs. at Error$/throwError() at flash.net::URLVariables/decode() at flash.net::URLVariables() at flash.net::URLLoader/onComplete() _____________________________________________________________________ ________________________________ stop(); var DepartVars:URLVariables = new URLVariables(); var DepartURL:URLRequest = new
[code]....
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
[Code]...
I'm not where error exactly the error happen so I post the whole thing. As far I know bottom code that relate to send_loc.php works fine, get_loc.php is having a problem. The output from get_loc.php is
[Code]...
I need to be able to pass some variables FROM flash and append it to the end of my address. I assumed that if I used LoadVars, I can append the vars to the end of the string like this:
ActionScript Code:
send_btn.onRelease = function ()
{
var my_lv:LoadVars = new LoadVars();
[Code].....