19
votes
6answers
46k views

how do I delete/gc an object in Actionscript 3?

I want to delete/force garbage collection on a class instance from inside itself. Obviously, this = null and delete this don't work. Is it any way I can do that, or am I barking up the wrong tree? I'm ...
12
votes
3answers
14k views

Accessing the Document class in AS3

How can instantiated classes access the Document class? Even after I name the Document class using the Properties bar in Flash, attempting to access it from other classes usually fails, saying ...
9
votes
1answer
4k views

Flex 4 two classes in one file

Can I put two or more actionscript classes in one .as file like this: //A.as package classes { public class A { public function A() { var b:B = new B(); } } ...
9
votes
3answers
2k views

AS3 - Can I know if a class implements an interface (or is a subclass of another class)?

With this code function someFunction(classParam:Class):Boolean { // how to know if classParam implements some interface? } i.e. Comparing classParam with IEventDispatcher interface: ...
5
votes
2answers
3k views

Templates for AS3 (like c++)

How do I define C++-like templates in AS3?; I have a map class (2d array) that I want to re-use across projects but the cell data is a different class depending on the project or implementation; ...
5
votes
5answers
2k views

Dynamically instantiate a typed Vector from function argument?

For a game I'm attempting to develop, I am writing a resource pool class in order to recycle objects without calling the "new" operator. I would like to be able to specify the size of the pool, and I ...
5
votes
1answer
2k views

AS3 Two MovieClips Sharing The Same Class

I have two MovieClip symbols in my library and I want them to share the same class, but Flash doesn't allow me to assign the same class to any two different MC symbols, so instead I created two bogus ...
5
votes
5answers
908 views

How to properly test for class inheritance in ActionScript 3?

In ActionScript 3, you can figure out whether object O is of class C or of a class that extends or implements class C (directly or indirectly) using... if (O is C) { ... } What I want to do is ...
5
votes
3answers
856 views

Reading all classes under a package or reading classes with same Metadata in Actionscript 3.0

I am doing an Actionscript 3.0 project which involves introspection. I am wondering if there is a way to get all the classes within a given package structure. For e.g. Say there are three as3 ...
4
votes
1answer
3k views

Is it possible to remove properties from a dynamic class?

I have a dynamic ActionScript Class that is used to send parameters to a WebService. Some of these parameters are always present, so they are public properties of the Class: package { [Bindable] ...
4
votes
3answers
10k views

How to access the stage from an AS3 class in Adobe Flash

The problem I've encountered is that I am using a keyboardEventListener to make a movieclip run around. As I'm a college student, I'm creating this for an assignment but we are forced to use as3 ...
3
votes
3answers
5k views

Definition fl.video.FLVPlayback could not be found

I'm stumped. I have two flash files I'm authoring. File A has a MovieClip on stage that has a linkage to a class in which I import fl.video.FLVPlayback File B also attempts to import ...
3
votes
3answers
9k views

AS3 Error: '1172: Definition fl.controls:Button could not be found.'

I am trying to create a class called LinkButton, which is a simple class that loads a URL on a click (im doing this to simpify my designers' transition to AS3). Even though I am importing the button ...
3
votes
2answers
3k views

AS3 Get the current class name from a static method

i have to read the current class name inside a static method. For non-static method it's easy i just call getQualifiedClassName(this) but inside a static method this is off course invalid. Any idea ? ...
3
votes
3answers
659 views

How can I determine a Class's superclass at runtime?

In Actionscript 3, if I'm given a Class object, is there any way to determine if that class extends from another given class? I don't want to instantiate the class to check it with the is keyword, ...
3
votes
2answers
2k views

AS3 string to class

How can I convert a string to a class without getDefinitionByName because that class is not linked to a library item and getDefinitionByName only works with classes that are linked to library or ...
3
votes
2answers
70 views

Why does this property/function name collision compile in AS3?

In ActionScript 3.0, this compiles: public function set func(value:Function):void { } public function func():void { } This doesn't: public function set someVar44(value:int):void { } var ...
3
votes
2answers
979 views

AS3: if-function doesn't listen to a boolean in another class

So... I'm working on a chess-game, and trying to make it so that a "public static boolean" (turn) dictates which player can make a move. This boolean is in a class (Board.as) which imports all the ...
3
votes
3answers
576 views

Actionscript overriding methods in extended interfaces vs Java?

I am much more familiar with Java's semantics of class and interface than with Actionscript semantics, but I have an example of some code that works in Java and doesn't work in Actionscript. This ...
3
votes
4answers
838 views

Using Flash Builder to create a collection of AS3 classes

How can I set up a project in Flash Builder for creating a collection of classes that is not an application by itself? When creating an Actionscript project it forces having a main application file, ...
2
votes
5answers
5k views

Get a class from my flash library dynamically

I have several bitmaps in my flash library that I have exported for Actionscript. Now depending on the Flashvars I receive I want to load the corresponding library bitmap. How do I load a bitmap ...
2
votes
4answers
494 views

Flex Comparing Class Object to Class

The question itself may not convey exactly what I mean, so I will quickly jump into the code. var myClass:Class; And I have my Class A defined with myClass storing Class A. myClass = ...
2
votes
2answers
998 views

AS3 as vs Class()

I don't fully understand the advantages/disadvantages between these two methods of typecasting in this example: for each(var i:DisplayObject in _display) { trace(i as Sprite); ...
2
votes
3answers
9k views

How to call a function in a Class from another Class?

Update: Modified title to better reflect my question Hi everybody :) My question today revolves around a CustomEvent I'm trying to send from one sub Class to another. I've used my CustomEvent class ...
2
votes
4answers
172 views

as3 - figure out the variable type from an empty variable

Is it possible to figure out the variable type when the variable isn't instantiated? Example of what I'm trying to accomplish: var foo:ExampleOne; var bar:ExampleTwo; var arr:Array = [foo, bar]; ...
2
votes
3answers
2k views

Flash AS3 - Objects of same base class in library - Type coercion failed

This happens to me a lot and I've yet to find a good solution. Say you have two classes, Tree (com.company.Tree) and Fruit (com.company.Fruit). On the stage in Flash, the Tree has an instance of Fruit ...
2
votes
1answer
41 views

AS3 - Is there a way to retrieve the entire package and class name as a String?

In a class I want to retrieve the package + class name of the current class as a String. For example, within a class named Inhabitant within package terra.environment I might want to go: ...
2
votes
1answer
231 views

Pass class as constructor's argument

I'm trying to pass my object class as constructor argument. I have something like this: package myclass { import flash.display.MovieClip; import flash.display.BitmapData; import ...
2
votes
3answers
714 views

How to pass a reference of a movieClip made in one class to another?

I have a movieClip with a button that I created inside of my display class Thumbnail.as and I have a button function that interacts with it inside of my ui class ThumbnailController.as. The current ...
2
votes
3answers
886 views

AS3: streamlining a 'universal loader'

In Flash Action script 3, when you need to load text, you use a class called URLLoader, and when you need to load an image (or .swf) you use a class called 'Loader.' As far as I know, loading a .bmp ...
2
votes
1answer
180 views

Classes don't match between main SWF and runtime loaded SWF from another domain

I load an external SWF. The external SWF has an embedded DisplayObject (getChildAt(0)) and I get an instance of its Class with the following code: public function getEmbedded():* { var ...
2
votes
1answer
129 views

FLASH AS3 EXTERNAL CLASS

I have a problem regarding as3. I have done a flash application that include an external class in the same folder with the swf. Now the problem is, when I edit the information on the external class ...
2
votes
2answers
1k views

{AS3} addChild() in a Class does not work

so I have a class: package { public final class Main extends Sprite { private var TextHolder:Sprite = new Sprite(); public function Main():void { ...
2
votes
1answer
198 views

Namespace vars between Classes

Synopsis How do you declare variables in a namespace while using the use statement? (ie., without declaring the namespace with the variable name) How do you reference namespace variables with the ...
2
votes
1answer
4k views

Loading .swc assets into array, in pure Actionscript 3 project

I know how to get Flash CS4 symbols into Flash Builder via .swc. The class names become available in the main class, but I can only instantiate those one by one, writing each name into the code. How ...
2
votes
1answer
916 views

Actionscript 3.0 Setter - Getter

I want to pass Value from Constructor in my Main Class to another Class. Main Class: public function Main() { Snap.locationX = 350; } Another Class: public function get ...
2
votes
3answers
1k views

AS3 window class which can hold components

I need to create a "popup window" in AS3, which can contain things like textboxes and datagrids and stuff like that. I have searched thoroughly, and have been unable to find such a component or ...
2
votes
2answers
595 views

AS3 Error 1120, after extending a class

I don't how to describe the situation in short, so I am going to describe it in details. I have created a class, extended from MovieClip. It looks like this: // Libraries are imported ...
1
vote
2answers
461 views

Array of Class Names AS3

I've got several movieclips in my FLA library with classnames applied. In my AS package file, I've got an array of those classnames. What I'd like to do is display the movieclips on stage as follows: ...
1
vote
4answers
5k views

Get all static variables in a class

I have this ObjectType class which is a class to help me do something like this: object.type = ObjectType.TWO //ObjectType.as package { public class ObjectType { public static var ...
1
vote
2answers
183 views

AS3 class instances names

I really wonder. I made a MovieClip class Apple, I wrote a function that creates a new instance with a name "apple". Each time a new instance is pushed into an Array "apples". I call the function 5 ...
1
vote
1answer
276 views

What is the best way to distribute as3 classes and packages?

I have a small framework that I would like to put out there. I would love to export these classes as a single file. I know there is a SWC format, but there is not much recent information on how to ...
1
vote
3answers
426 views

How can I pass all parameters (one by one) in an object to a constructor in AS3?

This is a hard question to do, but I'll try to explain. I have the Class and the parameters of its contructor as an object. What I need to do is a function that returns an instance of this class, ...
1
vote
2answers
231 views

Using multiple or only one eventlisteners in actionscript 3

Sorry for the lame question but I don't know how to search for it. So if I have two events from the same class like: package { import flash.events.Event; public class StylingEvent extends Event{ ...
1
vote
3answers
711 views

counting the number of instances of a particular class on stage in as3

Does some one know how to get the number of instances of a particular class (in my case Ball.as) currently on the stage. Note: I want a solution to not include the use of numChildren and then looping ...
1
vote
2answers
2k views

AS3 Global class that can add objects to stage

So I recently learnt that by importing a class into my main class I can access its functions from any other class. BUT.... one of my functions in the imported class needs to add display objects to the ...
1
vote
1answer
616 views

Programming a simple AI in AS3

I'm trying to create a little game where you can control a movieclip around the board with arrows keys and at the same time there are little characters walking around. I have an event listener for ...
1
vote
1answer
778 views

Why do I have to create an AS3 package using Flash?

I know what "works" If I create a new file in explorer named test.as and I create my packaged class, I haven't found a single way to have my flash file find and use it. I've tried using relative and ...
1
vote
3answers
2k views

AS3 Importing a class to main timeline

Hello I have a air for android project going and I am wanting to import a actionscript class for use in the main timeline. I wrote the class and imported it, but I get the following errors: Line 1 ...
1
vote
2answers
805 views

ActionScript - Passing & Instantiating Class Reference Containing Required Parameters?

I'm unsuccessfully attempting to instantiate a reference of a class that is passed as a parameter to another class. in this example there are 3 classes: MainClass, Canvas, MyCircle from the ...