all groups > flash actionscript > april 2004 >
You're in the

flash actionscript

group:

strict data typing


strict data typing michael nieuwenhuizen
4/26/2004 11:10:34 PM
flash actionscript:
to test strict data typing and the scope of variables i
wrote a little script:

function F1 () { // some code }
function F2 () { trace (x); }
F1 ();
F2 ();

now, if replace "// some code", and run the movie i get:

x = 10; // output: 10
var x = 20; // output: undefined
_global.x = 30; // output: 30

this all makes sense. what if i wanna use strict data typing?
i tried:

x:Number = 10; // error message
var x:Number = 10; // output: undefined
var _global.x:Number = 10; // error message

the second one makes sense, as one defines a local variable.
how about the other ones? how can i use strict data typing
for global variables? is it simply not possible to define them
in a function?

mike

--
portfolio: http://www.acousticshock.com
recent flash experiments: http://www.michaeln.demon.nl/test



Re: strict data typing Jeckyl
4/27/2004 8:58:02 AM
[quoted text, click to view]

That is correct.

You an only use the ": Type" with a var (or in function headers)

[quoted text, click to view]

This is correct, you can only put a simple name after a var .. not a path
with a dot (ie cannot put __global. in front of variable name).

[quoted text, click to view]

You can't

Also, if you want strict typing for member variables (non local vars) then
use a class instead. Or define them in a onClipEvent(load) etc, where 'var'
does not mean local var (it only makes var's local in a function).

Re: strict data typing michael nieuwenhuizen
4/28/2004 9:28:22 PM

[quoted text, click to view]

*burst into tears*

mike

--
portfolio: http://www.acousticshock.com
recent flash experiments: http://www.michaeln.demon.nl/test

Re: strict data typing michael nieuwenhuizen
4/28/2004 10:17:26 PM

"Jeckyl" <jeckyl@hyde.com> wrote in
[quoted text, click to view]

so the _only_ way to use strict data typing for global variable is
to simply place lines like:

var txt:String = "Hello World!";

in the root? i usually put all the initializing statements in a
function like:

_root.onLoad = init;

function init ()
{
//...
}

such that if i wanna restart the movie i simply have to call the
init function. i don't see how i can do this with strict data typing.
a "bug" in AS2?

mike


--
portfolio: http://www.acousticshock.com
recent flash experiments: http://www.michaeln.demon.nl/test

AddThis Social Bookmark Button