Re: [Flashcoders] AS3 - Button follow cursor within image area

2008-06-25 Thread Vayu Robins
Thanks for the tip Ashim! :-))


On 6/25/08 5:01 AM, Ashim D'Silva [EMAIL PROTECTED] wrote:

 You can also disable the button and use the image itself as a button.
 On click on the image, the event will feed you local mouse coords
 which will tell you which side of the image the mouse is on.
 Layered buttons are a bit troublesome, but there's workarounds.
 
 2008/6/25 Vayu Robins [EMAIL PROTECTED]:
 I think I have found a solution to my problem.  Dont know if its the best,
 but instead of adding a listener to the image, I added a listener to the
 stage and found the coordinates and width of image and made my buttons
 visible when inside these coordinates.
 
 Cordially
 Vayu
 
 
 On 6/24/08 7:27 PM, Vayu Robins [EMAIL PROTECTED] wrote:
 
 Hi coders.
 
 I have an issue I cant seem to find a solution to.
 
 I have an image gallery with invisble next and previous buttons.  When the
 mouse is over the left side of the image, the left button becomes visible
 and follows the mouse.  So far so good. :-)  The problem is that when the
 button is under the mouse the button only moves when the mouse has moved
 away from the button, which creates a very jagged movement.  Furthermore,
 this can be solved if I set prevImg.mouseEnabled = false, but then I disable
 the button.
 
 So the cursor needs to know when its over the image, even when the button is
 between the mouse and the image.
 
 Heres code I use:
 
 private function navigationMove(event:Event):void{
 var target = event.target;
 var location:Point = new Point(target.mouseX, target.mouseY);
 location = target.localToGlobal(location);
 if(event.target.mouseX  278) {
 prevImg.visible = true;
 nextImg.visible = false;
 prevImg.x = location.x;
 prevImg.y = location.y;
 }else{
 prevImg.visible = false;
 nextImg.visible = true;
 nextImg.x = location.x;
 nextImg.y = location.y;
 }
 }
 
 I hope someone can help me on this one.
 
 Thanks
 Vayu
 
 
 ___
 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] as2 - method losing scope when called from timeline.

2008-06-25 Thread Joseph Balderson
AS2 is full of mysterious crap, er bugs like this. It's what made Flash such a 
pain at times. I am s loving AS3... not that it's without it's own quirks...


___

Joseph Balderson, Flash Platform Developer | http://joeflash.ca


Steven Sacks wrote:

It's a rare bug that is unacknowledged by Macromedia/Adobe.

If you name the package folder that contains your class the same as your 
class name (case doesn't matter), AS2 will behave like a dumbass.  It 
does randomly buggy behavior, and it's impossible to track down what it 
is because there's nothing wrong with your code, it's AS2 being buggy.


Once you rename your package or class, everything works as it should.


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


Re: [Flashcoders] calling public static methods on Class using getDefinitionByName

2008-06-25 Thread jonathan howe
On a related note, I noticed this syntax in Flash help this morning:

var componentClass:Class = e.target.selectedItem.data as Class;
var styles:Object = componentClass[getStyleDefinition].call(this);

On Tue, Jun 24, 2008 at 8:27 PM, Patrick Matte | BLITZ 
[EMAIL PROTECTED] wrote:

 Ah ok, the reason it wasn't working was that I was casting ClassReference
 as Class instead of Object... Now this works.

 var ClassReference:Object = getDefinitionByName(Test) as Object;
 var bool:Boolean = ClassReference.parse(false); //would return false;


 BLITZ | Patrick Matte - 310-551-0200 x214

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] On Behalf Of Wagner Amaral
 Sent: Tuesday, June 24, 2008 7:18 AM
 To: Flash Coders List
 Subject: Re: [Flashcoders] calling public static methods on Class using
 getDefinitionByName

 On Tue, Jun 24, 2008 at 6:14 AM, Kenneth Kawamoto 
 [EMAIL PROTECTED]
 wrote:

  trace(getDefinitionByName(Test).parse(false));
 


 Nice
 Then maybe this works too (no compiler available right now, so just
 guessing):

 var c:Class = getDefinitionByName(Test) as Class;
 (c as Object).parse(false);
 ___
 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




