ActionScript 3.0 :: Return Const Reference To An Object?
Oct 30, 2010
I'm wondering if it's possible to return a const reference in AS3 in the same way you would in C++? I have a class with a movieclip inside and at the moment I'm returning it like so.[code]This works fine however I noticed this then allows access to the movieclip's attritbutes so then it'd be possible to do something along the lines of myClass.clip.x = 5 which I kind of want to avoid!Is it possible to make returns read only? I know it works for primitives.
I am new to actionscript and doing some research on it and stumbled upon this situation.[code]...
However, I expect that currentFig would contain a reference to a Figure object created in AddFig method, but it's not. What am I doing wrong? Why does an object exist only within a method?
I'm having some troubles with the use of interface and inheritance in AS3. I've done lots of OOP in the past and what I'm trying to do seems obvious to me, but doesn't work in AS3. The question is : Is it possible to override a function that return an Object of class A, and make it return an Object of Class B which extends A ? It seems not to be possible, since I'm getting a signature error in Flash, when compiling. For example, the following set of class do not compile (the code in function definition doesn't matter):
I am trying to understnd some of the things about packages, I have expand a book exercise and I am now trying to workout how to reference a return value within this package.I have put together this package
What I am trying to do is use the 'return(spot1);' value where 'new smiley1(); is.My goal is to be able to create the library object name, (in this case smiley1 from a string variable and then display it on the stage with addChild.At this stage I am just trying to work out how to swap 'new smiley1' with the 'return' value.I will work on the addChild bit next.
It seems that dropTarget only returns the name of the object that is directly under the mouse. Does anyone know whether there is a simple way for it return the name of the object that is under the entire bounding box of the object being dragged?
How to convert AS3 ByteArray into wchar_t const* filename?So in my C code I have a function waiting for a file with void fun (wchar_t const* filename) how to send to that function my ByteArray? (Or, how should I re-write my function?)
So, I have encountered a very bizarre scenario involving const declarations. I'm curious if anyone else has seen this as well. Note that this only happens when the game in question is loaded as an external swf.Here's my runtime error:
Code: ReferenceError: Error #1074: Illegal write to read-only property my.game.sidescrolling:BGBase::POINT on my.game.sidescrolling.Background.
I'm having a problem in flex 3 where if a static const I have defined is used as the parameter to a function call within binding tags I get a "1120: Access of undefined property NodePropertyMatrix". _propMtx is a ArrayCollection.
I want to load two picture and add every picture to every sprite object,such as picture a to sprite1 and picture b to spriteb,I know I can load a pictue by following code:
loadImage('a');loadImage('b');private function loadImage(imagePath:String):void { var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); loader.load(new URLRequest(imagePath));}private function
I'm just getting to grips now with how the Garbage Collector works.
Is there a way (like a function or a custom class available somewhere) to check an object for all its references and return them so that you can see what it's connected to?
I want to load two picture and add every picture to every sprite object,such as picture a to sprite1 and picture b to spriteb,I know I can load a pictue by following [code]...
I'm trying to create a function that determines which of 4 similar classes to create, and returns the new object itself.
Basically, I have a base class (Panel) that has 3 additional variations in layout, each of which has a subclass: TextPanel, FeaturePanel, and LinkPanel. The two parameters for my function are the "kind" of window to create and its name ("linkString"), both of which are provided by external XML. I'm wondering if it's even possible to return the new Panel as an object...?
My code will probably explain this better than I can:
Code: // create the new Panel variable ("addPanel") with a call to newPanel: var addPanel = newPanel(linkList[i].attribute("kind"), linkString); Code: // newPanel function:
[Code].....
within the Panel constructor, the provided string (linkString / 'h') is set as the Panel's .name. I did not copy that function into the subclasses, since they inherit it - unless I'm mistaken.
I want to assign an existing Object all the vars of a prototype Object, without a direct reference. One way to do this is:
[Code]...
This way both Object's values for .nom and .age can be independently changed, but it's tedious. Is there an automated way to assign all of protoObject's vars to enObj?
I got canvas objects stored in an array. Every canvas has it's name property.Is there a way to return a specific name?Actually I need an index number from that array, where I pass a name property of object inside this array (name is taken from event). Something like this:x = array.indexOf (canvasName=event.currentTarget.name)
I am trying to move text movies and textfields around a stage. This is a learning curve for me. I am confused by an example I have found on the internet.
I have a CSV reader class that parses a CSV file..... 1,11.15126526 2,11.28306635 3,10.78296071 4,10.79878325 The CSV reader class works and produces a Vector.<Point> ... However the container class (which includes an instance of the CSVFile class) needs to access the resultant Vector. Whenever I 'return' the Vector.<Point> to the container via a CSV method it is always empty...I don't know if its something to do with the size of the Vector<> or what?
I have problem with accessing object created by function imported from another package. I have 2 packages DragDrop and UserInterface. In UserInterface I create methods for buttons and later add them in DragDrop . I make it in two different ways: One(this one works):
The issue i'm having is that i want to have dispersed code-generated stars, and then they form a form (reindeer, santa, etc).
The idea is how i make the stars disperse and then return to their previous positions, knowing that the initial positions were randomly generated as well.
I want to print the content of the label property in the Alert window.[code]...
But the Alert window is completely empty. What am I doing wrong ?
I guess the keyword "this" is referencing the application instead of the LinkButton, right ?How can I reference the LinkButton itself, without having to add an ID to all my linkButtons?
I need to get a pointer to a piece of XML. I can get a pointer to the parent node and everything works but trying to get a pointer to a node that has no children just returns the value of that node.[code]...
Tracing subNode would be just the value and there is no pointer to the original xml object, so editing the subNode var would only change its value, not the one in the original XML object.
How do I get a pointer to the subNode so it can be edited to change the original xml object?