Import statement *not* required?

Can someone explain this to me? I was following along a
simple AS3 example (in the design video workshop) where a "Power
Button" has some MouseEven CLICK event handling applied to it with
a trace statement as the resulting handled function. Really simple
basic example. The import statement is import
flash.events.MouseEvent.
How come removing the import statement does not produce an
error?
Reference:
import flash.events.MouseEvent;
myButton.addEventListener(MouseEvent.CLICK, myButtonClicked);
function myButtonClicked(event:MouseEvent):void {
trace('do Something');
}

midimidi,
> So to be clear...if the AS is on the main timeline,
import statements
> are not needed, and if the AS is external and imported,
import
> statements are needed.
That's a general rule of thumb, but not 100% applicable.
> Are there any other exceptions to that, or does that go
for all AS3
> classes?
There are exceptions, and the easiest way to find them is to
leave out
your import statements and plug away ... sooner or later,
you'll get a
compiler error, and then you'll know. :)
>> It did strike me *** odd though, an imported .as
file uses the same
>> publish settings as code on the timeline. So why
treat them differently?
FLA files have publish settings, but AS files don't. They're
just text
files. I hear what you're saying ... they end up getting
compiled along
with / into the some FLA anyway -- and that FLA does have
classpaths
listed -- but those same AS files might be compiled in Flex
Builder 2 or
some 3rd party compiler. It would probably make good sense to
require the
import statement for inline FLA code, but not everyone is a
hardcore
programmer, and Adobe knows it. Nothing is *hurt* by using
import in FLAs,
but for folks who just want to do light programming, the
convenience of not
having to use it is nice.
David Stiller
Adobe Community Expert
Dev blog,
http://www.quip.net/blog/
"Luck is the residue of good design."