-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] FLV ending prematurely in FLVPlayback component

2008-06-25 Thread Matt Muller
Hi, I am using the FLVPlayback component to serve videos. Users with a slow
connection are getting the FLV stopping midway through.

I've done some testing and it seems the player thinks the FLV has finished,
which it hasn't. This is happening across multiple FLV's. I've tried
encoding with no audio.

Any ideas?

cheers,

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


[Flashcoders] switch statement more efficient than if...else?

2008-06-25 Thread Allandt Bik-Elliott (Receptacle)

Hi guys

quick question that came up in a conversation I had the other day -  
are switch statements more or less efficient than a series of  
if...else statements in either AS2 or AS3?


I'd always thought that the most efficient was the switch

al.z

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


Re: [Flashcoders] switch statement more efficient than if...else?

2008-06-25 Thread Paul Andrews
- Original Message - 
From: Allandt Bik-Elliott (Receptacle) [EMAIL PROTECTED]

To: flashcoders flashcoders@chattyfig.figleaf.com
Sent: Wednesday, June 25, 2008 3:12 PM
Subject: [Flashcoders] switch statement more efficient than if...else?



Hi guys

quick question that came up in a conversation I had the other day -  are 
switch statements more or less efficient than a series of  if...else 
statements in either AS2 or AS3?


I'd always thought that the most efficient was the switch


I doubt that there's anything in it - the compiler writes your if statement 
for you with a switch statement.


It would be better to be more concerned about readability and 
maintainability, where the switch statement will win hands down for many 
cases..  ;-)


Paul

al.z 


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


Re: [Flashcoders] FLV ending prematurely in FLVPlayback component

2008-06-25 Thread Manuel Ponce de Leon
Try using the FLV Metadata Injector into your FLVs 
http://www.buraks.com/flvmdi/


The problem may be caused by incorrect (ie, rounded down duration value) 
or corrupted metadata on the FLV.


Matt Muller wrote:

Hi, I am using the FLVPlayback component to serve videos. Users with a slow
connection are getting the FLV stopping midway through.

I've done some testing and it seems the player thinks the FLV has finished,
which it hasn't. This is happening across multiple FLV's. I've tried
encoding with no audio.

Any ideas?

cheers,

MaTT
___
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] switch statement more efficient than if...else?

2008-06-25 Thread eric e. dolecki
Switch/case is a bit quicker.

On Wed, Jun 25, 2008 at 10:12 AM, Allandt Bik-Elliott (Receptacle) 
[EMAIL PROTECTED] wrote:

 Hi guys

 quick question that came up in a conversation I had the other day - are
 switch statements more or less efficient than a series of if...else
 statements in either AS2 or AS3?

 I'd always thought that the most efficient was the switch

 al.z

 ___
 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] switch statement more efficient than if...else?

2008-06-25 Thread Kenneth Kawamoto
One thing worth noting is switch statement uses strict equality (===) 
therefore it's not exactly the same as if/else with equality (==).


Kenneth Kawamoto
http://www.materiaprima.co.uk/

Paul Andrews wrote:

Hi guys

quick question that came up in a conversation I had the other day -  
are switch statements more or less efficient than a series of  
if...else statements in either AS2 or AS3?


I'd always thought that the most efficient was the switch


I doubt that there's anything in it - the compiler writes your if 
statement for you with a switch statement.


It would be better to be more concerned about readability and 
maintainability, where the switch statement will win hands down for many 
cases..  ;-)


Paul

al.z 

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


Re: [Flashcoders] switch statement more efficient than if...else?

2008-06-25 Thread Juan Pablo Califano
I doubt there's a noticeable difference between a switch and a series of if
/else if statements.

In AS 3.0 bytecode, though, switches and equivalent conditionals are not
necessarily compiled into the same bytecode. In fact, there's a lookupswitch
instruction (opcode 0x1b). Of course, any switch can be implemented as a
series of if / else if statements, but that's up to the compiler. From my
(limited) experience, the Flash IDE always uses a switch bytecode whenever
it finds a switch construct in Actionscript code. I don't know how it
affects runtime performance, but my guess is that it doesn't have much
impact. And, thinking about it, maybe that opcode exists because it's an
optimized way to compile / execute a series of related conditions.

