RE: [Flashcoders] Try... catch......

2009-05-10 Thread Mario Gonzalez
One thing to note, is that try,catch(e:Error) is expensive for the AVM because 
it has to Throw an error.

Maybe not for this example or whatever you're creating, but it's something to 
keep in mind for later.
I see a lot of code we receive riddled with that as a way of hiding run-time 
errors AVM1 style.

Just something to note,

Mario Gonzalez
http://onedayitwillmake.com/
http://wonderfl.kayac.com/user/onedayitwillmake/


From: flashcoders-boun...@chattyfig.figleaf.com 
[flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Paul Andrews 
[p...@ipauland.com]
Sent: Saturday, May 09, 2009 11:27 AM
To: Flash Coders List
Subject: Re: [Flashcoders] Try... catch..

I regret my one word answer because while it answers the question, there's a
question of good practice to consider.

Putting "return ball;" as  the last line doesn't really help the casual code
reader, because I need to really look hard at the code to realise that if
ball is not explicitly set elsewhere the return value will be null.

However,

catch (e:TypeError ){ return null; }

explicitly shows that if the exception occurs the function will return null.

There's even a good argument for having "return null" at the end of the code
too, since only one exception will explicitly return null...

It's always better to have explicit code rather than try and save a
statement or two. We've all been down the "smart" code route though. Guilty
as charged.

Paul





- Original Message -
From: "Paul Andrews" 
To: "Flash Coders List" 
Sent: Saturday, May 09, 2009 4:17 PM
Subject: Re: [Flashcoders] Try... catch..


> Yes.
>
> - Original Message -
> From: "ACE Flash" 
> To: "Flash Coders List" 
> Sent: Saturday, May 09, 2009 3:28 PM
> Subject: Re: [Flashcoders] Try... catch..
>
>
>> Hi Hans,
>>
>> Thanks for the code :) I have one more question for the script below
>>
>> 1. if catch the TypeError, does the last line => return ball will
>> execute?
>>
>> Thanks a lot
>>
>>
>> public function myBall( value:int ):Ball
>>  {
>>   var ball:Ball = null;
>>
>>  try{
>>
>> //my code goes here.
>>  } catch (e:TypeError ){
>>
>>  }
>>  return ball;
>> }
>>
>>
>>
>> On Sat, May 9, 2009 at 2:21 AM, Hans Wichman
>> >> wrote:
>>
>>> Hi,
>>> yup
>>>
>>> either
>>> public function myBall( value:int ):Ball
>>>   {
>>>   var ball:Ball
>>>
>>>   try{
>>>
>>>  //my code goes here.
>>>  return ball;
>>>  } catch (e:TypeError ){
>>>   trace("Whoops");
>>>   }
>>>   return null;
>>>   }
>>>
>>> or
>>>
>>> public function myBall( value:int ):Ball
>>>   {
>>>var ball:Ball = null;
>>>
>>>   try{
>>>
>>>  //my code goes here.
>>>   } catch (e:TypeError ){
>>>
>>>   }
>>>   return ball;
>>>  }
>>> There are more possibilities, some of which are better practice than
>>> others,
>>> but in such a small method, I wouldn't make to much of a fuss about it.
>>>
>>> regards,
>>> JC
>>>
>>>
>>> On Sat, May 9, 2009 at 3:22 AM, ACE Flash  wrote:
>>>
>>> > Hi there,
>>> >
>>> > I am trying to add try block in my code, how can I deal it with return
>>> > function?
>>> >
>>> > If the code without any problems, I'd like to return "ball" ,
>>> > otherwise
>>> I'd
>>> > like to EXIT or return null.
>>> >
>>> > Thanks
>>> >
>>> > -
>>> >
>>> >  public function myBall( value:int ):Ball
>>> >{
>>> >var ball:Ball
>>> >
>>> >try{
>>> >
>>> >   //my code goes here.
>>> >   return ball;
>>> >   } catch (e:TypeError ){
>>> >
>>> >}
>>> >
>>> >   // shall I add => return null here?
>>> >}
>>> > ___
>>> > 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

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


Re: [Flashcoders] RegEx

2009-05-10 Thread Ian Thomas
Match and replace work fine for me outside of AIR.

