Actionscript : 1087: Syntax error: extra characters found after end of program - actionscript-3

I tried importing a .as referring to my variable name/value
import "net.chars."+adc;

You can't dynamically import a path via a string, because AS3 imports occur as compile-time. They're simply directives to tell the compiler what classes/packages you're using, nothing more.
You might be able to use the getDefinitionByName function if you really need this functionality, as described in this answer. However, you should note that you still have to reference the class somewhere in your code, otherwise it won't get compiled into the SWF. Flash has no way of loading classes externally at runtime, so you have to ensure that the compiler knows to include it.
For more information, see this article.

Related

how to tell the run-time loader not to run the constructor function when dlopen a shared library

From the manual of dlopen, I see
" Instead, libraries should export routines using the attribute((constructor)) and attribute((destructor)) function attributes.
See the gcc info pages for information on these. Constructor routines are executed before dlopen() returns, and destructor routines are
executed before dlclose() returns.
"
I do not want the constructor in a specific shared library to run automatically, while the ones in other shared libraries are not affected. Is there any way to achieve that?
Actually, I'm using dlopen, dlsym, dladdr to find the exact path of some shared library.
I do not want the constructor in a specific shared library to run automatically
Too bad: the library author decided that his library can't be used safely unless the constructors are run, and he has more say than you do.
Actually, I'm using dlopen, dlsym, dladdr to find the exact path of some shared library.
Are you saying that the only reason you dlopen that library is just so that you can find the absolute path to it?
If so, why do you care about the absolute path in the first place?

What does "Packages cannot be nested" in AS3 mean?

I got the complie error "Packages cannot be nested". What does it mean, and how do I fix it?
While you can have more than one Class, you should only have a single Package in each of your .as files. Check your .as files to see if you have more than one instance of Package.
Update based on OP's comments:
You cannot use Packages or Classes on the timeline. You need to place that code in an external file and link to it either by making it your Document Class or by assigning it to a symbol in your library via the Class property in the properties panel.

Failed to create shared library with wx and STL, "multiple definition" error?

I tried to build a shared library using wx and STL, and failed in an error of "multiple definition of". Please refer to:
https://code.google.com/p/gppanel/issues/detail?id=7
The declaration of wxPointListNode is not found in the sources. The suspicious lines are like these:
include/mathplot.h:85:WX_DECLARE_LIST(wxPoint, PointList);
include/mathplot.h:87:WX_DEFINE_LIST(PointList);
include/gpLineLayer.h:16:typedef std::deque<mpPointLayer*> mpPointList_t;
What the problem is?
Without the actual code this is just a guess, but I suspect that
include/mathplot.h:87:WX_DEFINE_LIST(PointList);
generates the full definition of PointList, including a non-templated method wxPointListNode::DeleteData. mathplot.h is included by all of the .cpp files (gpPanel.cpp, gpSeries.cpp, and baseData.cpp). Each cpp file is compiled into a .o file, so each has its own definition of DeleteData, and when you try to link the .o files together into lib/libgpPanel.so the linker issues the errors you're reporting.
The definition of the method needs to be in its own cpp file that's compiled and linked in.
All wxWidgets methods with DEFINE in their name expand into a definition of something and a definition can only be used once in a module, so it typically can't appear in a header file (unless you can guarantee that it's included by only a single source file). So just don't put it there.
Moreover, if this is your code, you should avoid using the legacy WX_DECLARE_LIST macro at all and just use std::list<> or std::vector<> instead. Or, if you really want to use only wx (which can only be important if you are targeting some embedded platform without good STL implementation), then use wxVector<>.

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 allready initialized! Is there a way? Or I have to initialize every class I want to use?! That would be soooo stupid of Adobe!
getDefinitionByName() will work with any class name, linked to library or not. Your problem is likely that since you're not mentioning the class name in the code, it's not in your swf at all. You will have to make sure the class is used at atleast one place in your code, if not it will not be compiled in.
This can be as simple as just putting them on a line in your Main-class:
public class Main {
public function Main(){
ClassYouWant;
AnotherClass;
codeThatDoesStuff();
}
}
The short answer:
If you want to avoid including class references (as suggested by #grapefrukt) you'll have to compile those classes in a library and reference that from your main application as an RSL (Runtime Shared Library)
The long answer:
There is no other way to create a Class by its name than to use getDefinitionByName().
However there are several ways to compile your code. By default, if you have a single application that doesn't include libraries, it will not compile classes that are not referenced in your code. You call this stupid, but there's a pretty good reason for that: it reduces the size of your swf and so the download time of your application.
If you use libraries there are three ways they can be referenced from your main application:
merged into code
runtime shared library (RSL)
external
The first option will take all (and only) the classes from the library that were referenced in the main application. This results in a smaller swf size.
The second option will compile the entire library into a separate swf, which is loaded by the main application. This results in a bigger file size, but the same swf can be used by several applications. And what's most important to you: all classes are in that swf, so they can be referenced by getDefinitionByName() without having to include the class in your main app.

reflect swf/swc for class that implements interface in actionscript

Not sure if this is possible but I would like to reflect a swf or swc file selected by the user at runtime to find any classes that implement a certain interface. Can this be done or do you actually need a reference to the class you want to reflect using describeType();
Note - this would be done in actionscript.
Thanks,
You can inspect a swf for the classnames (Source) and then use describeType on them to find the ones which implement the interface(s). But this is probably slow. You can try to extend the getDefinitionNames code to get around the describeType and extract the needed info from the bytes...