Cheers
Juan Pablo Califano


2008/6/25, eric e. dolecki [EMAIL PROTECTED]:

 Switch/case is a bit quicker.

 On Wed, Jun 25, 2008 at 10:12 AM, Allandt Bik-Elliott (Receptacle) 
 [EMAIL PROTECTED] wrote:

  Hi guys
 
  quick question that came up in a conversation I had the other day - are
  switch statements more or less efficient than a series of if...else
  statements in either AS2 or AS3?
 
  I'd always thought that the most efficient was the switch
 
  al.z
 
  ___
  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] switch statement more efficient than if...else?

2008-06-25 Thread Allandt Bik-Elliott (Receptacle)

hey

thanks for all of your responses

al.z


On 25 Jun 2008, at 16:24, Juan Pablo Califano wrote:

I doubt there's a noticeable difference between a switch and a  
series of if

/else if statements.

In AS 3.0 bytecode, though, switches and equivalent conditionals  
are not
necessarily compiled into the same bytecode. In fact, there's a  
lookupswitch
instruction (opcode 0x1b). Of course, any switch can be implemented  
as a
series of if / else if statements, but that's up to the compiler.  
From my
(limited) experience, the Flash IDE always uses a switch bytecode  
whenever

it finds a switch construct in Actionscript code. I don't know how it
affects runtime performance, but my guess is that it doesn't have much
impact. And, thinking about it, maybe that opcode exists because  
it's an

optimized way to compile / execute a series of related conditions.

Cheers
Juan Pablo Califano


2008/6/25, eric e. dolecki [EMAIL PROTECTED]:


Switch/case is a bit quicker.

On Wed, Jun 25, 2008 at 10:12 AM, Allandt Bik-Elliott (Receptacle) 
[EMAIL PROTECTED] wrote:


Hi guys

quick question that came up in a conversation I had the other day  
- are

switch statements more or less efficient than a series of if...else
statements in either AS2 or AS3?

I'd always thought that the most efficient was the switch

al.z

___
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] switch statement more efficient than if...else?

2008-06-25 Thread Mark Winterhalder
 I'd always thought that the most efficient was the switch

I know that the haXe compiler uses a jump table, I'm not sure about
the AS3 compiler. But as already mentioned there is an extra opcode
for switch, and even if the compiler doesn't a jump table, it might
use one in the future.

So, switch at least isn't slower, even if it isn't faster yet it has
the potential to become faster in the future, and it's more readable
in any case -- making switch the preferable choice.

The question should be is switch on int faster than switch on String?

Mark



On Wed, Jun 25, 2008 at 4:12 PM, Allandt Bik-Elliott (Receptacle)
[EMAIL PROTECTED] wrote:
 Hi guys

 quick question that came up in a conversation I had the other day - are
 switch statements more or less efficient than a series of if...else
 statements in either AS2 or AS3?

 I'd always thought that the most efficient was the switch

 al.z

 ___
 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] switch statement more efficient than if...else?

2008-06-25 Thread Rich Shupe
Actually, tt is my (perhaps wrong) understanding that this is not the case.
In the past, both Macromedia and Adobe sources have stated that switch does
not offer a performance boost--just readability and functionality (optional
break lines) enhancements over if statements.

I have been wrong many times, however. This may be such a case.


On 6/25/08 10:48 AM, eric e. dolecki wrote:

 Switch/case is a bit quicker.

Rich
http://www.LearningActionScript3.com


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


Re: [Flashcoders] switch statement more efficient than if...else?

2008-06-25 Thread Cedric Muller

and switch on Number ? :P
I read somewhere that Number was quicker than int though I still  
can't believe it


cedric



I'd always thought that the most efficient was the switch


I know that the haXe compiler uses a jump table, I'm not sure about
the AS3 compiler. But as already mentioned there is an extra opcode
for switch, and even if the compiler doesn't a jump table, it might
use one in the future.

So, switch at least isn't slower, even if it isn't faster yet it has
the potential to become faster in the future, and it's more readable
in any case -- making switch the preferable choice.

The question should be is switch on int faster than switch on  
String?


Mark



