Re: [Flashcoders] Classes added
to save typing, merely hit control - enter when you start instantiating, and code completion will enter the import for you, such as: var c:DisplayOb...(ctrl-entr)... -Scott On Jan 15, 2008 3:42 PM, Merrill, Jason [EMAIL PROTECTED] wrote: 2) It makes it much easier to tell, at a glance, what a class depends on. This can be beneficial in many cases. That's the main reason I do it, I like to see all dependancies, for my own benefit and for others who will come after me. package.* always seemed like a cop-out to me, even if it saves some typing. :) Jason Merrill Bank of America GTO LLD Solutions Design Development eTools Multimedia Bank of America Flash Platform Developer Community ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- : : ) Scott ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Classes added
Yep we got that ;) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks Sent: 15 January 2008 00:55 To: Flash Coders List Subject: Re: [Flashcoders] Classes added And by that I mean that it's poorly written, hehe. 14.11 New expressions A new expression results in the invocation of the intrinsic construct method of the value computed by the expression that follows the new keyword. Arguments, if specified, are passed to the construct method. If no arguments are specified, the parentheses may be omitted. That paragraph really clears things up. LOL! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders __ This e-mail has been scanned for viruses by the Virtual Universe e-mail security system - powered by MessageLabs. http://www.virtual-universe.net __ Virtual Universe Ltd, 28-39 The Quadrant, 135 Salusbury Road, London NW6 6RJ Tel: +44 (0) 870 788 6000 Fax: +44 (0) 870 788 6689 Web:www.virtual-universe.net - CONFIDENTIALITY NOTICE This e-mail may contain information which is confidential and privileged. If you are not the named addressee of this e-mail, you may not copy or use it, or forward or otherwise disclose it to anyone else. If you have received this e-mail in error, please e-mail the sender by replying to this message and then fully delete it from your system. Any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of Amplefuture Group. Amplefuture Group reserves the right to monitor e-mail communications from both external and internal sources for the purposes of ensuring correct and appropriate use of our communication equipment. __ This e-mail has been scanned for viruses by the Virtual Universe e-mail security system - powered by MessageLabs. http://www.virtual-universe.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Classes added
nothing will actually be added; Sprite is an intrinsic class, importing it merely works as typing and as a definition for compilation (the class is already in the player so it's not added to the SWF). So then it is safe to do import flash.display.*; and not to worry about bundling up the SWF eh? var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); I tried to google it but didnt know exactly how to find it.. The first one is slightly uncommon, but both do the same thing. Zeh Thanks Zeh, that is what I thought but I wasn't sure. specially when I instantiate my Classes there was no difference on the way I was using them, of course unless I needed to pass some parameters. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Classes added
Very good point Glen... Although this seems kind of redundant if you import your classes and then use the qualified name to instantiate a specific class. But I fully understand what you mean. On 1/14/08, Glen Pike [EMAIL PROTECTED] wrote: Hi, As a quick note: The reason for specifically listing all the classes you actually use, rather than having wildcards means that you won't get clashes between the same classnames that may appear in different packages, e.g. //Button class in here import mx.controls.*; //Button in here too import com.glenpike.*; //create a glenpike button. var btn:Button = new Button(); //won't work or will produce bizarre results, you may need to use... //...fully qualified classnames var btn:com.glenpike.Button = new com.glenpike.Button The wildcard could be problematic if you use lots of libraries or have a big project and someone pointed out it was best practice to fully list all your imported classes... HTH Glen Dwayne Neckles wrote: Does that means that only the Sprite class will be added or will all the classes under display will still be added? All classes under display will be added if you wrote import flash.display.Sprite; then only the Sprite class would be imported.. Another basic question... could some one point me to a resource to understand the difference between var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); Dude good question.. I dont think there is a diference.. cause both works... and never feel hesitant to ask newbie questions.. Date: Mon, 14 Jan 2008 16:26:37 -0600 From: [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Classes added I remember reading in a book/article that you can import all the classes you need and only the ones used by the application will be actually added this thought has been bother me because my logic says... Import all classes since only the ones used will be added it doesnt matter what classes you import For example in the following: import flash.display.*; var mySprite:Sprite = new Sprite(); Does that means that only the Sprite class will be added or will all the classes under display will still be added? //Another basic question... could some one point me to a resource to understand the difference between var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); I tried to google it but didnt know exactly how to find it.. Thanks for your input... -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _ Make distant family not so distant with Windows Vista(R) + Windows Live™. http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Glen Pike 01736 759321 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Classes added
Thanks for pointing out that document Francis... I see there is a lot more information under the same domain to look at. Full Address: http://livedocs.adobe.com/specs/actionscript/3/wwhelp/wwhimpl/js/html/wwhelp.htm On 1/14/08, Francis Cheng [EMAIL PROTECTED] wrote: You are correct. This is explicitly mentioned in the AS3 Language Specification: http://livedocs.adobe.com/specs/actionscript/3/as3_specification131.html See the money quote in the last line of the paragraph: 14.11 New expressions A new expression results in the invocation of the intrinsic construct method of the value computed by the expression that follows the new keyword. Arguments, if specified, are passed to the construct method. If no arguments are specified, the parentheses may be omitted. Francis Cheng | Senior Technical Writer | Adobe Systems Incorporated -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Juan Pablo Califano Sent: Monday, January 14, 2008 3:11 PM To: Flash Coders List Subject: Re: [Flashcoders] Classes added ... If I'm not mistaken, these are equivalent. var mySprite:Sprite = new Sprite(); var mySprite:Sprite = new Sprite; However, if you don't use the parenthesis, you can't pass parameters to the constructor. Cheers. Juan Pablo Califano ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Classes added
So then it is safe to do import flash.display.*; Only if you're not going to run into any naming conflicts. I generally find it's better to only import the classes you're going to use, for a couple reasons. 1) It reduces the chance of naming conflicts (like two packages having Button classes in them). The only time you'll have to deal with naming conflicts here is if you actually need to use classes with the same name from two different packages. If you import the entire packages there's a higher chance of conflict. 2) It makes it much easier to tell, at a glance, what a class depends on. This can be beneficial in many cases. -Andy On Jan 15, 2008 11:52 AM, Helmut Granda [EMAIL PROTECTED] wrote: nothing will actually be added; Sprite is an intrinsic class, importing it merely works as typing and as a definition for compilation (the class is already in the player so it's not added to the SWF). So then it is safe to do import flash.display.*; and not to worry about bundling up the SWF eh? var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); I tried to google it but didnt know exactly how to find it.. The first one is slightly uncommon, but both do the same thing. Zeh Thanks Zeh, that is what I thought but I wasn't sure. specially when I instantiate my Classes there was no difference on the way I was using them, of course unless I needed to pass some parameters. ___ 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] Classes added
2) It makes it much easier to tell, at a glance, what a class depends on. This can be beneficial in many cases. That's the main reason I do it, I like to see all dependancies, for my own benefit and for others who will come after me. package.* always seemed like a cop-out to me, even if it saves some typing. :) Jason Merrill Bank of America GTO LLD Solutions Design Development eTools Multimedia Bank of America Flash Platform Developer Community ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Classes added
Hi, helmut, only the referenced classed will make it to the swf bytecode. So, if you have: import somePackage.ClassA; import somePackage.ClassB; private var _objectA:ClassA; Only the ClassA will be compiled. Of course, if you call the constructor, it'll be compiled as well. That's a traditional approach followed by Macromedia/Adobe to keep the swf's as light as possible. Since somePackage.ClassB is not actually used in your code, it'll be left out. By referencing it, you can force the compiler to include your class in the final bytecode (Not need to bother with that usually, but it helped my to prevent some aperently really odd bugs with a class compiled into various swf in a rather large project. Since many swfs holded the bytecode for the same class, the one in the first swf loaded was the actual code used -- the other definitions are discarded at runtime. If that swf was compiled with an old version of the class, then that old code was used by the app, and all the changes made to tha class would be missed at runtime. If, however, while navigating the site I happened to load first another swf that was exported with the new version of the class, I'd see the new behavior. It tripped me out for a quite a while until I realized what was going on. I fix it by forcing the main swf to compile the class just referencing it in a var declaration) If I'm not mistaken, these are equivalent. var mySprite:Sprite = new Sprite(); var mySprite:Sprite = new Sprite; However, if you don't use the parenthesis, you can't pass parameters to the constructor. Cheers. Juan Pablo Califano - Original Message - From: Helmut Granda [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Monday, January 14, 2008 8:26 PM Subject: [Flashcoders] Classes added I remember reading in a book/article that you can import all the classes you need and only the ones used by the application will be actually added this thought has been bother me because my logic says... Import all classes since only the ones used will be added it doesnt matter what classes you import For example in the following: import flash.display.*; var mySprite:Sprite = new Sprite(); Does that means that only the Sprite class will be added or will all the classes under display will still be added? //Another basic question... could some one point me to a resource to understand the difference between var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); I tried to google it but didnt know exactly how to find it.. Thanks for your input... -- ...helmut ___ 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] Classes added
For example in the following: import flash.display.*; var mySprite:Sprite = new Sprite(); Does that means that only the Sprite class will be added or will all the classes under display will still be added? Only what you *use* will be added. import doesn't include anything, it merely states you might or might not use that package (or class definition), so it'll now where to look in case you do so. So in your case, yeah, only Sprite would be added. *If* it was a normal class or some custom class under AS2. Because in this specific example, if you're referring to AS3, nothing will actually be added; Sprite is an intrinsic class, importing it merely works as typing and as a definition for compilation (the class is already in the player so it's not added to the SWF). //Another basic question... could some one point me to a resource to understand the difference between var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); I tried to google it but didnt know exactly how to find it.. The first one is slightly uncommon, but both do the same thing. Zeh ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Classes added
Does that means that only the Sprite class will be added or will all the classes under display will still be added? All classes under display will be added if you wrote import flash.display.Sprite; then only the Sprite class would be imported.. Another basic question... could some one point me to a resource to understand the difference between var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); Dude good question.. I dont think there is a diference.. cause both works... and never feel hesitant to ask newbie questions.. Date: Mon, 14 Jan 2008 16:26:37 -0600 From: [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Classes added I remember reading in a book/article that you can import all the classes you need and only the ones used by the application will be actually added this thought has been bother me because my logic says... Import all classes since only the ones used will be added it doesnt matter what classes you import For example in the following: import flash.display.*; var mySprite:Sprite = new Sprite(); Does that means that only the Sprite class will be added or will all the classes under display will still be added? //Another basic question... could some one point me to a resource to understand the difference between var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); I tried to google it but didnt know exactly how to find it.. Thanks for your input... -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _ Make distant family not so distant with Windows Vista® + Windows Live™. http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Classes added
Francis Cheng wrote: See the money quote in the last line of the paragraph: 14.11 New expressions A new expression results in the invocation of the intrinsic construct method of the value computed by the expression that follows the new keyword. Arguments, if specified, are passed to the construct method. If no arguments are specified, the parentheses may be omitted. That paragraph really clears things up. LOL! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Classes added
You are correct. This is explicitly mentioned in the AS3 Language Specification: http://livedocs.adobe.com/specs/actionscript/3/as3_specification131.html See the money quote in the last line of the paragraph: 14.11 New expressions A new expression results in the invocation of the intrinsic construct method of the value computed by the expression that follows the new keyword. Arguments, if specified, are passed to the construct method. If no arguments are specified, the parentheses may be omitted. Francis Cheng | Senior Technical Writer | Adobe Systems Incorporated -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Juan Pablo Califano Sent: Monday, January 14, 2008 3:11 PM To: Flash Coders List Subject: Re: [Flashcoders] Classes added ... If I'm not mistaken, these are equivalent. var mySprite:Sprite = new Sprite(); var mySprite:Sprite = new Sprite; However, if you don't use the parenthesis, you can't pass parameters to the constructor. Cheers. Juan Pablo Califano ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Classes added
Hi, As a quick note: The reason for specifically listing all the classes you actually use, rather than having wildcards means that you won't get clashes between the same classnames that may appear in different packages, e.g. //Button class in here import mx.controls.*; //Button in here too import com.glenpike.*; //create a glenpike button. var btn:Button = new Button(); //won't work or will produce bizarre results, you may need to use... //...fully qualified classnames var btn:com.glenpike.Button = new com.glenpike.Button The wildcard could be problematic if you use lots of libraries or have a big project and someone pointed out it was best practice to fully list all your imported classes... HTH Glen Dwayne Neckles wrote: Does that means that only the Sprite class will be added or will all the classes under display will still be added? All classes under display will be added if you wrote import flash.display.Sprite; then only the Sprite class would be imported.. Another basic question... could some one point me to a resource to understand the difference between var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); Dude good question.. I dont think there is a diference.. cause both works... and never feel hesitant to ask newbie questions.. Date: Mon, 14 Jan 2008 16:26:37 -0600 From: [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Classes added I remember reading in a book/article that you can import all the classes you need and only the ones used by the application will be actually added this thought has been bother me because my logic says... Import all classes since only the ones used will be added it doesnt matter what classes you import For example in the following: import flash.display.*; var mySprite:Sprite = new Sprite(); Does that means that only the Sprite class will be added or will all the classes under display will still be added? //Another basic question... could some one point me to a resource to understand the difference between var mySprite:Sprite = new Sprite; and //notice the end () var mySprite:Sprite = new Sprite(); I tried to google it but didnt know exactly how to find it.. Thanks for your input... -- ...helmut ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _ Make distant family not so distant with Windows Vista® + Windows Live™. http://www.microsoft.com/windows/digitallife/keepintouch.mspx?ocid=TXT_TAGLM_CPC_VideoChat_distantfamily_012008___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Glen Pike 01736 759321 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Classes added
And by that I mean that it's poorly written, hehe. 14.11 New expressions A new expression results in the invocation of the intrinsic construct method of the value computed by the expression that follows the new keyword. Arguments, if specified, are passed to the construct method. If no arguments are specified, the parentheses may be omitted. That paragraph really clears things up. LOL! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders