Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Allandt Bik-Elliott (Receptacle)

should that be:?

var clip:* = e.target;
var buttons:Array = _menuButtons;
(e.target.buttonType == 1) ? buttons = _subMenuButtons : buttons =  
_menuButtons;




On 1 Jul 2008, at 00:03, Steven Sacks wrote:


Even better, 3 lines.

var clip:* = e.target;
var buttons:Array = _menuButtons;
if (e.target.buttonType == 1) buttons = _subMenuButtons;
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Steven Sacks
Why?  You already set buttons to _menuButtons.  Now you're going to set 
it again?


Besides, that ternary is not DRY because you are setting buttons = twice.

However, it can be compacted even more, and in 2 lines, instead of 3, by 
reusing clip and a ternary in the var declaration, like so:


var clip:* = e.target;
var buttons:Array = (clip.buttonType == 1) ? _subMenuButtons: _menuButtons;

:)



Allandt Bik-Elliott (Receptacle) wrote:

should that be:?

var clip:* = e.target;
var buttons:Array = _menuButtons;
(e.target.buttonType == 1) ? buttons = _subMenuButtons : buttons = 
_menuButtons;

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Allandt Bik-Elliott (Receptacle)

nice!

;)


On 1 Jul 2008, at 08:37, Steven Sacks wrote:

Why?  You already set buttons to _menuButtons.  Now you're going to  
set it again?


Besides, that ternary is not DRY because you are setting buttons =  
twice.


However, it can be compacted even more, and in 2 lines, instead of  
3, by reusing clip and a ternary in the var declaration, like so:


var clip:* = e.target;
var buttons:Array = (clip.buttonType == 1) ? _subMenuButtons:  
_menuButtons;


:)



Allandt Bik-Elliott (Receptacle) wrote:

should that be:?

var clip:* = e.target;
var buttons:Array = _menuButtons;
(e.target.buttonType == 1) ? buttons = _subMenuButtons : buttons =  
_menuButtons;

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Kerry Thompson
Steven Sacks:
 
 var clip:* = e.target;
 var buttons:Array = (clip.buttonType == 1) ? _subMenuButtons:
 _menuButtons;

Nice, Steve. 

One syntax question--the use of clip:*

Before I sent my original response to the post, I tried var clip = e.target.
Of course, it failed without the type *

I haven't run into that syntax before. What does the asterisk do for the var
type?

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Geografiek

It's a wildcard I think. clip can be of any type.
Willem

Op 1-jul-2008, om 12:10 heeft Kerry Thompson het volgende geschreven:


Steven Sacks:


var clip:* = e.target;
var buttons:Array = (clip.buttonType == 1) ? _subMenuButtons:
_menuButtons;


Nice, Steve.

One syntax question--the use of clip:*

Before I sent my original response to the post, I tried var clip =  
e.target.

Of course, it failed without the type *

I haven't run into that syntax before. What does the asterisk do  
for the var

type?

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders





=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31) 
30-2719512 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Kerry Thompson
Geografiek wrote:

 It's a wildcard I think. clip can be of any type.

That's what I suspected. What is the advantage, then, of using the wildcard,
rather than an untyped variable?

I don't mean to sound argumentative--I'm just trying to understand one of
ActionScript's nooks and crannies.

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Eamonn Faherty
I guess this is the same as using null instead of nothing in database
design.  You are explicitly saying that there were be a type at run time
instead of the compiler thinking you forgot it.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kerry
Thompson
Sent: 01 July 2008 11:42
To: 'Flash Coders List'
Subject: RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

Geografiek wrote:

 It's a wildcard I think. clip can be of any type.

That's what I suspected. What is the advantage, then, of using the
wildcard,
rather than an untyped variable?

I don't mean to sound argumentative--I'm just trying to understand one
of
ActionScript's nooks and crannies.

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Geografiek

Hi Kerry,
I understand you got an error not typing your variable in 'var clip =  
e.target;'