On Wed, Jun 25, 2008 at 4:12 PM, Allandt Bik-Elliott (Receptacle)
[EMAIL PROTECTED] wrote:

Hi guys

quick question that came up in a conversation I had the other day  
- are

switch statements more or less efficient than a series of if...else
statements in either AS2 or AS3?

I'd always thought that the most efficient was the switch

al.z

___
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] SWF file size differences

2008-06-25 Thread Manuel Ponce de Leon
Wonder if anyone else has come across this problem. It's definitely 
weird and to me it looks like a bug.


I have a simple fla file. I publish on a Mac and a PC (both with Flash 
CS3, AS3, Flash Player 9). The resulting SWF is way bigger on the PC 
(7KB vs 2KB on the Mac) despite the fla being the exact same file.


When looking at the file size reports of both systems, there are 
considerable differences in the Font Bytes and Frame Bytes Columns.


Any ideas?

Cheers,

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


[Flashcoders] Firefox 3 and flash 8 wmode problem

2008-06-25 Thread Patrick Matte | BLITZ
Has anybody else been experiencing problems with flash player 8 using wmode 
with Firefox 3?

Can't click on any of the flash buttons, using flash player 8 r42.

No problem with Firefox 2.

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


Re: [Flashcoders] switch statement more efficient than if...else?

2008-06-25 Thread Steven Sacks
I disagree that switch statements are more readable than if else 
statements, at least if you put your braces on their own lines.


if (true)
{
   // something
}
else if (true)
{
   // something else
}
else if (true)
{
   // yet another outcome
}

I don't think either is more readable than the other, unless you write 
your if else or switch statements poorly (no whitespace).


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


RE: [Flashcoders] switch statement more efficient than if...else?

2008-06-25 Thread Merrill, Jason
I disagree that switch statements are more readable than if 
else statements, at least if you put your braces on their own lines.

I wouldn't disagree, but I think it's more about personal preference.
Maybe it's just aesthetics, but I prefer:

switch(b)
{
case apple:
do something
break;
case bananas:
do something else
break;
case pears:
do yet something else
break;
}

(or the same thing above but with brackets)

over:

if (b==apple)
{
do something
}
else if (b==bananas)
{
do something else
}
else if (b==pears)
{
do yet something else
}


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] switch statement more efficient than if...else?

2008-06-25 Thread Kerry Thompson
Steven Sacks wrote:

 I disagree that switch statements are more readable than if else
 statements, at least if you put your braces on their own lines.

I'm a die-hard switch/case guy, but I agree with Steven on this. Neither is
inherently easier or harder to read.

Of course, I personally prefer switch statements, but I think it's a matter
of style. Steven's example is every bit as readable as a switch statement.

Also, with switch statements, you have to be careful about nesting switch
statements. I've seen switch statements with nested switches that are 3-4
pages long. There has to be a better way to write code than that.

Cordially,

Kerry Thompson

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


Re: [Flashcoders] switch statement more efficient than if...else?

2008-06-25 Thread eric e. dolecki
better way than nested switches that are 3-4 pages long = if/else statements
;)

On Wed, Jun 25, 2008 at 11:25 PM, Kerry Thompson [EMAIL PROTECTED]
wrote:

 Steven Sacks wrote:

  I disagree that switch statements are more readable than if else
  statements, at least if you put your braces on their own lines.

 I'm a die-hard switch/case guy, but I agree with Steven on this. Neither is
 inherently easier or harder to read.

 Of course, I personally prefer switch statements, but I think it's a matter
 of style. Steven's example is every bit as readable as a switch statement.

 Also, with switch statements, you have to be careful about nesting switch
 statements. I've seen switch statements with nested switches that are 3-4
 pages long. There has to be a better way to write code than that.

 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] switch statement more efficient than if...else?

2008-06-25 Thread Steven Sacks
One thing that nobody who writes switch statements seemed to know (me 
included) is you can (and, apparently, should) write them like this:


switch (n)
{
   case 0:
   {
   foo();
   break;
   }

   case 1:
   {
   bar();
   return;
   }

   case 2:
   {
   baz();
   return;
   }

   default:
   {
   blech();
   break;
   }
}


I definitely find that more readable than the old way. 


http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders