flash actionscript:
Park2,
[quoted text, click to view] > I am from a delphi background. In delphi I either
> declare a variable as public (the variable is available
> throughout the project) or private (the variable is
> used within a function).
Scope is a bit different in Flash. ActionScript features a special
_global object available to all timelines; that is, all movie clips,
including the main timeline (the main timeline is indeed a movie clip -- not
immediately obvious, but helpful to know). You may assign properties to the
_global object that are available everywhere.
e.g.
_global.myNum = 5;
_global.myStr = "Hello world";
Variables defined in a timeline are global to that timeline.
e.g.
// script in a frame of the main timeline
var myNum:Number = 5;
Note the ability to add strong typing to variables declared in this way
(above). Here, below, is another way to declare a varible in a timeline;
this time, by referencing a movie clip by its instance name. This is
functionally the same as entering the clip's timeline and using var there.
e.g.
myClip.myNum = 5;
Variables declared with the var statement inside functions are local to
that function (i.e., not available to any timeline).
e.g.
function myFunc() {
// scoped to this function only
var myNum:Number = 5;
}
[quoted text, click to view] > In flash what is the relationship throughout the
> project?
> _root
_root always points to the main timeline of the currently active
document. The default document is _level0, so unless you purposefully load
or create content in _level1, _level2, etc., _root points to _level0. If
your published SWF is loaded into another SWF, then any mention of _root
(even in the SWF loaded by the parent) refers the the *parent* SWF's main
timeline. In other words, there is only one _root, and it's always the
bottommost (or topmost, whichever you prefer) timeline.
[quoted text, click to view] > _level10
See above. And see this article ...
http://www.quip.net/blog/2006/flash/actionscript-20/is-root-evil [quoted text, click to view] > this
The global property "this" always refers to the timeline or object to
which it is scoped.
[quoted text, click to view] > etc etc......
Heh, I'll need more detail in order to answer that one. ;)
[quoted text, click to view] > Also how do I show all the code from a project within
> one window.
The Actions panel gives you access to all scripts in a vertical
treeview. One of the banes of FLA files, especially older ones, is the
likelihood that ActionScript will be scattered helterskelter. Current best
practices recommend that code be placed in a layer dedicated just for
scripts, and, in fact, in as few frames as possible.
David
stiller (at) quip (dot) net
Dev essays:
http://www.quip.net/blog/ "Luck is the residue of good design."