I'm fairly new to action and flash things. I'm trying to
create some
actionscript dynamically, store it into a .swf, and later be
able to
extract the values of some of the variables after lading the
.swf.
To test, I created a .swf using MacroMedia; it contained
only the
following actionscript:
this.something = "foo";
stop();
and later loaded the clip and extracted the value of
"something" like this:
_root.createEmptyMovieClip("img_mc", 999);
var my_mcl:MovieClipLoader = new MovieClipLoader();
// Create listener object:
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip,
status:Number):Void {
trace("parm/onLoadInit: " +
target_mc.something);
};
my_mcl.addListener(mclListener);
my_mcl.loadClip("new.swf", _root.img_mc);
Now I'm trying to use mtasc, to generate and compile this on
the fly
instead of thru the IDE. Apparently I have to define the
actionscript
through classes for mtasc, as my earlier example did not
compile in
mtasc.
I found this on the mtasc site; added a
"something" like I had before.....
class Tuto {
static var app : Tuto;
static var something : String;
function Tuto() {
// creates a 'tf' TextField size 800x600 at pos 0,0
_root.createTextField("tf",0,0,0,800,600);
// write some text into it
_root.tf.text = "Hello world !";
}
// entry point
static function main(mc) {
app = new Tuto();
something = "a string I'd like to read";
}
}
Anyway, I was able to create the .swf and load it exactly as
before,
but I'm not sure if I'm defining "something"
wrong, or accessing it
incorrectly in my onLoadInit() - probably both. Any
suggestions to get
this to work appreciated!
km
--
MTASC : no more coffee break while compiling
|