ActionScript 2.0 :: Converting Data Type?
Sep 16, 2004
So I'm importing this file called tbox.txt and in that file it has a variable, num, which equals 3. Now when I run the debug window, it comes back as num = "3". So its a string. so I do num=num-0 to make it a number instead of a string. And it doesn't work so I do a trace on num and it comes back as undefined.... which is what I dont understand, how can it be "3" and undefined at the same time.
View 4 Replies
Similar Posts:
Nov 9, 2006
I have this code inside my flash to name my navigation menu. Now I want to put this outside flash and load it via XML. How do save my different arrays into a variable for later use in my code?
In my nav fla (what i want to load from XML):
Code:
// MAIN MENU ARRAY
var mm_array:Array = ["MAIN1", "MAIN2", "MAIN3", "MAIN4"];
// SUB MENU ARRAY
[Code]...
View 9 Replies
Mar 25, 2009
I feel like this should be really easy, but I don't get what I need to do.I have a value bgW[j] stored in "j" equaling a number.But I can't seem to get it to register as a number.What commonly needs to happen to convert this value into a numeric datatype?I've tried a bunch of stuff: eval, parseInt, multiplying it by 1.
View 2 Replies
Jul 28, 2011
I need to send a byte array of data (its an image source) along with a bunch of other vars to a service.If I send the byte array using something like the following
var request:URLRequest = new URLRequest ( 'http://www.mydomain.com/upload.php' );
var loader: URLLoader = new URLLoader();
request.contentType = 'application/octet-stream';
[code].....
View 1 Replies
Jun 4, 2009
i load in AS3 data into flash and mantain their data type? Like receiving an array and even with arrays in it and recognizing that is an array instead of a standard string.
And if this is possible is it more reliable then using XML?
View 1 Replies
Jan 1, 2010
It is possible to convert microphone data into AMR based data?
View 1 Replies
May 22, 2010
I just started using AS3, I'm trying to do is pipe xml data to flash to be stylized in a text field, then save as transparent png. Right now I have a problem; when I run the script with this.addChild(this); it takes a snap of only the first entry, and only the first entry to output. If I leave that out, it sends all 750 entries to the output screen, and it parses the xml like it should (w/ out the text clear at the end, it applies all 750 entries filter styles to the one textfield). So I'm assuming everything is working right with parsing the xml, and it's just getting hung up. I'm assuming I have this setup all wrong, but it's the only way I could get it to work... this.addChild(this); just seems wrong, but it's the only way I could snag root, and write it.
Here's my code (I don't need this all proper for use on a website or anything, just to run a few times to batch out some xmls).
ActionScript Code:
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.text.TextField;
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
[Code] .....
There's no code implemented for saving the bitmap data to png. I'm using cs3 right now, so no FileReference.save() feature. I plan on finishing it on a buddies box w/ cs5. On a side note - Would it be possible to compile this with flashdevelop to get this feature? I've never used it...
Here's an example of my xml:
<game titlem="filenameoutput"></game>
<namem desc="name description"></namem>
<manu manufact="manufacturer"></manu>
<year yearmade="19xx"></year>
Probably not the best, but the best I could manipulate the source file w/ regular expressions and sed, and still have it work with the xml tutorial I was referencing. I can try again if it needs to be setup differently. Is it possible in as3 to create a gradient that has one color on top and one on the bottom? I've always failed miserably creating these in previous versions, so I didn't even try.
View 1 Replies
Mar 16, 2011
I get this out put (each row is a different element) and I don't know how to convert it in to a readable value.
it should be number with 9-10 digits. from what I have seen in other sites regarding this specific data (this is the value of the tempo in a midi file) - it looks something like this: "tempo is 06 96 27 (in hexa format)"
these values are ByteArray type. how do I convert them to the readable numbers (or perhaps they contain text)?
View 1 Replies
Sep 23, 2006
I want to load an image using XML and have that image be a button.
View 2 Replies
Apr 8, 2011
I have the job of recreating a flex app in HTML and CSS. The existing app makes considerable use of TextFlow to layout content. For several reasons I need to be quite accurate (within a few pixels) with positioning.
[Code]...
Ideally I'm looking for a library I can use to translate these many attributes into "proper" html and css. The current technology stack is PHP at the back end and javascript at the front end, but there would be little problem in using any other language to do the translation.
Failing that I guess I'll try and write my own, using the api reference as a guide.
View 3 Replies
Aug 31, 2011
I am developing a mobile project in Flash builder using flex 4.5. I am very new to flex, with some background in Obj-C.urrent Setup:I am passing the text property of a text input component to a second view via navigator.pushview{view.Someview, data}public function doSomething():void{navigator.pushView(Session_View, timeInput.text);This successfully passes the text I put into the textinput to the Session_View instance and I can display that text in a label in the mxml; however, I would like to take the text passed and convert it to an integer to use in my logic.Within Action Script I have tried parseInt() function with no luck.I have also tried to assign data to a variable in actionscript with no luck.
View 1 Replies
Aug 17, 2009
Below is basic structure of LetterClip class which extends WMovieClipwhich inreturns extends Movieclip Class.
public class LetterClip extends WMovieClip
{
public function LetterClip(char:String):void
[code]...
Error occurs at the push statement.It throws the given below error only when the same activity is executedsecond time in a sequece.
TypeError: Error #1034: Type Coercion failed: cannot convertorg.waterford.activity.erp.erp1.r1lt08.clipclass::LetterClip@282e9281 to org.waterford.activity.erp.erp1.r1lt08.clipclass.LetterClip.#Operating System: Windows XPBrowser: Microsoft IE
View 1 Replies
Nov 27, 2009
I have intercepted x-amf data being posted to a website from my computer by a flash application. I have the collected POST data in hex form. While some of it has translated directly to text, the rest is showing wierd symbols which probably means they're flash objects. How do I parse this data to get meaningful output outta it?
Basically, I need a script/program/anything that will take in amf data in the hex form, and output text and flash objects...
View 1 Replies
Apr 1, 2010
I'd like to make a call to a function and send either a string or an integer...
function getImage(val:*):void{
if(val == String){
switch(val){
case'next':
loadNext();
[Code[ .....
and vary my function accordingly...
View 2 Replies
Oct 27, 2010
I know I can attach audio and video to a NetStream. Apparently, I can also attach text messages although I haven't seen an example (if you know of one, please let me know). I also know that I can record a stream via Flash Media Server. I'm wondering what other types of data - if anything - else I can attach to a NetStream and record?
View 1 Replies
Dec 29, 2011
I have a class with a contstructor that should only change the source of an image.
[Bindable]
[Embed(source='../pictures/test.jpg')]
private var _picture:Class;
[code]....
(the image is not an image, but a class)The problem is that when I call the constructor, let's say:
var test:Test = new Test(pictureAtStage.source);
Flashbuilder will give an error, becouse I can't tell the compiler what data type "newSource" at the constructor will have...
*edit:When i use _picture.source, the embedded source does not seem to be changed...?
View 3 Replies
Jan 15, 2006
I'm trying to do something such as:
Code:
var n:Node = openList.shift();
I know that all of the data contained inside openList is a type of Node object, but Flash returns an error. I don't know how to typecast such as placing (in another language)...
Code:
(Node) openList.shift();
...to tell Flash that the data returned will be a Node object.
Better yet, is there a way to specify, while declaring the array, the type of the data that will be placed in it?
I could just take the :Node tag out from my variable declaration, but this might be in a tutorial, so I should at least act like I believe half the stuff about proper coding I write about
View 3 Replies
May 1, 2008
I'm trying to get the sum of two number values in an XML file, so I'm doing this:
PHP Code:
_root.gallery_height = myGalleryXML.firstChild.attributes.height; // '200'
_root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing; // '20'
_root.bar_y= _root.gallery_height+_root.spacing;
trace(_root.bar_y); //outputs 20020
The answer is supposed to be 220, but it comes out at as 20020 because the interpreter treats then as strings.
I can fix the problem by casting the type using the Number() method this way:
PHP Code:
_root.gallery_height = myGalleryXML.firstChild.attributes.height; // '200'
_root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing; // '20'
_root.bar_y= Number(_root.gallery_height)+Number(_root.spacing);
trace(_root.bar_y); //outputs 220
This works fine, but is it *the right* way of doing it? Why is Flash treating my numbers as strings?
View 3 Replies
Mar 14, 2009
I have a function and it accepts an argument, it can be a MovieClip or an Array. How can I determine what the type is of the argument? I did an attempt, but it didn't work, my code currently looks like so:
Code:
var peopleArray:Array = new Array("Alfred", "Bob", "Casper", "David");
function myFunction (givenArray:Object) {
if (givenArray.dataType == Array) {
trace ("This is an array");
// do stuff where an array is needed
[Code] .....
View 1 Replies
Feb 23, 2010
i'm linked a MovieClip class object to my project, and i will programatically add it to the display list. is there a difference between defining the variable's data type and not doing so? neither produce a runtime error.[code]
View 1 Replies
Nov 16, 2010
I take a date (as a string data type) from the user. Now, I want to know if there is a a function in actionscript that will convert it to a date format. Right now, I am just parsing the string and concatenating the pieces back together. i.e.:
changeDateString = date.getFullYear().toString() + '/' + (date.getMonth()+1).toString() + '/' + date.getDate();
But for months like May, it will return "5" and not "05". I have similar problems for days like "9" or "7." Is there something in the library that will do this for me? (For the moment, I can go ahead and manually concatenate the "0" in front, but this seems like a hassle to do.)
View 1 Replies
Jan 25, 2011
What data type do I use in flex (flash builder) to create a "double" or "float" data type. I need the numbers after a decimal point. (i.e. prices)
View 2 Replies
Jul 15, 2011
I am trying to save a Sprite object as a file on the device I'm working on and it seems to work. the problem I'm having is reading the saved file back and placing it back on stage as a sprite. Below is the code I have so far, could someone tell me what it is I'm doing wrong? I have a suspicion that the saved isn't what I expect it to be since the file sizes have been under a kilobyte.
public function save_album(e:Event):void
{
var outFile:File = File.documentsDirectory; // dest folder is desktop[code]....
View 1 Replies
Jun 24, 2009
so I'm not just new here, but definitely new to actionscript (though I have a MINOR amount of OOP experience in matLAB). I was wondering if someone could clarify something (though I'm sure this thread will grow out of my own confusion)?
[Code]...
View 4 Replies
Jan 20, 2010
i want to use a variable to load a mc [code]when i use "string", it works locally but not uploaded on the server
View 1 Replies
Dec 27, 2011
When adding Numbers, AS3 seems to add incorrectly?:
Code:
var num:Number = 5.4;
for(var i:int=0; i<100; i++)
{
[Code]...
Why do I get Numbers into the tens of decimal points?
View 1 Replies
Sep 16, 2009
How can I define a custom data type in flash? for example in C/C++ I can do something like this:
[Code]...
Is there a way something like this can be done in flash? Basically I want to be able to create my own variable types.
View 3 Replies
Feb 8, 2010
I need to create a custom Object that basically stores some custom parameters (properties?), which I have successfully done, and the code below works fine.
PHP Code:
myObject = new Object();
myObject.nameLabel = "New Releases";
myObject.artOrientation = "portrait";
myObject.artAmount = 5;
I find the new compiler and debugger capabilities very useful, since I'm not the most detail-oriented, so I (usually) like that Flash forces me to strict-type my variables and such. Anyway, I was wondering if it's a "best practice" to strict data type a custom objects' properties, and if so, how to do it in the logic above? I kept getting syntax errors when I just tried it initially.
I know if I created a custom Class .AS file, I would be forced to data type the properties... but I'd rather just do it "in-line" in my main .FLA file. Also, I know I can just pass typed VARIABLES to the properties... but I'd rather have the properties strict-typed themselves... so if I try to pass a variable as the wrong type, then I would still get an error.
View 2 Replies
Feb 17, 2011
Typically you create a Vector (strongly typed array) specifying a data type like:
new Vector<PictureBox>();
However I need to create a utility method that should be able to create a vector of any given datatype. Is it possible to specify a type using a variable instead of hard-coding it?
var type:Class = PictureBox;
new Vector<type>();
View 2 Replies
Apr 25, 2011
I am loading images and data into flash via XML. Some bits of data are missing an image or just don't have one for various reasons. When the image URL is null flash returns the message TypeError: Error #2007: Parameter url must be non-null. I have been trying to catch this error using IO error event but I am unsure if this is the the correct method for doing this as I can't seem to get it working. This is causing a problem for me because when I add the items to the stage the data doesn't match the images and what I would like to do once I am able to capture this error is push a default image into the _trackArray which i will then use to add items to the stage.
[Code]...
View 2 Replies