as3: meaningful object identification while debugging - actionscript-3

I wanted to ask if there is a possibility to identify objects in more meaningful way during the debug. e.g. now in flex builder debug panel I see for example:
Object(#12131241241)
And ideally I wanted to have Object(#"field1:field2")... is there a way to do it. I believe in java it can be achieved by overriding toString method of the given class.... Tried same in as3 but it did not work

Not answering your question directly here but there are many community debuggers around that give you more meaningful data. The IDE's Intellij Idea or Flash Develop and there are a few other projects such as http://demonsterdebugger.com/ or http://code.google.com/p/flash-console/ which give you an insane toolset for debugging.

Related

flexUnit pure AS3 IntelliJ

Is it possible to have FlexUnit 4.1 in IntelliJ with project set up as Pure AS3 which meens no Flex Runner.
What I get is an error
Error #1065: Variable mx.core::FlexVersion is not defined.
ReferenceError: Error #1065: Variable mx.core::FlexVersion is not defined.
But if I uncheck the Pure AS3 from module setting everything works.
The reason why I check pure AS3 is that I dont get Flex completion, and possible there are reasons that I still dont know.
I assume your inspiration is running it on a continuous integration system like Hudson, Bamboo, or TeamCity.
You need a windowing environment, but there are some workarounds to provide one.
Look at this FlexUnit Wiki:
http://docs.flexunit.org/index.php?title=Continuous_Integration_Support
Makes sense. There are quite a few flex libs that get left out if you go with the pure actionscript option.
You pretty much miss out on anything you might have wanted from spark and a number of the classes that leverage mxml approaches to the visual side.
By now I'm guessing you have already researched and found the classes you were missing and wrapped the code to not use them, but perhaps someone else clawing out their eyes will appreciate knowing there is a fairly big difference in what IntelliJ excludes when you toggle to "pure actionscript".
Of course the AS3 documentation won't really cover that AFAIK because the intent is that you will use both mxml and AS.
I ran into the same problem in a pure AS3 environment. Adding:
-define+=CONFIG::useFlexClasses,false
in the module's compiler options and commenting out flex classes that might be imported worked for me.
There might be a thrown error for mx.core.FlexVersion and so I just commented those lines out.

Migrating from AS2 to AS3

I would like to know from someone who have already done that, any recommendations and things I have to take a special look, I have seen some articles related to the topic, googled it, etc...
but I would like the advice from stackoverflower x)
I already know object oriented programming in c++, using classes and etc, but I can't quite understand AS3 packages and stuff, but i'm very familiarized with AS2.
Thanks
Drop everything you know, start fresh. AS2 is different than AS3. Don't try to do the AS2 thing with AS3.
Read & Learn the Adobe LiveDocs
Learn how the display list works.
Learn AS3 coding standards, write clean readable code
Learn how to use common actionscript libraries, TweenLite, Gaia framework, RobotLegs, Temple Library, Pure MVC, Away3D, as3corelib etc.
Never ever code inside the Flash IDE actionspanel, there are really nice actionscript editors like FlashDevelop, FDT, FlashBuilder, IntelliJ.
My experience migrating from AS2 to AS3 has been pretty smooth, so smooth that I would never go back and squirm at the thought of maintaining old AS2 code.
Firstly I would get familiar with the display list, here is a good article.
Then I would gain an understanding of the new types in AS3, especially the difference between Number, int and uint as you don't need to lump everything in Number anymore.
Do some reading up on the event system and how you can capture events that have bubbled up from other objects, and how you can use capture and stop them propagating further, and how to avoid unnecessary clicks on nested objects in buttons you create.
Like you say you already know OOP, so I would then suggest limiting timeline code as much as possible, write everything in classes.
XML is handled using e4x which makes xml parsing trivial, you will find this a breeze to work with compared to AS2.
The drawing api is now contained in a graphics library accessible through many display objects.
Get to know a good framework, I highly recommend pure MVC AS3
Finally for animation - there can be only one library - Greensock TweenMax AS3 of course ; )
EDIT :
I have looked around for some resources that I think will be of interest to you, I based these choices on my experiences and what I believe are key areas of research:
Presentation on AS3 by Grant Skinner - Excellent overview that you can refer to time and time again.
Getting Started with ActionScript 3.0 - Comprehensive approach to using AS3 with Flash CS3.
Senoculars tips of the day - because you already code in AS2 you should understand a lot of these tips and how they differ in AS3.