I tried 'var type = myType;', which gave no error.
Appearantly in some cases you _need_ to type a variable, in other  
cases you don't (!?)
In my case Flash automatically assigns String as the data type to  
'type'. (maybe only for primitive data types?)
Because in your case somehow you need to type the var, but don't know  
yet the actual type the * comes in handy.

my 2ct
Willem

Op 1-jul-2008, om 12:41 heeft Kerry Thompson het volgende geschreven:


Geografiek wrote:


It's a wildcard I think. clip can be of any type.


That's what I suspected. What is the advantage, then, of using the  
wildcard,

rather than an untyped variable?

I don't mean to sound argumentative--I'm just trying to understand  
one of

ActionScript's nooks and crannies.

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders





=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31) 
30-2719512 or cell phone: (+31)6-26372378

or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Merrill, Jason
That's what I suspected. What is the advantage, then, of 
using the wildcard, rather than an untyped variable?

Gotta think outside the IDE :) because in the Flex world for example,
depending on how you have the compiler set, it will complain if you
don't typecast a variable (even if you are only doing a wildcard cast).


Jason Merrill 
Bank of America 
Global Technology  Operations  Global Risk LLD 
eTools  Multimedia 

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Merrill, Jason
(even if you are 
only doing a wildcard cast).

What I meant was, not even if, but that casting to a wildcard will
alieviate the compiler complaints since  you're casting to SOMETHING,
even if it is a wildcard.

Jason Merrill 
Bank of America 
Global Technology  Operations  Global Risk LLD 
eTools  Multimedia 

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Merrill, Jason
Sent: Tuesday, July 01, 2008 10:58 AM
To: Flash Coders List
Subject: RE: [Flashcoders] Warning: 3596: Duplicate variable 
definition.

That's what I suspected. What is the advantage, then, of using the 
wildcard, rather than an untyped variable?

Gotta think outside the IDE :) because in the Flex world for 
example, depending on how you have the compiler set, it will 
complain if you don't typecast a variable (even if you are 
only doing a wildcard cast).


Jason Merrill
Bank of America
Global Technology  Operations  Global Risk LLD eTools  Multimedia 

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative 
learning ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Paul Andrews

What's the problem with private var bSprite:IDESprite;  ?

Paul

- Original Message - 
From: eric e. dolecki [EMAIL PROTECTED]

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Tuesday, July 01, 2008 5:25 PM
Subject: Re: [Flashcoders] Warning: 3596: Duplicate variable definition.



on a related note. If I have a sprite in my Library (exported with a class
name), and in that sprite some movieclips, in order to call the sprite 
into

my document class, in order to access things within that sprite, I have to
do this:

private var bSprite;
...
bSprite = new IDESprite();
bSprite.some_mc...

and NOT

private var bSprite:Sprite

because then when I try to access some_mc I get an error.

So in this case is it best to simply not type bSprite, or type it with a
wildcard?

- E

On Tue, Jul 1, 2008 at 11:32 AM, Merrill, Jason 
[EMAIL PROTECTED] wrote:


(even if you are
only doing a wildcard cast).

What I meant was, not even if, but that casting to a wildcard will
alieviate the compiler complaints since  you're casting to SOMETHING,
even if it is a wildcard.

Jason Merrill
Bank of America
Global Technology  Operations  Global Risk LLD
eTools  Multimedia

Join the Bank of America Flash Platform Developer Community

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe.



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Merrill, Jason
Sent: Tuesday, July 01, 2008 10:58 AM
To: Flash Coders List
Subject: RE: [Flashcoders] Warning: 3596: Duplicate variable
definition.

That's what I suspected. What is the advantage, then, of using the
wildcard, rather than an untyped variable?

Gotta think outside the IDE :) because in the Flex world for
example, depending on how you have the compiler set, it will
complain if you don't typecast a variable (even if you are
only doing a wildcard cast).


Jason Merrill
Bank of America
Global Technology  Operations  Global Risk LLD eTools  Multimedia

Join the Bank of America Flash Platform Developer Community

