Get list of Class names in package - actionscript-3

Is there any way I can get a list of all the classes in a particular package?
I know getDefinitionByName, getQualifiedClassName, and getQualifiedSuperclassName in flash.utils can find me a class, but I can't find anyway to find all the classes in a package at runtime.

No, ActionScript reflection is limited to the three functions you mentioned and flash.utils.describeType(object:*).

Related

Emulate C++ namespace in Excel macro

C++ allows to conveniently organize the code with namespaces.
Some Excel functions -like for instance NORM.DIST- seem to follow the same logic. Is there a way to emulate a namespace from a worksheet?
Thank you!
NB: I came across an article (http://bytecomb.com/organizing-code-with-namespaces-in-vba/) explaining how to achieve this from a module, but not from a worksheet. Basically, it creates a class (eg MyNamespaceClass) and then defines one global variable (myNameSpace).
Eventually, I dropped my attempt to emulate namespaces with their convenient dot notation (eg namespace.functionName) and simply named all my public functions with the the same prefix (eg prefix_functionName).

Concept of Namespace in Dotnet? [duplicate]

This question already has answers here:
C# namespace alias - what's the point?
(11 answers)
Use of Namespaces in C#
(6 answers)
Closed 8 years ago.
I searched many articles to understand the concept of namespace? But I could not understand.
Can anyone explain the concept of namespace with simple example? Why do we import namespace?
The following is pseudo-code, I hope it's clear
namespace1.SomeClass
namespace2.SomeClass
var x = new SomeClass(); //which class are we trying to instantiate?
var y = new namespace1.SomeClass(); //now compiler and everyone else knows
A namespace is used to organize objects in categories and control the scope of objects.
More details about .NET namespaces on : http://msdn.microsoft.com/en-us/library/0d941h9d
Notice that the namespace concept is not limited to .NET but to many programming languages.
Why Namespace?
Namespaces are used to organize code. It lets you organize code and gives you a way to create globally unique types and avoid name collisions.
e.g.
Suppose, you have created a class Foo in your code. In same project, you are using some third party library, in which also a class with same name exists. In this case, when you are referring class Foo, compiler won't be able to resolve it.
But, this problem can be solved by namespaces. The Foo class in the library you are using, belongs to some namespace specified by developer of it. (Usually, it contains company name or something unique identifier). And your Foo class belongs to namespace you have specified. So, at the time of using it, you can specify fully qualified name of the class like <Namespace>.Foo. Which will make it easy for compiler to resolve reference.
Also, you yourself can categorize your classes using namespace to bifurcate it according to their purpose. Which will be easier to maintain. (e.g. CoreFramework.Foo, UIHelper.Bar, etc...)
Why do we import namespace?
Now, at the time using class you have categorized by namespace. You will have to tell compiler in which namespace the referring class contains. By default, compiler looks for the classes in same namespace. If the class you are referring belongs to another namespace, either you will have to specify fully qualified name of the class (i.e. Namespace.Foo) or you can inform compiler at the beginning of the class by using import statement that, code withing the class contains references to the classes belonging to this namespace.

Restricted access of function in Haxe?

I started playing around with Haxe recently, after using AS3 for quite some time and ran into a problem while writing a very simple game engine:
I have a class called World. One of the things the World does, is keeping track of all Entity objects in the game. I want this list of Entity objects to be accessible ONLY from within the engine. The user of the engine should not be able to modify the list directly.
In AS3, I could simply use the internal keyword to give access to other classes within the same package. And when that wasn't enough I could define a custom namespace and use it as my access modifier. But Haxe doesn't seem to have either of those.
TL;DR: How can I restrict access of a variable to a specific package/namespace? If not possible, what other options do I have?
If you're using Haxe 2.11 (nightly build), you can use #:allow.
Copied from the Haxe.org wiki:
#:allow(my.pack) : This will give access to all private fields of a
class to all the classes in the package my.pack (and its
sub-packages). See Access Control for more info. (since 2.11)
More detailed doc on Access Control.

Package name for a loop class

I wrote a class that performs an asynchronous loop. It needs a package name. I already have a util package, but feel resistant to put half of my classes in that package. If it really belongs there, I'll put it there, but I'd feel much better if I can find a more appropriate/specific package. What do you think?
peach for parallel each.
Shamelessly stolen from the Ruby project with the same name.
A package is normally created for more than one class. If your class uses some helper classes, then it should go in a separate package; differently, you should use the generic package you already have.
I ended up going with "timer" as the package name after finding many similarities with the Timer class that sits in the timer package.

Actionscript 3.0: Scope

Tutorials usually don't deal with scope in Actionscript. Can you point me to some documentation and/or explain what should I know about it. I want to avoid problems arising from certain classes are not visible at certain places.
These should help.
Function scope:
http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_21.html
Packaging and namespace:
http://livedocs.adobe.com/flex/3/html/03_Language_and_Syntax_04.html#119303
You're a bit vague, but hopefully I'm getting you ;)
Scope for classes are generally pretty easy to handle, it mostly comes down to packages.
Packages are created in a simple tree structure, and in ActionScript3 the filestructre has to follow the namespaces. Which makes it even easier.
You can access any class from anywhere, but if it's in another package you will need to "import" the class. This is done by writing an import statement in the beginning of class or interface where you need to use it. Like so:
import flash.display.MovieClip;
There is an exception to this rule, a class can be declared with the internal keyword, in which case the class will only be available within that package. This is mostly used for helper classes.
Basicly you should not worry about classes not being available.
NB:
You create package with the package keyword.