Runtime Class creation in actionscript-why and for what purpose?

Hi
Recently in actionscript it has been made possible to create Classes at runtime. Thi seems quite cool, but I am perplexed thinking of a situation in which this might be useful. Anyone have any ideas?
First of all, the uses for this in ActionScript is limited. So start of understanding what it actually is, and how other languages use it.
See Self-modifying code on wiki:
http://en.m.wikipedia.org/wiki/Self-modifying_code
Also see Reflection:
http://en.m.wikipedia.org/wiki/Reflection_(computer_science)
As an example of how it might be useful, I'm currently working with genetic algorithms to modify code at runtime. This way I can test every permutation (varying initial values and methods) without having to create classes for them, with the added bonus of exporting a .swf only containing the winning permutation.

Why doesn't ActionScript have "generics"?

Can anyone tell me why ActionScript 3, a statically typed language, doesn't have generics? Is it too much work? A historical thing? Is there some way to "fake" it that I haven't picked up yet?
Edit: thanks a lot for the answers! The Vector class is basically what I was looking for, and the other information was helpful too.
The new Vector class is a form of generics that Actionscript 3 now supports when compiled for Flash Player 10. They don't support the specification of your own generic classes, yet.
I think Adobe will implement the ES4 standard eventually. It would be nice if they had a competitor who could push them quicker in the right direction. I was expecting a little more from the updates to AS3 when they moved to CS4, but I suppose the revolutionary Vector class will have to suffice.
It looks like they spent a lot of time beefing up the libraries for Flex and AIR, so maybe they'll go back to improving the language support later, but it probably isn't a real priority. Remember, Adobe is in it for the money, not for the feel good of making the sweetest possible language.
I believe it's a historical thing. ActionScript is based on ECMAScript (JavaScript is also based on ECMAScript). ECMAScript is a dynamically typed language, meaning that variables don't have their type declared. Generics are more useful in statically typed languages, wherein the type of variable is declared upfront. In a statically typed language, without generics you're stuck casting all the time from the root object (for example, Object in Java). This is not a problem in ECMAScript, because you can put anything you want into any data structure.
So why didn't ActionScript add generics when they added static typing to ECMAScript? I can't be sure of that, but I think the premise of your question is a bit off - there are generic-esque containers, such as Vector. I might think they'd keep the dynamically-typed containers of ECMAScript (objects and arrays) for backwards-compatibility, but they already broke that between AS2 and AS3, so I'm not sure.
Parameteric types ( the word 'generics' is usually used in ECMAScript for generic methods, rather than the combination of parametric types and runtime polymorphism used in Java ) were proposed as part of ES4, but ES4 fractured and much of the type system proposed for ES ( including the parts implemented in ActionScript ) are not going into the next version. I can't say whether or not Adobe would want to go that way by themselves.
Let's first get proper containers and algorithms in actionscript and then worry about generics...
as3 is not very different from javascript, btw, so your question would kind of apply to JS as well.

.NET Exception Explorer

Does anyone know of a program or plug-in or anything that I can find out what are all the exceptions any method may throw?
I think JAVA has this build in if I'm not mistaken. Where the compiler tells you what exceptions this method will throw.
Does the same exist for .NET?
Thanks
Edit: After searching around more, I wish there was tool like Object Explorer, except for Exceptions. You select the class or method and it lists the exceptions, at that level, which are thrown by the class. The tool links provided are a great start. Thanks!
I don't know if this is exactly what you are looking for, but:
http://www.red-gate.com/Products/Exception_Hunter/index.htm
Note: I've never used the product, and I don't work for Red Gate, I just remember seeing it advertised before.
You can see this information with intellisense in Visual Studio. When you highlight a method name in the intellisense list, its description should contain a list of exceptions at the bottom. This information is added by properly commenting your methods and classes. If you are using a library that is not part of the framework, then you will only get this information if the developers of the library appropriately commented their code.
.NET doesn't require or permit each method to state which exceptions it throws. As I recall, it was felt that this would lead most developers to simply state "throws Exception".