Are you a Bank of America associate interested in innovative
learning ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe.


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Merrill, Jason
You would not use a wildcard in that case, in your document class, you
would import IDESprite and then cast the variable as type:IDESprite

private var bSprite:IDESprite = new IDESprite();

Wildcards in my experience are more for when you don't know and/or don't
want to require what the type will be, it could be anything.  


Jason Merrill 
Bank of America 
Global Technology  Operations  Global Risk LLD 
eTools  Multimedia 

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of eric e. dolecki
Sent: Tuesday, July 01, 2008 12:26 PM
To: Flash Coders List
Subject: Re: [Flashcoders] Warning: 3596: Duplicate variable 
definition.

on a related note. If I have a sprite in my Library (exported 
with a class name), and in that sprite some movieclips, in 
order to call the sprite into my document class, in order to 
access things within that sprite, I have to do this:

private var bSprite;
...
bSprite = new IDESprite();
bSprite.some_mc...

and NOT

private var bSprite:Sprite

because then when I try to access some_mc I get an error.

So in this case is it best to simply not type bSprite, or 
type it with a wildcard?

- E

On Tue, Jul 1, 2008 at 11:32 AM, Merrill, Jason  
[EMAIL PROTECTED] wrote:

 (even if you are
 only doing a wildcard cast).

 What I meant was, not even if, but that casting to a 
wildcard will 
 alieviate the compiler complaints since  you're casting to 
SOMETHING, 
 even if it is a wildcard.

 Jason Merrill
 Bank of America
 Global Technology  Operations  Global Risk LLD eTools  
Multimedia

 Join the Bank of America Flash Platform Developer Community

 Are you a Bank of America associate interested in 
innovative learning 
 ideas and technologies?
 Check out our internal  GTO Innovative Learning Blog  subscribe.



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Merrill, Jason
 Sent: Tuesday, July 01, 2008 10:58 AM
 To: Flash Coders List
 Subject: RE: [Flashcoders] Warning: 3596: Duplicate variable 
 definition.
 
 That's what I suspected. What is the advantage, then, 
of using the 
 wildcard, rather than an untyped variable?
 
 Gotta think outside the IDE :) because in the Flex world for 
 example, depending on how you have the compiler set, it will 
 complain if you don't typecast a variable (even if you are only 
 doing a wildcard cast).
 
 
 Jason Merrill
 Bank of America
 Global Technology  Operations  Global Risk LLD eTools  
 Multimedia
 
 Join the Bank of America Flash Platform Developer Community
 
 Are you a Bank of America associate interested in innovative 
 learning ideas and technologies?
 Check out our internal  GTO Innovative Learning Blog  subscribe.
 
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Steven Sacks

Kerry,

You should turn Strict mode on your FLAs in the publish profile 
settings.  If you click on the language (the place you set your class 
paths and if you want Flash to auto-declare stage instances), you should 
see a checkbox for strict mode.  Turn it on.


The reason you want strict mode is because it will catch errors that the 
normal Flash compiler does not.  Strict mode will help you quite a bit 
and expose obvious errors that the normal Flash compiler does not catch, 
which results in confusing runtime errors that should have been caught 
during compiling.  I wish there was a way to turn Strict mode on by 
default, but AFAIK, you have to do it manually for every Flash file.


Leaving variables untyped is loose coding and AS3 is all about enforcing 
strict coding.  Using * as a wildcard type is not generally something 
you want to do, but it's there for you if you need it (notable 
exceptions include specific game programming situations where it's been 
proven faster to iterate over certain wildcard variables than typed ones).


In the example given, the proper way of doing that would be to do what I 
originally said; either have both classes extend the same abstract and 
cast the var to the abstract, or have both classes implement the same 
interface and cast the var to that.  In this case, you can probably get 
away with a wildcard, but you should never leave a variable untyped.


At the very least, you're making your code more readable in the sense 
that you're explicitly setting a type as a wildcard and it's clear in 
the code that's what you wanted, vs you forgot to set a type.