Ian

On Sat, May 9, 2009 at 11:54 PM, Anthony Pace  wrote:
> I am reading the documentation, and it says that match and replace are only
> for air 1.0 and they have that nasty trilobal air logo.
>
> What the heck  If that is the case then why are they running in the
> flash player?
> ___
> 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] Try... catch......

2009-05-10 Thread Juan Pablo Califano
I might be wrong, but I think hanlding an exception / error is not the
expensive part.

The expensive part is throwing, as you said.

But, if you have:

var container:Sprite = null;
container.addChild(child);

The error will be thrown, whether you have a handler for it or not. The
"cost" here is that the player has to unwind the stack looking for a
suitable catch block to handle the error, jump to that block and then get
back to where it was.

In fact, I think handling the error right away should be less expensive than
not catching it or catching it further down the stack.

Cheers
Juan Pablo Califano


2009/5/10 Mario Gonzalez 

> One thing to note, is that try,catch(e:Error) is expensive for the AVM
> because it has to Throw an error.
>
> Maybe not for this example or whatever you're creating, but it's something
> to keep in mind for later.
> I see a lot of code we receive riddled with that as a way of hiding
> run-time errors AVM1 style.
>
> Just something to note,
>
> Mario Gonzalez
> http://onedayitwillmake.com/
> http://wonderfl.kayac.com/user/onedayitwillmake/
>
> 
> From: flashcoders-boun...@chattyfig.figleaf.com [
> flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Paul Andrews [
> p...@ipauland.com]
> Sent: Saturday, May 09, 2009 11:27 AM
> To: Flash Coders List
>  Subject: Re: [Flashcoders] Try... catch..
>
> I regret my one word answer because while it answers the question, there's
> a
> question of good practice to consider.
>
> Putting "return ball;" as  the last line doesn't really help the casual
> code
> reader, because I need to really look hard at the code to realise that if
> ball is not explicitly set elsewhere the return value will be null.
>
> However,
>
> catch (e:TypeError ){ return null; }
>
> explicitly shows that if the exception occurs the function will return
> null.
>
> There's even a good argument for having "return null" at the end of the
> code
> too, since only one exception will explicitly return null...
>
> It's always better to have explicit code rather than try and save a
> statement or two. We've all been down the "smart" code route though. Guilty
> as charged.
>
> Paul
>
>
>
>
>
> - Original Message -
> From: "Paul Andrews" 
> To: "Flash Coders List" 
> Sent: Saturday, May 09, 2009 4:17 PM
> Subject: Re: [Flashcoders] Try... catch..
>
>
> > Yes.
> >
> > - Original Message -
> > From: "ACE Flash" 
> > To: "Flash Coders List" 
> > Sent: Saturday, May 09, 2009 3:28 PM
> > Subject: Re: [Flashcoders] Try... catch..
> >
> >
> >> Hi Hans,
> >>
> >> Thanks for the code :) I have one more question for the script below
> >>
> >> 1. if catch the TypeError, does the last line => return ball will
> >> execute?
> >>
> >> Thanks a lot
> >>
> >>
> >> public function myBall( value:int ):Ball
> >>  {
> >>   var ball:Ball = null;
> >>
> >>  try{
> >>
> >> //my code goes here.
> >>  } catch (e:TypeError ){
> >>
> >>  }
> >>  return ball;
> >> }
> >>
> >>
> >>
> >> On Sat, May 9, 2009 at 2:21 AM, Hans Wichman
> >>  >>> wrote:
> >>
> >>> Hi,
> >>> yup
> >>>
> >>> either
> >>> public function myBall( value:int ):Ball
> >>>   {
> >>>   var ball:Ball
> >>>
> >>>   try{
> >>>
> >>>  //my code goes here.
> >>>  return ball;
> >>>  } catch (e:TypeError ){
> >>>   trace("Whoops");
> >>>   }
> >>>   return null;
> >>>   }
> >>>
> >>> or
> >>>
> >>> public function myBall( value:int ):Ball
> >>>   {
> >>>var ball:Ball = null;
> >>>
> >>>   try{
> >>>
> >>>  //my code goes here.
> >>>   } catch (e:TypeError ){
> >>>
> >>>   }
> >>>   return ball;
> >>>  }
> >>> There are more possibilities, some of which are better practice than
> >>> others,
> >>> but in such a small method, I wouldn't make to much of a fuss about it.
> >>>
> >>> regards,
> >>> JC
> >>>
> >>>
> >>> On Sat, May 9, 2009 at 3:22 AM, ACE Flash  wrote:
> >>>
> >>> > Hi there,
> >>> >
> >>> > I am trying to add try block in my code, how can I deal it with
> return
> >>> > function?
> >>> >
> >>> > If the code without any problems, I'd like to return "ball" ,
> >>> > otherwise
> >>> I'd
> >>> > like to EXIT or return null.
> >>> >
> >>> > Thanks
> >>> >
> >>> > -
> >>> >
> >>> >  public function myBall( value:int ):Ball
> >>> >{
> >>> >var ball:Ball
> >>> >
> >>> >try{
> >>> >
> >>> >   //my code goes here.
> >>> >   return ball;
> >>> >   } catch (e:TypeError ){
> >>> >
> >>> >}
> >>> >
> >>> >   // shall I add => return null here?
> >>> >}
> >>> > ___
> >>> > Flashcoders mailing list
> >>> > Flashcoders@chattyfig.figleaf.com
> >>> > http://chattyfig.figleaf.c

