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
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:
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
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
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
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.
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
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
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
:[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
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
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
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
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
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
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
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 :
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
18 matches
Mail list logo