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
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,
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
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
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
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
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
?
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
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
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
: [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
-
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
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
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
[]
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
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
@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
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:
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
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
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
- 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
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
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
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
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']); //
26 matches
Mail list logo