RE: [Flashcoders] e.target subobjects how do I refrence??

2009-05-10 Thread liutoday

function down(e:MouseEvent):void{

  var _obj:Button = e.target Button;

 TweenMax.to(obj.menuSquare_mc, .3, {alpha:.06, delay:0,
ease:Sine.easeOut}); 

 }
 
> Date: Thu, 7 May 2009 09:29:05 -0500
> From: zu...@zadesigns.com
> To: flashcoders@chattyfig.figleaf.com
> Subject: [Flashcoders] e.target subobjects how do I refrence??
> 
> 
> 
> I have a loop that is assigning event listeners to "target". My targets
> are named btn1, btn2, btn3, etc etc. 
> 
> inside each btn, I have a movie clip called "menuSquare_mc" which I want
> to animate. how can I target menuSquare_mc of each button using only 1
> function??? 
> 
> function down($e:MouseEvent ):void { 
> 
> trace($e.type + " : " +$e.target ) ; 
> 
> if ($e.type == "mouseOver") { 
> 
> TweenMax.to($e.target.menuSquare_mc, .3, {alpha:.06, delay:0,
> ease:Sine.easeOut}); 
> 
> } 
> 
> } 
> 
> the above code fails... I want it to say btn1.menuSquare_mc,
> btn2.menuSquare_mc, etc) using just 1 function... 
> 
> in fact, my idea would be to use if $e.type == "mouseDown" do another
> function just like the over and one just like the out.
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_
上MClub和Messenger好友一起都市寻宝!
http://club.msn.cn/?from=1
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Creating MXP with Flex Builder?

2009-05-10 Thread Gerry Beauregard
I'm development a library of interactive sound effects in Action  
Script 3 using Flex Builder. I've got loads of experience with audio  
coding on various platforms in various languages (especially C++).   
However, I'm relatively new to Flash development, so I have some  
(perhaps naive) questions about how to package the library.   Perhaps  
some of you can help.


Until now, I've been thinking of packaging the library as a SWC, but  
after some investigation, it seems that flash components are normally  
packaged & sold as MXP files, e.g. on sites like flashloaded.com.  As  
far as I can tell, Flex Builder doesn't provide any way to directly  
create an MXP.


Is there some extra plugin for Flex Builder for creating an MXP?  Or  
is there some separate tool that can create an MXP from a SWC?


I've seen the Adobe Extension Manager mentioned in the context of  
MXPs... but from what I've read so far, it sounds like it manages  
loading of MXPs, rather than their creation.   I've seen some docs on  
MXI files, which appear to simply be XML files for defining what goes  
into an MXP...  but I still haven't figured out what tool will read in  
an MXI and files to which it refers to generate an MXP...  any tips  
would be most welcome!


I'm developing on a Mac, btw, but can easily switch to using Windows  
if the tools available on Windows are better.


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