Similar Messages

  • Import statement not working

    i created a package named "pkg1", it contains 4 classes named
    1) Base
    2) Subclass1 (extends Base)
    3) Subclass2 (extends Subclass1)
    4) Subclass3 (extends Subclass2)
    now when i try to use the package using
    import pkg1.*
    and in main method, if i write,
    Subclass3 obj = new Subclass3();
    It does not work, error msg says "makes sure Subclass3 is in the correct sub-directory."
    However, when i tried
    import pkg1.Subclass3;
    It worked fine, Why is then import pkg1.* not working??

    I don't think that's going to help.
    Try and see.
    When the java compiler looks for a class
    pkg1.Subclass1 it looks for pkg1\Subclass1.java
    relative to the current directory and
    pkg1\Subclass1.class relative to each directory on
    the classpath.
    When the javac compiler (at least version 1.4) looks for a dependent class, it looks in the Classpath directories. It only looks relative to the current directory if the current directory is in the Classpath. When it looks for a dependent class, it looks for both .java and .class files. If it only finds a .java file or the .java file is newer than a .class file, it will try to compile the file.
    You need to compile from the directory above
    pkg1, in this case (unfortunately) d:\
    This makes it sound like it is a requirement to compile from the directory. It isn't required.

  • EXPORT IMPORT  STATEMENT NOT WORKING

    hI
       I AM USING THE FOLLOWING STATEMENT BUT THE VALUES ARE NOT COMING IN THE TABLE ACTOR_TAB1
    SUBMIT ZDISPLAY3 WITH P_MFRNR = P_MFRNR
                       WITH P_GFELD = P_GFELD AND RETURN
    IMPORT ACTOR_TAB1 = ACTOR_TAB1 FROM  MEMORY ID 'KAKAL_INS'.
    IN REPORT ZDISPLAY3 I AM USING THE FOLLOWING STATEMENT
      EXPORT ACTOR_TAB = ACTOR_TAB TO MEMORY ID 'KAKAL_INS'.
    IN INTERNAL TABLE ACTOR_TAB1 VALUE IS NOT COMING CAN ANY BODY TELLY WHY VALUE IS NOT GETTING POPULATED

    Hi kota,
    1. When u use memory id, make sure of the
    following points.
    a) The memory id is SAME as the variable name
    b) Memory id should be in CAPITAL
    c) When u want to import,
    the variable name should be same as original one,
    and should be declared in the same fashion only.
    regards,
    amit m.

  • Lucene import statements not working

    I'm new to Tomcat, Lucene, and JSP, so bare with me...
    I just installed all three and Tomcat and JSP are working and Lucene is working. Now I'm trying to get them working together but I don't know where my issue is. I have a sample page I found and it's not working and giving me the following error messages...
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 6 in the generated java file
    Only a type can be imported. com.knowledgebooks.servlet.StartupWorkServlet resolves to a package
    An error occurred at line: 7 in the generated java file
    Only a type can be imported. org.apache.lucene.document.Document resolves to a package
    An error occurred at line: 8 in the generated java file
    Only a type can be imported. org.apache.lucene.search.Searcher resolves to a package
    An error occurred at line: 9 in the generated java file
    Only a type can be imported. org.apache.lucene.search.IndexSearcher resolves to a package
    An error occurred at line: 10 in the generated java file
    Only a type can be imported. org.apache.lucene.analysis.Analyzer resolves to a package
    An error occurred at line: 11 in the generated java file
    Only a type can be imported. org.apache.lucene.analysis.standard.StandardAnalyzer resolves to a package
    An error occurred at line: 14 in the generated java file
    Only a type can be imported. org.apache.lucene.search.Query resolves to a package
    An error occurred at line: 15 in the generated java file
    Only a type can be imported. org.apache.lucene.queryParser.QueryParser resolves to a package
    An error occurred at line: 16 in the generated java file
    Only a type can be imported. org.apache.lucene.search.Hits resolves to a package
    An error occurred at line: 17 in the generated java file
    Only a type can be imported. com.knowledgebooks.API resolves to a packageI'm not even sure where to begin looking. Does anyone have any idea?
    Thanks in advance!

    can you provide me your jsp code? so i can look into and advice you.

  • Import statement not found for javax.mail.Message

    when i'm in webSphere shich is using jdk1.4.2,
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Session;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    cannot be found
    Where would the Mail classes be located?
    Thank you

    mail.jar and activation.jar, which can be downloaded here:
    http://java.sun.com/products/javamail/downloads/index.html
    http://java.sun.com/products/javabeans/jaf/downloads/index.html

  • Import invoice with status as Approval not Required

    Hi All,
    Can any one give the way to import an invoice with payables open interface import status as Approval not required.
    Thank you in advance.
    Raj.

    midimidi,
    > So to be clear...if the AS is on the main timeline,
    import statements
    > are not needed, and if the AS is external and imported,
    import
    > statements are needed.
    That's a general rule of thumb, but not 100% applicable.
    > Are there any other exceptions to that, or does that go
    for all AS3
    > classes?
    There are exceptions, and the easiest way to find them is to
    leave out
    your import statements and plug away ... sooner or later,
    you'll get a
    compiler error, and then you'll know. :)
    >> It did strike me *** odd though, an imported .as
    file uses the same
    >> publish settings as code on the timeline. So why
    treat them differently?
    FLA files have publish settings, but AS files don't. They're
    just text
    files. I hear what you're saying ... they end up getting
    compiled along
    with / into the some FLA anyway -- and that FLA does have
    classpaths
    listed -- but those same AS files might be compiled in Flex
    Builder 2 or
    some 3rd party compiler. It would probably make good sense to
    require the
    import statement for inline FLA code, but not everyone is a
    hardcore
    programmer, and Adobe knows it. Nothing is *hurt* by using
    import in FLAs,
    but for folks who just want to do light programming, the
    convenience of not
    having to use it is nice.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Import statement is not working

    hi everybody,
    I have a directory under which I have a number of sub-directories. Lets call this directory "parent_directory". under this directory I have another directory called "child_1". Under "child_1" I have another subdirectory called "child_2". Now I have a code in child_2 that has the following statement:
    import program_1;
    //this is a program present in the parent directory. lets call it
    //program_1.java
    when I am compiling I am getting an error saying:
    program_2.java:28: '.' expected
    import program_1;
    ^
    1 error
    program_2.java is the program present in child_2 in which I have included the import statement.
    If I change the ";" to "." then again error appears as the import statement only needs the name of the class and doesnot need the extension.
    I will be very grateful to you if you could please suggest me a way around this.

    This questions belongs in the "New to Java" forum ...
    sigh
    Anyways, import works on package names with trailing * or full qualified class names, e.g.import mypackage1.*; // imports all classes in mypackage1
    import mypackage2.MyClass2; // imports MyClass2 from mypackage2So instead of import program_1; you need to do
    1. ensure that program_1 is in some package
    2. ensure that your directory structure mirrors your package structure (same names!)
    3. ensure that your CLASSPATH is either not set at all or points to the parent dir of your topmost package
    Example:
    Directory structure:C:\tmp\java\top\
    C:\tmp\java\top\MyClass1.java
    C:\tmp\java\top\bottom\
    C:\tmp\java\top\bottom\MyClass2.java
    CLASSPATH=".;<java install dir>\jre\lib\rt.jar;C:\tmp\java"Source for MyClass1.java:package top;
    public class MyClass1 {
    }Source for MyClass2.java:package top.bottom;
    import top.MyClass1;
    public class MyClass2 {
      private MyClass1 myClass1;
    }

  • Additions required in portalapp.xml to import statements in JSPDynPage

    Hi all,
    What additions are required in portalapp.xml and import statements in JSPDynPage to include the equivalent of following JCO Clientservice in EP6 SP11?
    com.sap.portal.runtime.application.jcoclient.jcoclient
    The piece of code requiring the above is also given below.
    IJCOClientService clientService = (IJCOClientService) PortalRuntime.getRuntimeResources().getService("com.sap.portal.runtime.application.jcoclient.jcoclient");
    Thanking you ,
    Med venlig hilsen/Best regards
    Prabahar N.R

    Hi Prabahar,
    portalapp.xml: Add "com.sap.portal.runtime.application.jcoclient" to the SharingsReferences.
    import: com.sapportals.portal.prt.service.jco.IJCOClientService
    Hope it helps
    Detlev

  • About once a week, I can be doing some really important uni work and the bloody thing crashes and states 'not responding'

    I open Firefox, then as soon as it opens it states 'not responding' then starts working, then 'sticks' on every page/site I go to. Am doing important uni work and am getting sick of this happening, it's either great or rubbish and very bloody annoying.

    upgrade your browser to Firefox 9 and check
    * getfirefox.com

  • Why do some Security Updates get flagged by SCCM 2012 as "Not Required" when the Bulletin ID states they are?

    Hiya
    We've just pushed all updates from the March patch Tuesday Security Bulletin to our test Workstations/Servers (using SCCM 2012 R2)
    One of the patches (MS14-013 - KB2929961) hasn't applied to a selection of 2008 R2 and 2012 Servers, but according to the Bulletin notes for this it is applicable to both. It has applied to my Windows 8 boxes.
    The servers don't already have this applied, its not a superseded update and SCCM has flagged this as "Required" for x64 versions of Windows 7, Windows 8, Windows 8.1 but "Not required" for any servers. 
    Bulletin ID states its applicable to all except Itanium based editions - https://technet.microsoft.com/en-us/security/bulletin/ms14-013
    If I download the update and try to run it manually on the servers I get "The update is not applicable to your computer"
    So it looks as though the WUAgent and SCCM compliance are reporting correctly, but that the Bulletin ID isn't entirely correct??
    Has anyone else found this? We use the Bulletin IDs for monthly meetings on what we're patching and what system it will affect so causes a lot of confusion with system owners when a patch doesn't apply that they're expecting to get applied.
    Thanks!

    Hi,
    Without any indepth investigation if I am not mistaking the update is for Directshow and that component is installed with the Desktop Experience on the server OS's, and therefor the update is not applicable on the servers.. 
    Could that be the case?
    Regards,
    Jörgen
    -- My System Center blog ccmexec.com -- Twitter
    @ccmexec

  • HT4914 iTunes sight states PC requirements for iTunes Match is: iTunes 10.5.1 or later but my PC is not allowing download stating I need windows upgrade to 8. Anyone else have this issue.

    iTunes Match states PC requirements is iTunes 10.5.1, but my PC states I need to have windows 8 to use Match or access it on PC. Any way around this?

    Anyone?

  • Import statement clashes

    Hi,
    If 2 import statements happen to import the same class implicitly (as opposed to naming the exact class in the import statement), then how does the compiler decide which one is used? Apparently the order of the import statements doesn't matter... already tried that.
    For example:
    //class Test.java
    import java.lang.*; /redundant, but shows that we're importing Object
    import org.omg.CORBA.Object;
    public class Test {
    public static void main(String[] args) {
    Object obj = new String();
    ... here, the compiler complains about "found: java.lang.String" and "required: org.omg.CORBA.Object". Switching the order of the import statements had no effect... same issue. How are name clashes handled with import statements?

    The conflict is not resolved -- if there is any ambiguity the compiler complains. In these cases you need to use the fully qualified class name; e.g. java.lang.Object or org.omg.CORBA.Object -- it's not allowed to use the simple name "Object" because there's no way to know which of the two is meant.

  • Import statement and directory structure

    First of all, sorry for such a long post, I believe part of it is because I am unsure of the concept of importing in Java. Secondly, Thanks to anyone who can ultimately enlighten me to the concept of import. I did ask this question before in the "erorr and error handling" forum, and the people who have helped me there did a great job. But, I believe I require a little more clarification and thus have decided to post here.
    Anyhow, my question..
    Could someone explain to me the concept of the import statement, or direct me to a webpage with sort of explanation for newbies? For some reason, I am having a hard time grasping the concept.
    As I understand it, the import statement in Java, is very similar to the namespace keyword in C. That is to say, import doesn't actually "import" any source code, the way that the #include statement does in C.
    So I suppose what my question is, say I have a java class file like below:
    //filename: sentence.java
    //located: c:\school\csc365
    package csc365;
    class sentence
    //some variables here..
    //some constructor here..
    //some methods here..
    And some sample program like the one below which implements the above..
    //filename: test.java
    //located: c:\school\csc365
    import csc365.*;
    import java.io.*;
    class test.java
    //creates some sentence object
    //uses the object's methods
    //some other things.
    As I understand it, the test.java file should not compile because the csc365 package is not in the correct directory. (assuming of course, the classpath is like c:\school\csc365;c:\school )
    But, ... where then should the sentence.java be located? In a subdirectory of c:\school called csc365 (i.e c:\school\csc365\) ?
    And thus that would mean the test.java file could be located anywhere on the hard drive?
    I suppose, I just need a little clarification on the correlation between a package's "name" (i.e package csc365; ) and its corresponding directory's name, and also how the javac compiler searches the classpath for java classes.
    ..So, theoretically if I were to set the classpath to look in every conceivable directory(provided the directory names were all unique) of the harddrive, then I could compile a test.java anywhere?
    As a note: I have been able to get the test.java file to compile, by leaving out the import statement in the test.java file, and also leaving out the package statement for the sentence class, but I assume this is because the files are defaulted to the same package?

    Hi Mary,
    No, import isn't analogous to C++ namespace - Java package is closer to the namespace mark.
    import is just a convenience for the programmer. You can go your whole Java career without ever writing an import statement if you wish. All that means is that you'll have to type out the fully-resolved class name every time you want to use a class that's in a package other than java.lang. Example:
    // NOTE: No import statements
    public class Family
       // NOTE: fully-resolved class names
       private java.util.List children = new java.util.ArrayList();
    }If you use the import statement, you can save yourself from typing:
    import java.util.ArrayList;
    import java.util.List;
    public class Family
       // NOTE: fully-resolved class names
       private List children = new ArrayList();
    }import isn't the same as class loader. It does not bring in any source code at all.
    import comes into play when you're compiling or running your code. Java will check to make sure that any "shorthand" class names you give it live in one of the packages you've imported. If it can't find a matching fully-resolved class name, it'll give you a message like "Symbol not found" or something like that.
    I arrange Java source in a directory structure that matches the package structure in the .class files.
    If I've got a Java source file like this:
    package foo.bar;
    public class Baz
       public static void main(String [] args)
            Baz baz = new Baz();
            System.out.println(baz);
       public String toString()
           return "I am a Baz";
    }I'll store it in a directory structure like this:
    root
    +---classes
    +---src
          +---foo
               +---bar
                    +---Baz.javaWhen I compile, I go to root and compile by typing this:
    javac -d classes foo/bar/*.javaI can run the code from root by typing:
    java -classpath classes foo.bar.BazI hope this wasn't patronizing or beneath you. I don't mean to be insulting. - MOD

  • Length error occured in IMPORT statement

    Hello everyone,
    i hv one requirment in PO print(ME23N). in po print asset no nt display without changing other format.
    so that i first copy both smartform and driver program, in that i made certain changes such that i declare the patameter p_ebeln and i comment to data statement of p_ebeln & p_ebeln = nest-objky.
    then i join asset no (anek-anln1) with the help of inner join. then in smartform i gave condition that if bsart = 'ZCAP'
    wa_final-anln1 = gv_anln1.
    endif.
    i import gv_anln1 in smartform and exported in deriver program.
    both are synthetically currect but when i gave print preview dump is occured.
    length error occured in IMPORT statement
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_IMPORT_MISMATCH_ERROR', was
         not caught in
        procedure "%GLOBAL_INIT" "(FORM)", nor was it propagated by a RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        During import the system discovered that the target object has
        a different length than the object to be imported.
    what i do?

    Hello,
    can u send me coding for that?
    program line is already created for that
    and their first coding is like that,
    if gv_bsart = 'ZCAP'.
    wa_final-matnr = space.
    endif.
    and in text they fetch matnr no.
    but as per requirement they want asset no when bsart = 'ZCAP'
    how that asset no will come.
    matnr comes there is bsart is other that ZCAP, but bsart = ZCAP they want asset no instead of matnr.

  • JSP import Statement importing a Class File giving ERROR

    Hey guys,
    There is a problem to which I dont know the reason,
    Consider the code below:
    <%@ import Converter, ConverterHome %>
    It gives me a Compile Time error of this type:
    '.' Required in import Converter ;
    but when i put these classes in a package suppose "converter"
    and the above import statement like this :
    <%@ import converter.Converter,converter.ConverterHome%>
    It gives me no error
    So whats the reason behind this? Cant I compile a JSP program by refrencing classes without in any package?
    please Reply
    Thanks in advance..

    So whats the reason behind this?
    Cant I compile a JSP program by refrencing classes without in any package?No, I do not beleive you can, is you are using Java 1.4. In 1.4, you can only reference classes in the Default Package (none) from other classes in the default package. If you are in a package, then you can not import from the default package. And this is for ALL java classes, not just JSP and Serlets. Since the JSP servlet would be part of a package (which depends on the server you are using) you will need to put your classes into packages to import them...

Maybe you are looking for

  • Tax code S0

    Dear experts my problem is ,when I maintain Tax code S0 in service po,System automatically calculate tax amount in PO.When in condition record S1 is maintained. Pl provide a solution Mayur

  • Generating table with large number of columns (256)

    Hi, I don't know if this is right place for posting this: for data mining purposes I need a table which column names needs to be size N, where N is 2, 3 or 4. Column name is build upon alphabet of nucleotids A,C,T,G and all variations with repetition

  • Perl Select

    Good Morning: I am accesing the DataBase from a Perl Script. In the Insert sentence, I want to use some pl/sql functions: $stmt = "insert into my_table(field_1) values ( replace('$s_column_name[$i]',CHR(39),CHR(39)||CHR(39)))"; But the function repla

  • Skype Internet DECT phone not working

    Hi all, I tried to get support from Creative but they have been less than useful. ? ?Can anyone answer these two simple questions: . What is the latest version of the Dect software? I am on v.2.6.0 2. Is there a knowledge base / support section that

  • ITunes eating 100% cpu and reopening soulution

    My iTunes made almost unusable my mac, and when I closed it, it always reopened. I havent noticed the RimAlbumDaemon, cause it hasn't took too many cpu time, but IT was the reason of iTunes's behavior. I deleted every BalckBerry related software from