Using fl.controls.* with FDT (and Flash CS3)
I Recently upgraded to FDT 3.0 Professional...I highly recommend if you're doing heavy actionscript projects. It's pricey, but will pay for itself quickly.
Using fl.controls with the syntax checking took a bit of research. Turns out you have to follow the steps as
- Create a new FLA, name it CS3Controls
- drag all the components you need into the Library
- In File> Publish Settings > Flash > checkmark "Export SWC"
- publish it
- copy the CS3Controls.swc to someplace you'll remember (e.g. a common classpath or whatever app that uses them's lib folder)
- - Now in FDT, add your SWC to your project, and in the Flash Explorer panel, right-click and add that SWC file to your classpath
- once that swc is visible in the FDT Flash Explorer, right click over it. "Source Folder">"Add to Classpath"
- after a moment you will see it above the packages, if successful, clicking the plus will show you all the classes inside it...very cool FDT team!
- in your AS class just proceed as normal eg.: <code> import fl.controls.*</code>
Found this post
AS3: Function.apply
When using method closures, it sometimes it helps to have some default arguments, and later some optional arguments to pass. This example will look at passing additional params when using Elastic tweens.
Using Function.apply it's pretty easy to concat the arguments into one argument list. Though it should be noted that it's significantly slower than just passing them, which is appropriate if the number of arguments is of a known quantity.
-
-
////// parameters for our tween, some of these will change over time //////
-
var t:String = 0; //current time
-
var b:String = 0; //begin val
-
var c:String = 1; //change val
-
var d:String = 1; //duration
-
-
var _fA:Array = [1, 2]; //parameters for elastic tweening
-
-
function _f(a:Object, b:Object, c:Object, d:Object, e:Object = null, f:Object = null, g:Object = null ):Object {
-
trace("a:" + a + " b:" + b + " c:" + c + " d:" + d + " e:" + e + " f:" + f + " g:" + g);
-
return a + b + c;
-
}
-
-
//note that the first value is null, as when using a method closure,
-
//the scope the function is being evaluated in is fixed to that of the class.
-
-
var calc = _f.apply(null,[t,b,c,d].concat(_fA));
-
-
trace("result " + calc);
A faster way is to avoid array manipulations, and just route based on the number of arguments. e.g. arg1, arg2 are
-
-
var calc
-
if(numOfArgs==4){
-
calc = _f.apply(null,[t,b,c,d]);
-
} else if (numOfArgs == 6){
-
calc = _f.apply(null,[t,b,c,d,arg1,arg2]) ;
-
} else if (numOfArgs == 8){
-
calc = _f.apply(null,[t,b,c,d,arg1,arg2,arg3,arg4]) ;
-
}
//a:t b:b c:c d:d e:1 f:2 g:null
//result tbc
