Jester, that's actually in the documentation, that's not a bug. I don't
remember where I read it, but I found it somewhere when I was looking into
scope. You can search around in here:
http://livedocs.macromedia.com/flash/8/main/00001200.html if you're
interested.

As to your original question, the answer depends on whether or not "myVar"
is already defined in clip1. If it is, then as others have said, you can't
declare something twice. You didn't mention in your question as to whether
or not you're trying to declare it in two places. It's my opinion that
declaring a variable in a different scope using strong typing is illegal
because AS enforces you to be consistent with the "spirit of the code". I'll
explain.

The following is an illegal declaration:

// llegal syntax error: Identifier expected
this.clip1.myVar:Number;

This is pretty similar to your statement, except that I cut out the
assignment, as it only clouds the issue. Before ActionScript introduced
strong typing, you could define variables in any scope at any time. While
this offers a greater range of possibilities, it also introduces a lot more
danger, and as such is appropriate for small-time scripting, not larger
software projects. Strong typing is useful because it helps keep you out of
danger- it makes sure that variables can not change type implicitly. It's
usually not appropriate for small scripting projects, as you're usually
dealing with tasks small enough that you never run into type-related issues.

AS2 supports the programmer working on a large project by offering strong
typing, and the scripter/designer who isn't doing much with AS by offering
dynamic variable declaration. AS2 however (at least in this case) does not
really support both at the same time. It makes sense that, if you're using
strong typing, you're working on a project where you don't want to support
shortcuts like dynamic declaration. If you want strong typing, then you
shouldn't be declaring myVar outside the scope of clip1; if you want dynamic
declaration, then why are you wasting time with strong typing?

I hope that made sense.
Liam


On 10/31/05, JesterXL <[EMAIL PROTECTED]> wrote:
>
> Finally, there is a bug in Flash MX 2004 & 8; you can't datatype like
> this:
>
> myVar:Number = 42;
>
> but you can do this:
>
> var myVar:Number = 42;
>
> ----- Original Message -----
> From: "Chris Velevitch" <[EMAIL PROTECTED]>
> To: "Flashcoders mailing list" <[email protected]>
> Sent: Monday, October 31, 2005 12:30 AM
> Subject: Re: [Flashcoders] Strict Datatyping Question
>
>
> On 10/31/05, Joseph Balderson <[EMAIL PROTECTED]> wrote:
> > Why it is illegal to combine both a path declaration and a datatype
> > declaration
> > in the same expression" i.e.:
> ...
> > // illegal syntax error
> > this.clip1.myVar:Number = 42;
>
> This illegal because myVar has already be declared in the definition
> of the type of clip1.
>
> Also, you have used the phase 'path declaration'. This is an oxymoron.
> Declarations only appear in a class definition, paths are references
> to the objects/types of interest.
>
>
> Chris
> --
> Chris Velevitch
> Manager - Sydney Flash Platform Developers Group
> www.flashdev.org.au <http://www.flashdev.org.au>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to