[Flashcoders] OOP 101: Is import really necessary?
Flashcoders, So this is one of those things I wonder about. If I type a var to a custom type, doesn't the compiler automatically import the associated class files? When or why would I need to explicitly need to use the import directive? Thanks in advance! -g ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
If you are talking about flash, no i believe it doesnt automatically import your class for you. You may be getting confused with the new Flex Builder 2 which does infact import automatically for you. On 25/05/06, Rifled Cloaca [EMAIL PROTECTED] wrote: Flashcoders, So this is one of those things I wonder about. If I type a var to a custom type, doesn't the compiler automatically import the associated class files? When or why would I need to explicitly need to use the import directive? Thanks in advance! -g ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP 101: Is import really necessary?
So this is one of those things I wonder about. If I type a var to a custom type, doesn't the compiler automatically import the associated class files? When or why would I need to explicitly need to use the import directive? Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rifled Cloaca Sent: Thursday, May 25, 2006 11:23 AM To: Flashcoders mailing list Subject: [Flashcoders] OOP 101: Is import really necessary? Flashcoders, So this is one of those things I wonder about. If I type a var to a custom type, doesn't the compiler automatically import the associated class files? When or why would I need to explicitly need to use the import directive? Thanks in advance! -g ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
import in AS2, is to help you avoid typing in the complete package name everytime u reference a class. The following code import mx.controls.Button; var playBtn:Button; ... var stopBtn:Button; var pauseBtn:Button; will look like this: var playBtn:mx.controls.Button; ... var stopBtn:mx.controls.Button; var pauseBtn:mx.controls.Button; if you don't use an import. Please refer flash help for more details.. :) ~Arul Prasad On 5/25/06, Rifled Cloaca [EMAIL PROTECTED] wrote: Flashcoders, So this is one of those things I wonder about. If I type a var to a custom type, doesn't the compiler automatically import the associated class files? When or why would I need to explicitly need to use the import directive? Thanks in advance! -g ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
ok its early for me but I think you dont actually need to import if you provide the full classpath for your datatypes: private var myVar:com.blah.MyDataType will work just fine, without an import, i beleive. however, if you wanted to do: private var myVar:MyDataType; then you would need to tell flash which class you were referring to, by importing the pakcage/class info. import com.blah.MyDataType; basically, 'import' is almost like setting a shortcut to refer to a particular class without using its full package name. On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: So this is one of those things I wonder about. If I type a var to a custom type, doesn't the compiler automatically import the associated class files? When or why would I need to explicitly need to use the import directive? Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rifled Cloaca Sent: Thursday, May 25, 2006 11:23 AM To: Flashcoders mailing list Subject: [Flashcoders] OOP 101: Is import really necessary? Flashcoders, So this is one of those things I wonder about. If I type a var to a custom type, doesn't the compiler automatically import the associated class files? When or why would I need to explicitly need to use the import directive? Thanks in advance! -g ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
I think what he is asking is if this is the same as import: var myObj:mx.core.UIObject = new mx.core.UIObject; I think one of the answers is that it saves on typing out the class info for every reference. Any other benefits to import? On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: So this is one of those things I wonder about. If I type a var to a custom type, doesn't the compiler automatically import the associated class files? When or why would I need to explicitly need to use the import directive? Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. Jason Merrill Bank of America Learning Technology Solutions ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP 101: Is import really necessary?
The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
I think Ian stated that Importing a class will not affect the swf, but instanciating an object contained in the class will. So: import MyCoolNewClass; does not affect swf var MyCoolNewClass:MyCoolNewClass = new MyCoolNewClass(); does affect swf Merrill, Jason wrote: The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
I think what he is saying is that if you had a dozen imports or imported an entire package (*) it would not include the specific classes until you actually referenced them. On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- Jonathan Berry, M.A. IT Consultant 619.306.1712(m) [EMAIL PROTECTED] www.mindarc.com --- This E-mail is covered by the Electronic Communications Privacy Act, 18 U.S.C. ?? 2510-2521 and is legally privileged. This information is confidential information and is intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. --- ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP 101: Is import really necessary?
Hi, it is included, but not solely becoz of the import statement. I might be wrong, but I believe this is even a 'bug'. Expected behavior: import MyClass causes inclusion of MyClass in the swf Real behavior: import MyClass still requires you to use MyClass somewhere in the code as in var myClass:MyClass, in order for it to be included. Note that we are talking about the Flash IDE here, with mtasc you can include exclude any class you like whether or not it is referenced in the code. greetz Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Thursday, May 25, 2006 7:25 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] OOP 101: Is import really necessary? The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP 101: Is import really necessary?
I see - gotcha. Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Jonathan Berry Sent: Thursday, May 25, 2006 1:58 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? I think what he is saying is that if you had a dozen imports or imported an entire package (*) it would not include the specific classes until you actually referenced them. On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- Jonathan Berry, M.A. IT Consultant 619.306.1712(m) [EMAIL PROTECTED] www.mindarc.com --- This E-mail is covered by the Electronic Communications Privacy Act, 18 U.S.C. ?? 2510-2521 and is legally privileged. This information is confidential information and is intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. --- ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
The import statement embeds, but so does this: var a:mx.controls.Button; import also allows you to use a shortcut as has been mentioned already. From the docs: Lets you access classes without specifying their fully qualified names. .. You must issue the import statement before you try to access the imported class without fully specifying its name. If you import a class but don't use it in your script, the class isn't exported as part of the SWF file. This means you can import large packages without being concerned about the size of the SWF file; the bytecode associated with a class is included in a SWF file only if that class is actually used. If you import but don't use it it's not included ... however, in practice you can definitely see that the SWF file size has changed. I took a blank FLA and published for a SWF size of 43 bytes. I then used this code: import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; import mx.controls.DataGrid; import mx.containers.Accordion; File size: 42.5 KB I then used this code: var b:mx.controls.Button; var l:mx.controls.List; var t:mx.controls.Tree; var d:mx.controls.DataGrid; var a:mx.containers.Accordion; FileSize: 48.3 KB I then used this code: import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; import mx.controls.DataGrid; import mx.containers.Accordion; var b:Button; var l:List; var t:Tree; var d:DataGrid; var a:Accordion; FileSize: 48.3 KB So the classes seem to be included in the SWF with just the import statements. Of course there is no difference if you import and use them compared to using them with explicit reference to the classes. Now the docs say that import by itself doesn't include the classes, but I used this code: import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; import mx.controls.DataGrid; import mx.containers.Accordion; trace(_global['mx']['controls']['Button']); The output panel displays [type Function] telling me that the class was indeed included. The compiler doesn't understand the [] notation as a reference to the class during compile-time, so I don't think that's why it worked. I think the classes are indeed included. However, someone could prove me wrong. Incidentally, the file size was 42.5 KB ... so, trim the fat and use [] notation! Derek Vadneau - Original Message - From: Merrill, Jason [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Thursday, May 25, 2006 1:24 PM Subject: RE: [Flashcoders] OOP 101: Is import really necessary? The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
import in flash is only used to save you some typing. when you use import com.package.Class; the class is *not* included in the swf until you reference that class in your code somewhere. like var blah:Class; you don't have to use import, you can also use: var blah:com.package.Class; and it will behave exactly the same way, only every time you reference the class, you'll need to type the full path instead of just 'Class' it's just a typing shortcut. On May 25, 2006, at 2:01 PM, j.c.wichman wrote: Hi, it is included, but not solely becoz of the import statement. I might be wrong, but I believe this is even a 'bug'. Expected behavior: import MyClass causes inclusion of MyClass in the swf Real behavior: import MyClass still requires you to use MyClass somewhere in the code as in var myClass:MyClass, in order for it to be included. Note that we are talking about the Flash IDE here, with mtasc you can include exclude any class you like whether or not it is referenced in the code. greetz Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Thursday, May 25, 2006 7:25 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] OOP 101: Is import really necessary? The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript cotained in the class is embedded in the .swf. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http
RE: [Flashcoders] OOP 101: Is import really necessary?
Also interesting to note here. If you make two layers in the timeline and in the top layer you put x = 10; And the bottom layer you put trace(x); you'll get 10. However, if in the top layer you put import SomeStaticClass; And in the bottom layer you put SomeStaticClass.someMethod(); It doesn't work. Imports only work in the scope of the specific script itself, not the clip those scripts are in, even though scripts in layers in Flash allegedly work from top to bottom as if they were one big script. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
The import statements tell the compiler where to find the classes your going to use, it compiles into the byte code only the classes you use. You could also do it by giving the full package.class of the class too. Import statements aren't strictly necessary, but they save a lot of typing if your using the library a lot. On 5/25/06, Derek Vadneau [EMAIL PROTECTED] wrote: The import statement embeds, but so does this: var a:mx.controls.Button; import also allows you to use a shortcut as has been mentioned already. From the docs: Lets you access classes without specifying their fully qualified names. .. You must issue the import statement before you try to access the imported class without fully specifying its name. If you import a class but don't use it in your script, the class isn't exported as part of the SWF file. This means you can import large packages without being concerned about the size of the SWF file; the bytecode associated with a class is included in a SWF file only if that class is actually used. If you import but don't use it it's not included ... however, in practice you can definitely see that the SWF file size has changed. I took a blank FLA and published for a SWF size of 43 bytes. I then used this code: import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; import mx.controls.DataGrid; import mx.containers.Accordion; File size: 42.5 KB I then used this code: var b:mx.controls.Button; var l:mx.controls.List; var t:mx.controls.Tree; var d:mx.controls.DataGrid; var a:mx.containers.Accordion; FileSize: 48.3 KB I then used this code: import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; import mx.controls.DataGrid; import mx.containers.Accordion; var b:Button; var l:List; var t:Tree; var d:DataGrid; var a:Accordion; FileSize: 48.3 KB So the classes seem to be included in the SWF with just the import statements. Of course there is no difference if you import and use them compared to using them with explicit reference to the classes. Now the docs say that import by itself doesn't include the classes, but I used this code: import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; import mx.controls.DataGrid; import mx.containers.Accordion; trace(_global['mx']['controls']['Button']); The output panel displays [type Function] telling me that the class was indeed included. The compiler doesn't understand the [] notation as a reference to the class during compile-time, so I don't think that's why it worked. I think the classes are indeed included. However, someone could prove me wrong. Incidentally, the file size was 42.5 KB ... so, trim the fat and use [] notation! Derek Vadneau - Original Message - From: Merrill, Jason [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Thursday, May 25, 2006 1:24 PM Subject: RE: [Flashcoders] OOP 101: Is import really necessary? The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- Weldon MacDonald ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP 101: Is import really necessary?
There is a bit of an anomaly with importing classes... For example you have 3 classes. Let's call them FirstClass, SecondClass and ThirdClass. Within FirstClass you import and create an instance of SecondClass and within SecondClass you import and create an instance of ThirdClass, creating a chain. On the main timeline of the fla, you import FirstClass, but don't create an instance of it. Because you didn't create an instance of it, rightfully it is not compiled. But, both SecondClass AND ThirdClass are compiled. You can check it either by file size or by clicking Debug--List Variables in the player window. Most likely because there is an instance of SecondClass created within FirstClass and an instance of ThirdClass created within SecondClass. It would make sense though that because an Instance of FirstClass was not created, that the compiler should just stop right there, but that isn't the case. Perhaps that's why there is the flaName_exclude.xml trick, but even then you have to explicitly exclude each class. It's not really a trick, but may be a little known concept. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Geoff Stearns Sent: Thursday, May 25, 2006 2:36 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? import in flash is only used to save you some typing. when you use import com.package.Class; the class is *not* included in the swf until you reference that class in your code somewhere. like var blah:Class; you don't have to use import, you can also use: var blah:com.package.Class; and it will behave exactly the same way, only every time you reference the class, you'll need to type the full path instead of just 'Class' it's just a typing shortcut. On May 25, 2006, at 2:01 PM, j.c.wichman wrote: Hi, it is included, but not solely becoz of the import statement. I might be wrong, but I believe this is even a 'bug'. Expected behavior: import MyClass causes inclusion of MyClass in the swf Real behavior: import MyClass still requires you to use MyClass somewhere in the code as in var myClass:MyClass, in order for it to be included. Note that we are talking about the Flash IDE here, with mtasc you can include exclude any class you like whether or not it is referenced in the code. greetz Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Thursday, May 25, 2006 7:25 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] OOP 101: Is import really necessary? The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need to type 'import' at all, as long as you refer to all your classes by full packagename. Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: Because if Flash imported every class available to it automatically, then your .swf files would be huge and unnecessarily bloated. Do you really want the code to all the Remoting classes imported into your .swf if you're not using them? When you include, the actionscript
Re: [Flashcoders] OOP 101: Is import really necessary?
Then how do you explain my results? 43 bytes for a SWF with nothing in it compared to 42.5 KB (that's kilobytes) with only 5 import statements. How do you account for the ~42.4 KB? And how do you account for the fact that a trace of the class using [] notation traces out [type Function]? If the classes were in fact not included, would it not return undefined? The compiler doesn't know that I've referenced the class when I use [] notation. Derek Vadneau - Original Message - From: Weldon MacDonald [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Thursday, May 25, 2006 2:54 PM Subject: Re: [Flashcoders] OOP 101: Is import really necessary? The import statements tell the compiler where to find the classes your going to use, it compiles into the byte code only the classes you use. You could also do it by giving the full package.class of the class too. Import statements aren't strictly necessary, but they save a lot of typing if your using the library a lot. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
Derek, Where did you place those imports? On the timeline, or in an external AS class file? Would it make a difference? -g ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP 101: Is import really necessary?
Adding...Importing it as a package does properly exclude the classes. From my example, obviously why import a class and not use it, but I'm trying to understand the logic of the compiler. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Booth Sent: Thursday, May 25, 2006 3:17 PM To: 'Flashcoders mailing list' Subject: RE: [Flashcoders] OOP 101: Is import really necessary? There is a bit of an anomaly with importing classes... For example you have 3 classes. Let's call them FirstClass, SecondClass and ThirdClass. Within FirstClass you import and create an instance of SecondClass and within SecondClass you import and create an instance of ThirdClass, creating a chain. On the main timeline of the fla, you import FirstClass, but don't create an instance of it. Because you didn't create an instance of it, rightfully it is not compiled. But, both SecondClass AND ThirdClass are compiled. You can check it either by file size or by clicking Debug--List Variables in the player window. Most likely because there is an instance of SecondClass created within FirstClass and an instance of ThirdClass created within SecondClass. It would make sense though that because an Instance of FirstClass was not created, that the compiler should just stop right there, but that isn't the case. Perhaps that's why there is the flaName_exclude.xml trick, but even then you have to explicitly exclude each class. It's not really a trick, but may be a little known concept. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Geoff Stearns Sent: Thursday, May 25, 2006 2:36 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? import in flash is only used to save you some typing. when you use import com.package.Class; the class is *not* included in the swf until you reference that class in your code somewhere. like var blah:Class; you don't have to use import, you can also use: var blah:com.package.Class; and it will behave exactly the same way, only every time you reference the class, you'll need to type the full path instead of just 'Class' it's just a typing shortcut. On May 25, 2006, at 2:01 PM, j.c.wichman wrote: Hi, it is included, but not solely becoz of the import statement. I might be wrong, but I believe this is even a 'bug'. Expected behavior: import MyClass causes inclusion of MyClass in the swf Real behavior: import MyClass still requires you to use MyClass somewhere in the code as in var myClass:MyClass, in order for it to be included. Note that we are talking about the Flash IDE here, with mtasc you can include exclude any class you like whether or not it is referenced in the code. greetz Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Thursday, May 25, 2006 7:25 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] OOP 101: Is import really necessary? The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. Err...that has not been my understanding at all. If that is the case, then why do you NOT need to include your class files on the server with the .swf? Since reality is you don't, all that code has to be in the .swf upon compiling, otherwise, the .swf wouldn't know what to do with Myvar:MyCoolClass = new MyCoolClass(); If it's not included with the .swf, how would the .swf know what MyCoolClass is otherwise? Jason Merrill Bank of America Learning Technology Solutions -Original Message- From: [EMAIL PROTECTED] [mailto:flashcoders- [EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: Thursday, May 25, 2006 12:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Errm - actually that's not such a good reason. The 'import' statement doesn't actually embed a class into the .swf. All it does is tell the compiler that when you type (for example) MyClass, you are actually referring to com.fred.MyClass. You could just type com.fred.MyClass throughout the body of your code instead of typing import at the top of the file. 'import' is simply a disambiguation helper for the compiler. It's got nothing to do with what code actually gets included in the resultant .swf. You can prove this by typing: import com.fred.* // Replace with some set of classes you're not using in your current project And recompiling. The .swf file size won't go up until you actually _reference_ an object that belongs to one of those packages. As soon as you typed: var f:MyClass=new MyClass(); or, in fact var f:com.fred.MyClass=new com.fred.MyClass(); The file size would go up. So - in answer to RifledCloaca - no, you don't need
Re: [Flashcoders] OOP 101: Is import really necessary?
Yep - just to reiterate (and hopefully make it more clear): The line: import com.fred.MyClass; Is _not enough_ to get Flash to compile MyClass into your .swf file. You need to actually _reference_ MyClass for it to be included. e.g. var a:MyClass=new MyClass(); In fact, import is _nothing to do_ with getting Flash to include compiled code into a .swf. All import does is to tell the compiler that whenever you refer to a class by a short name (MyClass) that it doesn't know anything about, it should check through the list of imports and try and match it up with one of them; and when it gets a successful match it should use the full package name and class. It's kind of when I _say_ MyClass, I really _mean_ com.fred.MyClass, but can't be bothered typing it That's all. :-) And that's why import com.fred.*; works. The compiler is just using that line (when you refer to a class by it's short name later on) to do a simple pattern match to try to work out what the package name for the class really is. import com.fred.* doesn't include all the _code_ of com.fred.*. It just means when I mention a class you haven't heard of before and can't find, check it against everything under com.fred. If it _did_ include all the code, your swfs would be bloated beyond belief. It's the actual usage of references to the object - declaration, instantiation, method calling - that makes Flash's equivalent of a linker include the compiled code for the class into the SWF. This is demonstrated when you are trying to instantiate classes via something like ClassFinder (http://dynamicflash.com/2005/03/class-finder/) and only ever referring to them using string names rather than actually referring to them directly in code. You'll find that you _can't_ instantiate the classes, even if you put in import lines for them - Flash hasn't worked out you need them in your .swf. So you need to actually put references to them into the code - normally doing something like: import com.fred.MyDynamicClass; var a:MyDynamicClass; is enough to make sure the linker works it all out and it's included. Hope that makes it clearer, Ian On 5/25/06, Merrill, Jason [EMAIL PROTECTED] wrote: I see - gotcha. Jason Merrill Bank of America Learning Technology Solutions ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
Hi Derek, That's really interesting - and goes against everything I'd expect. Particularly when your other results have kind of proved the opposite (and I've certainly proved the opposite before with ClassFinder situations). A couple of other tests might prove illuminating... - Is the same true of non-Macromedia classes? (i.e. have they hacked something specifically for those? I'd doubt it, but you never know) - How does it behave when you do something like: import mx.controls.Button; var a:String=mx; trace(_global[a]['controls']['Button']); In other words, is the compiler doing some cunning reduction on the string literals and actually working out that you're using the class? Again, I doubt it, but you never know! You have me mystified. :-D I'd test it myself, but have to rush off now to put up a tent in about 10cm of muddy water in a field somewhere in the middle of the UK. If nothings come to light by the beginning of next week, I'll have another look. :-) Cheers, Ian On 5/25/06, Derek Vadneau [EMAIL PROTECTED] wrote: Now the docs say that import by itself doesn't include the classes, but I used this code: import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; import mx.controls.DataGrid; import mx.containers.Accordion; trace(_global['mx']['controls']['Button']); ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
Well, I've demystified it, sorta. My previous results were from the timeline. Here are the results from a simple class: Just a simple class that is instantiated. 228 bytes Same but with import statements in the class file. 228 bytes Same but with variable assignments in the class. 47.9 KB Variable assignments with no imports. 47.9 KB That is probably what everyone is expecting to see and how the docs define the behaviour. When we talk timeline, you can chuck that. Interesting difference. I don't know why it would matter but that's the behaviour I'm seeing. Derek Vadneau - Original Message - From: Ian Thomas [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Thursday, May 25, 2006 3:47 PM Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Hi Derek, That's really interesting - and goes against everything I'd expect. Particularly when your other results have kind of proved the opposite (and I've certainly proved the opposite before with ClassFinder situations). A couple of other tests might prove illuminating... - Is the same true of non-Macromedia classes? (i.e. have they hacked something specifically for those? I'd doubt it, but you never know) - How does it behave when you do something like: import mx.controls.Button; var a:String=mx; trace(_global[a]['controls']['Button']); In other words, is the compiler doing some cunning reduction on the string literals and actually working out that you're using the class? Again, I doubt it, but you never know! You have me mystified. :-D I'd test it myself, but have to rush off now to put up a tent in about 10cm of muddy water in a field somewhere in the middle of the UK. If nothings come to light by the beginning of next week, I'll have another look. :-) Cheers, Ian ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
Then how do you explain my results? Because some of those classes instantiate other classes (in the UIObject hierarchy), so those classes are compiled even though you didn't instantiate the first class. Importing *any* of the MM UI components will instantiate all kinds of lower-level classes, causing the entire UIObject hierarchy to be compiled even if you never use the class you actually imported. ryanm ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] OOP 101: Is import really necessary?
It will include them, unless of course you exclude each one of them using the excludeAssets xml file. This file over-rides everything. Even if you instantiate the class, it will be excluded. - James -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ryanm Sent: Thursday, May 25, 2006 4:27 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] OOP 101: Is import really necessary? Then how do you explain my results? Because some of those classes instantiate other classes (in the UIObject hierarchy), so those classes are compiled even though you didn't instantiate the first class. Importing *any* of the MM UI components will instantiate all kinds of lower-level classes, causing the entire UIObject hierarchy to be compiled even if you never use the class you actually imported. ryanm ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
It is a very interesting find, Derek. I haven't noticed that. _ Derek Vadneau wrote: Now the docs say that import by itself doesn't include the classes, but I used this code: import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; import mx.controls.DataGrid; import mx.containers.Accordion; trace(_global['mx']['controls']['Button']); I played with it a little. (Flash 8.0/Mac OS X.4.6) import mx.controls.Button; import mx.controls.List; // import mx.controls.Tree; // import mx.controls.DataGrid; // import mx.containers.Accordion; trace(_global['mx']['core']['UIObject']); // Output: [type Function] trace(_global['mx']['controls']['Button']); // Output: undefined trace(_global['mx']['controls']['List']); // Output: undefined // import mx.controls.Button; import mx.controls.List; import mx.controls.Tree; // import mx.controls.DataGrid; // import mx.containers.Accordion; trace(_global['mx']['core']['UIObject']); // Output: [type Function] trace(_global['mx']['controls']['List']); // Output: [type Function] trace(_global['mx']['controls']['Tree']); // Output: undefined // import mx.controls.Button; import mx.controls.List; // import mx.controls.Tree; import mx.controls.DataGrid; // import mx.containers.Accordion; trace(_global['mx']['core']['UIObject']); // Output: [type Function] trace(_global['mx']['controls']['List']); // Output: [type Function] trace(_global['mx']['controls']['DataGrid']); // Output: [type Function] // import mx.controls.Button; // import mx.controls.List; // import mx.controls.Tree; // import mx.controls.DataGrid; import mx.containers.Accordion; trace(_global['mx']['core']['UIObject']); // Output: [type Function] trace(_global['mx']['controls']['Button']); // Output: [type Function] trace(_global['mx']['containers']['Accordion']); // Output: undefined Good luck, Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] OOP 101: Is import really necessary?
I nailed down this issue. If a class is imported in the timeline, its super class will be embedded. // Class definitions: class Test extends Super {} class Super {} // Timeline: _root import Test; // Test; trace(_global['Super']); // Output: [type Function] trace(_global['Test']); // Output: undefined Good luck, Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com