HTH,
Steven

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-07-01 Thread Kerry Thompson
Steven Sacks wrote:

 You should turn Strict mode on your FLAs in the publish profile 
 settings.

No problem there--it's one of the first things I did when I got CS3. I LIKE
strict typing, for all the reasons you mentioned. In fact, lack of typing in
Lingo is one of my biggest complaints about Director. It has led to more
hours of debugging than I care to think about.

I come from a background of over 20 years of typed languages--COBOL,
FORTRAN, Pascal, C/C++, even RPG--and the languages I have had the most
trouble debugging have been weakly typed or un-typed languages like Basic
and Lingo. Not that they don't have their place, but I appreciate the
compiler nagging me about mis-typed variables. I'd rather the compiler nag
me than spend half a day chasing down a bug stemming from untyped variables.

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-06-30 Thread Kerry Thompson
Pavel KruĊĦek wrote:

 I have written a script, here is piece of some method:
 
 private function resetState( e:Event )
   {
   switch(e.target.buttonType)
   {
case 0 :
 var clip = e.target as MenuButtonMain;
 var buttons:Array = _menuButtons;
 break;
case 1 :
 var clip = e.target as MenuButtonSub;
 var buttons:Array = _subMenuButtons;
 break;
   }
 
snip
 
   The script works as want it to but I keep getting a 3596 - duplicate
 variable definition warning,  when I run the script. 

You have var clip and var buttons defined twice, once in case 0 and once in
case 1. Try it like this, and I think the error will go away:

 private function resetState( e:Event )
{
var clip;
var buttons:Array;

switch(e.target.buttonType)
{
 case 0 :
clip = e.target as MenuButtonMain;
buttons = _menuButtons;
  break;
 case 1 :
clip = e.target as MenuButtonSub;
buttons:Array = _subMenuButtons;
break;
}
 
Cordially,

Kerry Thompson


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-06-30 Thread Steven Sacks
You see that you're declaring clip (and buttons) twice (causing the 
error), and as two different types (not causing the error but will cause 
another shortly).


Because you want one variable to act as either a Main or Sub, you need 
to either cast clip as an abstract version that both of those extend, or 
make an interface both of them implement and cast clip as such, or cast 
clip as * and forgo any strict typing altogether.


Relevant code only:

var buttons:Array;
var clip:* = e.target;
switch(e.target.buttonType)
{
case 0:
{
buttons = _menuButtons;
break;
}
case 1:
{
buttons = _subMenuButtons;
}
}


Pavel wrote:

Hi List,

I have written a script, here is piece of some method:

private function resetState( e:Event )
{
switch(e.target.buttonType)
{
 case 0 :
  var clip = e.target as MenuButtonMain;
  var buttons:Array = _menuButtons;
  break;
 case 1 :
  var clip = e.target as MenuButtonSub;
  var buttons:Array = _subMenuButtons;   
  break;

}

for (var i:uint = 0; i buttons.length; i++)
{
if( buttons[i] != clip )
{
buttons[i].enable();
} else buttons[i].disable();
}



 The script works as want it to but I keep getting a 3596 - duplicate 
variable definition warning,  when I run the script. Should I be woried 
about this warning message? What is wrong in my code?


Thanks

Pavel


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-06-30 Thread Kerry Thompson
  private function resetState( e:Event )
 {
   var clip;
   var buttons:Array;
 
   switch(e.target.buttonType)
   {
case 0 :
   clip = e.target as MenuButtonMain;
   buttons = _menuButtons;
 break;
case 1 :
   clip = e.target as MenuButtonSub;
   buttons:Array = _subMenuButtons;
   break;
   }

Sorry--cut and paste error. The case 1 reference to buttons should be

buttons = subMenuButtons;

without the :Array type identifier.

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Warning: 3596: Duplicate variable definition.

2008-06-30 Thread Steven Sacks

Even better, 3 lines.

var clip:* = e.target;
var buttons:Array = _menuButtons;
if (e.target.buttonType == 1) buttons = _subMenuButtons;
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders