2005/10/31 | Actionscript 3 - First Steps X
类别(失落的学习) | 评论(2) | 阅读(44) | 发表于 09:30

This post is not about actionscript, but more about the publishing process. I couldn't find the dialog to specify the size of the resulting swf. It was my thinking, that i can specify the size in dialog similar to the flash publishing dialog, but to no avail.

After searching the docs for a while, i found the list of options for the mxmlc, the mxml compiler. The option -default-size width height looked good to me. And indeed, after specifying the option in the additional compiler arguments field, inside the project's/properties/Actionscript compiler dialog, the correct size is created now.
Great stuff. Some of the other options might come in handy too, but i haven't tried them yet.

Actionscript 3 - First Steps IX
The new integrated delegation probably needs some more attention than in Step VII. The next example shows, that this has nothing to do with the event system, which is part of the flash api, but is a feature of the language itself. We create a simple second class Test2, containing a method, that runs a function given as parameter.

package {

import flash.util.trace;
import flash.display.MovieClip;

public class Test
extends MovieClip
{

public function Test() {
var t2:Test2 = new Test2();

// use a member method as parameter
t2.run( onCompleteT2);

//use a anonymous function as parameter
var ref:Test = this;
t2.run( function(){
trace("Test::anonymous function " + this + ":" + ref);
});
}

public function onCompleteT2(){
trace("Test::onCompleteT2 " + this);
}


}

private class Test2
{

public function run( onComplete:Function){
trace("Test2::run");
onComplete();
}

}
}


As you can see from the second trace, the scope of onCompleteT2 is implicitely set to the instance of Test. No longer we need to use Delegate.create or local variables to provide a reference to the scope. Still this method works though, as you can see from the last trace.
Also note, that anonymous functions are no longer automatically scoped to _root but to global, as you can see from the last trace too

0

评论Comments