The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.38 / 5.00 36,385 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.07 / 5.00 13,902 ViewsOk, this is a sort of advanced topic and I'm not even sure it can be done.
What I'm loosely doing is a testing program in flash, sort of like JUnit. The idea is that the user specifies a class name (ie. 'flash.display.Sprite') that extends my 'TestBase' class. This is tested by using assert type functions specified in 'TestBase'. The problem is that I need to import the class to be tested dynamically, and I don't know how to do it. Erhm...
Ideas?
flash.utils.getDefinitionByName
Import isn't the right word. The keyword doesn't even cause inclusion of the class in AS.
Weell,
I'm using getDefinitionByName() right now and it works fine for loading for example flash.display.Sprite, but it won't work on my own classes unless they are in the compilation root folder. That is unless I import them manually at compile time. Which I could do, but would rather not since I would have to make separate testing files for ever project.
Could you load .as files with a Loader and parse them in some way?
Right, but you do want to compile them, right? Then you have to include them.
You can have an includes class, an empty one that just imports and lists the classes in its body,
Blerk, seems like making an itsy testing tool in flash aint gonna work very smoothly.
Lol, I've been coding in python all summer - these kind of thing work out really nice in python. Although it's a hopeless language in many other ways.
I am not sure whether this will help or not, but you could take a look at FlexUnit and see if/how they implement what you want.
flash.utils.getQualifiedClassName
I have a feeling this is the sort of thing that you're looking for, but I'm really not sure. No harm in trying it :)
This sounds like a standard preloading issue in an unusual shape. You got classes and you want them loaded, but you have no author time instances of them. Set them to export by force, problem solved.
Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.
At 9/14/09 04:04 PM, Tree-SkyLark-BCE wrote: http://opensource.adobe.com/wiki/display /flexunit/FlexUnit
Lol, FlexUnit actually seems to provide exactly what I need. Have to check it out when I get home but it should contain all solutions.
At 9/15/09 03:05 AM, henke37 wrote: This sounds like a standard preloading issue in an unusual shape. You got classes and you want them loaded, but you have no author time instances of them. Set them to export by force, problem solved.
I'm not sure what you mean... I know how to export classes without having instances, but don't want to export stuff - that's clumsy. The point is to get something JUnit-like that can be used for all my projects. Therefore I don't want to recompile the program for every project.
Ideal use case:
- run program
- specify .as file
If specified class extends TestBase: runs tests and display results. Repeat.
- be happy
At 9/15/09 03:26 AM, Fickludd wrote: Ideal use case:
Personally, I usually just opt for skipping to the last step. :)
Don't forget, in the publish settings you can set alternate source paths for as files, so the files you want to use shouldn't be limited to the same folder as the FLA.
Actionscript can not be run without being compiled into bytecode PERIOD.
Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.