ActionScript 3.0 :: Keeping References To Primitive Data Types/Properties?
Oct 26, 2009
Primitive Data Types (Boolean, int, Null, Number, String, uint, and void) are treated as "values" rather than Objects, so when you pass one of them into a function, instead of passing a reference, it basically clones the information, and creates a new instance. It does the same thing when when you use "primitive1 = primitive2", and instead of passing on a reference, clones it.I thought there might be a slim possibility Flash allows me to reference primitives if I treat them as objects instead of (in this case) ints.
Code:
var num1:int = 5;
var num2:Object;
[code]......
View 6 Replies
Similar Posts:
Mar 19, 2012
Types like Movieclip , String, Object act as references when declared and defined, while types like int, Number are primitives. Why such difference has been made. Why not all of them can be primitives ?
View 1 Replies
Jul 4, 2011
my understanding is that primitive types (uint, string, Number, etc.) of a class do not need to be set to null for garbage collection.
for example, i am not required to write this dispose() method in the following class:
package
{
//Imports
import flash.display.Shape;
[Code]....
if this is true, which i believe it is, what is the difference between objects of primitive types and objects of non primitive types concerning memory allocation?
View 2 Replies
Jan 24, 2012
Consider the following function:
Code:
public function foo(bar1:int, bar2:uint, bar3:String, bar4:Boolean):void{}
What I want is to have the different types of data represented by custom named types which are essentially representing the original data types. I other word, I would like to proxy the data types and have a valid function as following:
Code:
public function foo(bar1:PAR_Bar1, bar2:PAR_Bar2, bar3:PAR_Bar3, bar4:PAR_Bar4):void{}
so PAR_Bar1 would proxy the `int` data type, PAR_Bar2 would proxy the `uint` data type, so on and so forth.
The reason I need this is because I'm using a debugger with a GUI that can run methods and allows changing function parameter values in real-time, the issue is that the debugger can't tell me what parameter I'm changing, it only displays the data type of a parameter. So if I need to change 10 different parameters all of type int, the debuggers display all of them as int and not by their names.
I think that if I use proxy types I can easily differentiate between parameters.
So, my question: Is it possible to proxy data types? I mean map specific data types to custom data types that would represent the base data types?
View 2 Replies
Dec 20, 2011
I would like to extends the Event class to add some events I am using in game. But I don't want the new Event Class to have the old public static types. For instance I don't want to have:
NewEventClass.ENTER_FRAME
How do you go about extending the Event class without getting the old types mixed in?
Is there any way to outsmart AS3 to leave out the uneeded types?
Or should I avoid creating a new Event type altogether and just add the new strings?
View 1 Replies
Apr 7, 2006
Does anyone know of any really easy and effective ways to move complex data types from PHP into FLASH and vice-versa? A while back I made an attempt to recreate PHP' serialize() function in actionscript but it was really difficult and performance was poor.
I'm able to do it fairly easily for one dimensional arrays indexed by numbers, but when I have to pass either an object (or several objects) or when i have to pass a nested array of arbitrary complexity (such as a data tree) then I get bogged down.
I have a little experience dealing with XML in flash (working with the tree component) but it seems like so much effort when i am dealing with a new data type.
Does anyone know of any pre-packaged components or code (in actionscript and complimentary part in php) that might be useful?
View 3 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
Sep 8, 2010
I am trying to pull a text from within xml tags and place them in a text box when certain mc's are clicked. I am using the e.target to find the name of the mc clicked and grab info from tags with the same name as the target mc. The XML link is good as i can get data when doing tests with out using mentioned technique.
ActionScript Code:
package {
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
[Code] .....
And the xml file
Code:
<statsIcons>
<pollutionIcon_mc> some text </pollutionIcon_mc>
</statsIcons>
View 1 Replies
Jan 24, 2012
Consider the following function:
public function foo(bar1:int, bar2:uint, bar3:String, bar4:Boolean):void{}
What I want is to have the different types of data represented by custom named types which are essentially representing the original data types. In other words, I would like to proxy the data types and have a valid function as following[code]...
View 3 Replies
Jul 22, 2010
Im trying to wrap my head around data types and phrasing them from xml. From what I gather variables that come in from XML are always treated as a string - even if you declare them as something else before hand? Im not seeing that myself as everything else other then the Boolean is behaving as expected. For example in the code below, if I declare FGFILLCOLOR as anything other then an int, or Number, I get an unrelated type error. So why just Boolean and how can I convert them so they behave properly without declaring all of them as a String? Though I've seen a few related solutions posted around but I wan't able to sort them out.
[Code]....
View 9 Replies
Jul 22, 2010
Im trying to wrap my head around data types and phrasing them from xml. From what I gather variables that come in from XML are always treated as a string - even if you declare them as something else before hand?Im not seeing that myself as everything else other then the Boolean is behaving as expected. For example in the code below, if I declare FGFILLCOLOR as anything other then an int, or Number, I get an unrelated type error. So why just Boolean and how can I convert them so they behave properly without declaring all of them as a String? Here is what I've got:
the xml
Code:
<VARIABLES>
[code].....
View 6 Replies
Apr 21, 2011
WSDL defines a number of datatypes supported by web service . Is there a documentation stating the various equivalents of those datatypes on flex side. In general for any language that we use to consume web service, how do we get to know the equivalent datatypes of the wsdl types.
One of the web service that I am consuming is returning base64Binary (an image binary data) , What is the equivalent datatype of this on flex ?
View 2 Replies
May 23, 2009
In my code there's a function that shows an image on the screen (or loads the image and shows a progress bar). This function is called by clicking on a thumbnail, and it uses a parameter [e.target.name] refering to the property "name" of the thumbnail clicked, which is an integer (or I believe so). The thumbnails are placed inside the cointaner_mc MovieClip.
Code:
container_mc.addEventListener(MouseEvent.CLICK, clickThumb);
function clickThumb(e:MouseEvent):void{
if (my_full_images[e.target.name] == undefined){[code]...
but I want to call this function by clicking on a button, which would need to pass another type of parameter, in this case, a variable which refers to the number of the image displayed on the screen plus one.I tried this:
Code:
clickThumb(image_num + 1);
But it doesn't work, I get the following error:
1067: Implicit coercion of a value of type Number to an unrelated type flash.events:MouseEvent.
How could I call the function clickThumb and make it use "image_num + 1" instead of "e.target.name" ?
Could I dispatch the event (MouseEvent.CLICK, clickThumb), passing this value "image_num + 1" ?
View 2 Replies
Jun 11, 2010
I am working on a modularized Flex application, and I am trying to cut-down on the amount of client-server interaction.Every time a module is opened, a request is made to a web service to get values to bind to the Flex form. If a user closes the module, and then reopens it at another time during their session, the same web request will be made.Since this data is static, i.e. not changing, I am thinking about creating global variables to hold the data providers. On the initial application load, a series of web service calls will be made to fill all needed data providers. Then, any time a module is opened, it can use these global providers instead of making unnecessary and repeated requests. These are NOT going to be huge providers, so I don't think browser memory should be a concern.
View 1 Replies
Mar 7, 2004
i've been struggling with the following:
i am creating a list of buttons with an attachMovie. the AS is :
//as
var i = -1;
while(++i<userlist.length){
var user = userlist[i];
[Code].....
okay the problem is this: then i assign an on click function to every button right in the while loop that uses the data parameter of the "ob" object and when i play the movie the data parameter is always the parameter of the last object created for all the buttons. I know why this is happening- it overWrites the old "ob" with the new with every itteration of the loop.
But how would i go differently about creating an individual "ob" for each button created and still be able to have a function with a data parameter like this.onRelease.userClicked(data)?
View 9 Replies
May 26, 2011
I wish to pass a reference to _camera.y, but _camera.y is a primitive and gets passed as a value.Here's the code for a little debugging class.
ActionScript Code:
package
{
import flash.events.Event;[code]..........
If I call watch("Cam Y", _camera.y) I get "0" traced out all the time - I assume because the y position of the camera is being passed in as a value.I want to pass it in as a reference so that this little class will keep an eye on the y position of the camera.
View 2 Replies
Jan 14, 2011
Is there a way to tween the oval primitive from within flash? I would like to do a tween where I move the start angle, but I can't seem to be able to tween the oval. Is this possible?
View 1 Replies
Mar 16, 2009
I've searched around the web trying to find out how to set the primitive Plane backside material in papervision. Unfortunately without luck. That is why I'm turning to you,My question is simple (as written above):How do I set the background material of a Plane primitive in Papversion 2.0?
View 1 Replies
Dec 7, 2007
I code other languages, Javascript,PHP, XHTML, CSS etc. I hope to get into this. I was just wondering how I can edit a primitive oval object thats on the stage in actionscript.
View 7 Replies
Nov 28, 2011
I have a Plane and I try tweening a MovieClipSprite on it. I run into trouble when I try to tween near the points where both segment triangles meet (I have kept both segments as 1), While moving near these points the Sprite disappears. I can tell it goes beneath the Plane because when it reappears it does so gradually and I can see it's lower half appearing as it moves away from these points. Increasing the segments obviously deteriorates the performance further as this begins to happen at other points as well. I am pasting some relevant code var planeMaterial:BitmapMaterial = new BitmapMaterial(texture.bitmapData, {smooth: true, precision: 4});
[Code]....
View 1 Replies
Feb 12, 2009
Can i change the fill color of an existend rounded rectangle primitive?[code]
View 7 Replies
Mar 17, 2007
Is it possible to access the properties of an image when it's been loaded in to an swf?
I am thinking of the properties which can be edited and displayed in the Windows directory listing.
The image 'contents' field could then be used as the caption for the image viewed in flash.
View 2 Replies
Feb 19, 2009
When working with XML I find it best to bring in the XML document and then add the data to new objects so they can be easily referenced later. Previously I have done this by hard-coding the node names when I parse the XML and add the appropriate data to a property in my new custom object, allowing me to state what type of data it is, array, string, etc. I would really like a way to do this dynamically, so when I parse the XML it detects whether the node has children and makes an array, etc. Something was done by XML2Object in AS2.
View 4 Replies
Dec 11, 2009
Previously I post a discussion on this matter on Flex Adobe forum and still don't understand what needs to be done. So, I'll try my luck again on stackoverflow. I'm using drag and drop data binding functionality in flash builder 4 on a data-grid. However, the data I need to show need to be query from another object.
[Code]....
View 1 Replies
Jul 3, 2009
I am creating objects (MovieClips) which have properties in the form:
obj1.property1 = "T-shirt";
obj1.property2 = productID;
obj1.property3 = Size;
obj1.suboption1.property1 = Small;
[Code]...
View 5 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
Sep 27, 2011
I am not sure my title is correct.Is there any 3rd-party library on AS3.0( like STL in C++), can do this: I define my class and use its objects as associative array, for example:
class Company{
var public name;
var public logo;
[code].....
View 7 Replies
Sep 27, 2011
Is there any 3rd-party library on AS3.0( like STL in C++) around, can do this:I define my class and use its objects as associative array, for example:
class Company{
var public name;
var public logo;
var public address;
var public telnumber;
}
And use a kind of data structure class(say, List) to store a few Company-type objects. And then, I define my own comparing and searching function on that List class(namely, override the default one); within my functions I could specify on which attribute(name, or address, or telephone number) to perform searching, and how it would be performed.
View 4 Replies
Dec 19, 2011
i have my HTTPService, it looks like this :
<s:HTTPService
id="setCustomerInstalledPackageService"
url="http://localhost:8090/myapp/servletName"
[code]......
View 1 Replies
Apr 20, 2011
I have a situation where I need to update a DropDownList's dataProvider and selectedItem in a specific order. See the following code ...
<s:DropDownList id="dropDownList"
dataProvider="{someDataProvider}"
selectedItem="{someSelectedItem}" />
In my case, some user interaction produces new values for the bindable variables "someDataProvider", and "someSelectedItem". However, when flex renders the DropDownList, the control's selected value is empty.
The reason for this is that the DropDownList's "selectedItem" property gets bound before the "dataProvider" property. The "dataProvider" needs to be bound first for "selectedItem" to be valid, this is because the new "selectedItem" points into the new "dataProvider".
what is the best practice for updating bindable properties in a specific order? I've come up with a few ways (e.g. using a valueCommit handler), but I wanted to see what the community had to say.
View 2 Replies