February 2006
Monthly Archive
Mon 27 Feb 2006
Posted by johannes.nel under
worflowNo Comments
At work there has been a major drive towards better code, better processes and a more mature way to develop flex applications which led us to unit test with much more urgency (using ASUnit). We don't Flex Builder for Flex 1.5 (check out this tut by Darron Schall for setting up eclipse for flex)
always preferring the FDT and Oxygen. Now if you used the ASUnit create class command for the Flash IDE you would know that creating a class and its testcase was fairly simple. You pop the classname in and voila the class is created. the testcase is created and the allTests file is altered. This kind of functionality is nice, but we wanted to use it in Eclipse as well. Last year when we started down this line I contacted the great folks over at Powerflasher (the creators of FDT)and asked them if their Class Creation Wizard could link to an ANT script which it would execute directly after the class was created. Nico Zimmermann obliged (Thanks!).
I then went and wrote a python script which created testcases for all the files in a source folder, and altered the AllTest file for each of the flders beneath that as well. A problem I Immediatly ran into was my source control system (SVN) created .svn folders which i then recursed through so I just put a check in for any folders that follow the SVN naming conventions. Another issue we were facing after this was that we used external libraries like XPATH from xfactorstudio and we did not want to create unit test for these as well so Peter suggested using RegEx to filter out certain packages. Having never learnt how to use RegEx properly i come from the Alias school of RegEx ( A man had a problem, he decides to use RegEx to solve it, now he has two problems), so i just told Peter you do it, which he promptly did.
On how wo use this:
extract the .tar file into the root of your project. you have two files to worry about at this point, the classCreated.xml ANT script and the clientBuild.properties which that uses.
in clientBuild.properties which looks like this
CODE:
-
src.path = ${basedir}/src
-
test.templates=${basedir}/python/templates
-
test.include = .
-
test.exclude = ^com\\.xfactorstudio
-
lib.dir=${basedir}/lib
-
base.package = com
-
pyAntTasks.jar=${lib.dir}/pyAntTasks.jar
you need to worry about the src.path variable. i keep my source in a folder called src, if its in the root of your project set it equal to ${basedir}
then you haev test.include and text.exclude which takes takes a regular expression on what to include. as you can see at the moment we are including everything whilst excluding anything in the com.xfactorstudio package.
the last variable to set is the base package. if you keep your code in a package called com it will work, if however your code is in a package called org you need to change that value to org.
you also need python set up as an enviroment variable. (in bash or your command prompt you ahve to be able to type python and it will start and show you >>>), i used python 2.4.1 and have not tested it on anything else yet, but i don't expect any problems.
current limitations:
this does not deal with multiple top level packages yet
if a class has the word interface in it a testcase does not get created for it.
this has been tested on both pc and mac.
http://xperiments.lennel.org/createTestCases.tar
i have also uploaded the templates for AS3.
http://xperiments.lennel.org/AS3templates.tar
the mxml testing stuff is pretty imature, that is a work in progress for us
Sun 26 Feb 2006
Posted by johannes.nel under
as1 Comment
based on this article by werner sharp from the adobe engineering team i tried creating a typed array storing 16bit uint's in strings (the 16 bit limit coming from utf-16). the getITemAt turned out to be quite a bit slower than i expected and peter then suggested using bytearray to do this as well.
the experiment is posted here, the code is availible via the context menu.
using any tool to monitor your flashlog you will see the results. included you will find some unit test using asunit
the results:
Array test
added 10000 items 1
retrived 10000 items 1
altered 10000 items 0
byte array test
added 10000 items 2
retrived 10000 items 2
altered 10000 items 2
string array test
added 10000 items 8
retrived 10000 items 3
altered 10000 items 4005
wow, arrays in AS3 are just super fast!
Sun 26 Feb 2006
Posted by johannes.nel under
jsflNo Comments
execute function comes from http://blog.fuelindustries.com/archives/cat_jsfl.html
the trace function is just a rework of theirs to use esacpe and unescape.
Actionscript:
-
public static function executeJSFL()
-
{
-
var file = arguments.shift();
-
var func = arguments.shift();
-
var result;
-
if( arguments.length> 0 )
-
{
-
var arg = arguments.join( "\',\'" );
-
result = MMExecute(((((("fl.runScript(fl.configURI+\'WindowSWF/" + file) + "\',\'") + func) + "\',\'") + arg) + "\');");
-
}
-
else
-
{
-
result = MMExecute(((("fl.runScript(fl.configURI+\'WindowSWF/"+ file) + "\',\'") + func) + "\');");
-
}
-
-
return( result );
-
}
-
-
public static function flTrace(str){
-
-
MMExecute("fl.trace(unescape(\""+ escape(str)+"\"));");
-
-
}
Sun 26 Feb 2006
Posted by johannes.nel under
jsflNo Comments
type: command
location: commands-->classBuilder
usage:
open a symbol in the ide. dbl-click the jsfl file.
a class shell like this :
Actionscript:
-
import ucles.visual.RadioButton
-
-
import mx.controls.MediaController
-
-
import mx.containers.Accordion
-
-
class myName extends MovieClip
-
{
-
-
private var prompt:TextField
-
-
private var questionNumber:TextField
-
-
private var optionAtxt:TextField
-
-
private var optionBtxt:TextField
-
-
private var optionA:RadioButton
-
-
private var optionB:RadioButton
-
-
private var iMedia:MediaController
-
-
private var accTest:Accordion
-
}
will be generated in the output window, with all the necesary includes and variable declarations. all elements with an instance name will be included, if no instanceName is assigned the element will be ignored.
loads of improvements can be made int he jsfl i am certain.
the extension is availible @
http://www.lennel.org/commands/classBuilder.zip
errata:
currently buttons are declared as MC's. their interfaces are so similiar that i saw no need for otherwise.
compiled clips it searches the import library by walking through the fl.configURI+"Classes/mx/" folder recusively, thus if two similiar class names exists but with different namespaces both will be imported.
Sun 26 Feb 2006
Posted by johannes.nel under
jsfl1 Comment
need to poll from a windowsSWF what object(s) on the stage is selected at
any given point so I can extract the actionscript from it. Thus using
setInterval I call a function to do that in a jsfl file.
Obviously I need to c how many objects are selected at any given point so I use the following lines of codevar doc = fl.getDocumentDOM(); if(doc.selection.length==1)
all straight fwd there,
the side effect is this, when accessing an the selection array I seem to be
losing the values of any properties being set in the properties pane for
symbols (x,y,width,height and instance name).
to reproduce
1. create an fla
2. on the firstframe place this code:
Actionscript:
-
this.onEnterFrame = function(){
-
-
MMExecute("fl.getDocumentDOM().selection");
-
-
}
3. publish to the windowsSWF folder.
4. open ur new pane
5. create a symbol on the stage and try to change any of those
abovementioned properties, whilst the panel is open.
This problem has not been sorted in 7.2.