When is necessary to use import statements to import classes?

Hi,
I'm sure that it must be necessary to use import statements
in some situations, I'm finding that my code often works fine
without them. For example, some instructions will say it is
necessary to use import.flash.events.MouseEvent; before
MouseEvent.CLICK will work, or that I must import the loader class
before loading an SWF, but I'm finding that I can skip timporting
and it works fine. Could anyone please explain why this it, and
give me some idea of how to knew when to import and when I don't
have to?
Thank you in advance!

Importing is only necessary when you create you own classes
or are using a class that Flash doesn't auto import such as the
fscommand package. Any time you create your own custom
package/class, it is also necessary to use import statements unless
you add the folder containing your custom packages to the default
class path.

Similar Messages

  • Casting Object using imported class

    The problem im having is when trying to de-serialize an obejct. the class that defines the object is stored in a different package and this code works fine when i move the class into the same package.
    Im getting a ClassNotFoundException on the line with the >>
    Any thoughts on why i cant cast using a class from another package?
         private void loadTest(){
              try {
                   FileInputStream fi = new FileInputStream("./Tests/"+plantComboBox.getSelectedItem()+"/"+mode+"/"+testComboBox.getSelectedItem()+"/"+testComboBox.getSelectedItem()+".test");
                   ObjectInputStream oi = new ObjectInputStream(fi);
                   >>test = (Test)oi.readObject();
                   //test.printTest();
                   oi.close();
              } catch (Exception er) {
                   er.printStackTrace();
         }

    Yeah i figured it out. The object that was serialized was made in a different project and was contained in a package called "main".
    In my other project When i was running that method with the "Test" class in the same package as the method, it was, coincidently in the "main" package and when i moved it to my "test" package and the object was de-serialized it was being re-initialized with its package as "main" and throwing the error.

  • Can you use if statements for css classes?

    I'm trying to make a table field change color depending on what info the field is pulling from the database.  Here is my code:
    <table>
    <?php do { ?>
          <tr>
            <td><input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_getSystems['path_id']; ?>" />
              <strong><?php echo $row_getSystems['system']; ?></strong></td>
            <td><?php echo $row_getSystems['jumps']; ?></td>
    <?php
      if ($row_getSystems['security'] < 0.5) {
      ?>
      <td class="alert"><?php echo $row_getSystems['security']; ?></td> <? ;}
      elseif ($row_getSystems['security'] < 0.7)  {
      ?>
            <td class="noalert"><?php echo $row_getSystems['security']; ?></td> <? ;}
      else {
      ?>
      <td class="good"><?php echo $row_getSystems['security']; ?></td> <? ;} ?>
            <td><?php echo $row_getSystems['belts']; ?></td>
            <td><?php echo $row_getSystems['station']; ?></td>
            <td><?php echo $row_getSystems['deadend']; ?></td>
            </tr>
          <?php } while ($row_getSystems = mysql_fetch_assoc($getSystems)); ?>
      </table>
    I added the spaces to make the part I wrote stand out better.
    When I try to view it live - it says:
    Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\mining\systems.php on line 101
    Any ideas on how to do this?  Cause clearly, I'm not doing it correctly. 
    Thanks!

    Nevermind, I figured out how to do it.  Here is the correct code.  I presume this is the best way.  Hopefully. 
    <table>
      <?php do { ?>
          <tr>
            <td><input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_getSystems['path_id']; ?>" />
              <strong><?php echo $row_getSystems['system']; ?></strong></td>
            <td><?php echo $row_getSystems['jumps']; ?></td>
            <!-- Table Background Changes -->
                        <td style=" color: #fff;
                        <?php
                        if ($row_getSystems['security'] < 0.5) {
                        echo "background-color: #C00"; }
                        elseif  ($row_getSystems['security'] < 0.7) {
                        echo "background-color: #F90"; }
                        else {
                        echo "background-color: #060";
                        ?>
            ">
                          <strong><?php echo $row_getSystems['security']; ?></strong></td>
            <!-- End of Changes -->
            <td><?php echo $row_getSystems['belts']; ?></td>
            <td><?php echo $row_getSystems['station']; ?></td>
            <td><?php echo $row_getSystems['deadend']; ?></td>
            </tr>
          <?php } while ($row_getSystems = mysql_fetch_assoc($getSystems)); ?>
      </table>

  • Binding a subtree using custom State- and ObjectFactory

    Hi,
    first of all a very short example to illustrate my idea. I know that it would be complete rubbish to store the kind of data in the example in multiple classes and ldap entries. Currently I'm working with much larger objects that must be written according to special schema definitions. This example is really only for illustration!
    LDAP-Schema:
    objectclass ( 1.3.6.1.4.1... NAME 'myperson'
                  SUP top STRUCTURAL
                  MUST ( cn $ sn ) MAY ( email ) )
    objectclass ( 1.3.6.1.4.1... NAME 'myphoto'
                  SUP top STRUCTURAL
                  MUST ( cn $ jpegPhoto ) )
    Java-Classes:
    class MyPhoto {
        byte[] photo;
    class MyPerson {
        String cn;
        String sn;
        String email;
        MyPhoto photo; // This is the really relevant line :)
    }Now to the question:
    Is it possible to bind multiple java objects with one call to bind and to get a subtree by using custom State- and ObjectFactory-Classes?
    Structure of the LDAP-Database
    dn: cn=John Doe
    {  cn=John Doe
       sn=Doe
       [email protected]   }
    dn: cn=TheLogo, cn=John Doe    // Child of cn=John Doe
    { cn=TheLogo              // The cn is the same for all MyPhoto entries
                              // its only use is for building the dn
      jpegPhoto=[some binary data]   }I tried to solve the problem with a kind of recursion. When my StateFactory is called to bind an Object of Class MyPerson it builds the appropriate AttributeList. Before it returns, it calls bind for the Object of class MyPhoto with the dn: "cn=TheLogo,cn=John Doe".
    Of course this doesn't work because the entry for cn="John Doe" doesn't exist at this time. Now I don't know what to do. A possible solution would be to create everything by hand, but then I wouldn't have to use custom StateFactories at all. But if there is a simple solution to my problem I would like to use my own StateFactory instead of having to implement a persistance manager on my own.
    I hope you understand what I want to do and why it doesn't work out. If you don't please ask and I will try to clarify.

    Hello,
    A provisional solution is to use an external controller. For this approach to work, each class has to provide the list of objects being part of its properties. I have prepared two interfaces for this purpose:
    public interface HasSubordinates {
    Enumeration getSubordinates();
    boolean hasSubordinates();
    public interface Storable extends HasSubordinates {
    String getIdentifier();
    Then, you can use the controller to recursively get the object "tree" and store it in the directory (either using objects that implement the DirContext interface or using StateFactories - the last one is the one I have used)
    The code for the Controller is the following:
    import javax.naming.*;
    import javax.naming.directory.*;
    import javax.naming.spi.*;
    import java.util.*;
    import java.io.IOException;
    public class DatabaseAccessController {
    // Constants
    final static String ldapServerName = "localhost";
    final static String rootdn = "cn=juanluis, o=niaf";
    final static String rootpass = "secret";
    final static String rootContext = "o=niaf";
    private DirContext initialContext;
    private static Properties env = new Properties();
    static {
    env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
    env.put( Context.STATE_FACTORIES, "database.PersonStateFactory:database.AddressStateFactory");
    env.put( Context.PROVIDER_URL, "ldap://"+ ldapServerName+"/"+rootContext);
    env.put( Context.SECURITY_PRINCIPAL, rootdn );
    env.put( Context.SECURITY_CREDENTIALS, rootpass );
    public DatabaseAccessController() {
    try {
    initialContext = new InitialDirContext( env );
    } catch( Exception e ) {
    e.printStackTrace();
    public void store( Storable object ) {   
    try {
    store( object, initialContext );
    } catch( NamingException ne ) {
    ne.printStackTrace();
    private void store( Storable object, DirContext ctx ) throws NamingException{
    DirStateFactory.Result result = DirectoryManager.getStateToBind( object, null, null, env, null );
    Attributes attributes = result.getAttributes();
    DirContext new_ctx = ctx.createSubcontext( dn(object), attributes );
    if( object.hasSubordinates() ) {
    Enumeration subordinates = object.getSubordinates();
    while( subordinates.hasMoreElements() ) {
    try {
    store( (Storable)subordinates.nextElement(), new_ctx );
    } catch( Exception e ) {
    e.printStackTrace();
    private String dn( Storable object ) {
    return "cn="+object.getIdentifier();
    This is an example of how it should work on two objects:
    public class Person implements Storable{
    String name;
    String surname;
    Address address;
    public Person(String n, String sn, Address addr) {
    name = n;
    surname = sn;
    address = addr;
    public boolean hasSubordinates() {
    return true;
    public Enumeration getSubordinates() {
    Hashtable h = new Hashtable();
    h.put("address", address );
    return h.elements();
    public String getIdentifier() {
    return name + " "+ surname;
    public class Address implements Storable {
    String street;
    int number;
    Attributes attrs;
    public Address( String s, int n) {
    street = s;
    number = n;
    public boolean hasSubordinates() {
    return false;
    public Enumeration getSubordinates() {
    return null;
    public String getIdentifier() {
    return street + number;
    And here it is the program that access to the directory:
    public class TestLDAP {
    public TestLDAP() {
    public static void main(String[] args) {
    try {
    System.out.println("Creating controller...");
    DatabaseAccessController controller = new DatabaseAccessController();
    System.out.println("Controller created");
    Person person = new Person("Juan Luis", "Manas", new Address("Street in Madrid", 33 ));
    System.out.println("Storing object in the directory...");
    controller.store(person);
    System.out.println("object stored successfully!");
    } catch( Exception e ) {
    e.printStackTrace();
    }���
    If you find a better way of performing the storage of complex objects in the directory, please, let me know.
    Regards,
    Juan Luis

  • How to use a protected attribute of class cl_gui_alv_grid

    Hello all,
           i have a scenario where i need to use the attribute 'm_appl_events' which is protected attribute. in need to add this event type into my events and add this to registered events.
        when i tried to use this with refrence to class i defined, it showing an error message 'access to protected attribute m_appl_events is not allowed. i already inherieted the cl_gui_alv_grid class into my class
         can any one please tell me how exactly could i use the protected attribute.
    Thanks,
    raju N

    Hi Krishna,
    Protected method or attrubute can be accessed through Inheritence or Friends functionality. So you can inheritence easily in you case . so that you can access the variable in the Inherited sub class only. So you can write 2 methods ie GET or SET ing the value of your protected method.
    I think this informatio may help you.
    Best Regards,
    Vijay

  • Error message when importing data using Import and export wizard

    Getting below error message when importing data using IMPORT and EXPORT WIZARD
    Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    <dir>
    <dir>
    Messages
    Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Could not allocate a new page for database REPORTING' because of insufficient disk space in filegroup 'PRIMARY'.
    Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.".
    (SQL Server Import and Export Wizard)
    Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "Destination - Buyer_.Inputs[Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "Destination
    - Buyer_First_Qtr.Inputs[Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.
    (SQL Server Import and Export Wizard)
    Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "Destination - Buyer" (28) failed with error code 0xC0209029 while processing input "Destination Input" (41). The
    identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information
    about the failure.
    (SQL Server Import and Export Wizard)
    Error 0xc02020c4: Data Flow Task 1: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
    (SQL Server Import and Export Wizard)
    </dir>
    </dir>
    Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on Source - Buyer_First_Qtr returned error code 0xC02020C4.  The component returned a failure code when the pipeline engine called PrimeOutput().
    The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
    (SQL Server Import and Export Wizard)
    Smash126

    Hi Smash126,
    Based on the error message” Could not allocate a new page for database REPORTING' because of insufficient disk space in filegroup 'PRIMARY'. Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting
    autogrowth on for existing files in the filegroup”, we can know that the issue is caused by the there is no sufficient disk space in filegroup 'PRIMARY' for the ‘REPORTING’ database.
    To fix this issue, we can add additional files to the filegroup by add a new file to the PRIMARY filegroup on Files page, or setting Autogrowth on for existing files in the filegroup to increase the necessary space.
    The following document about Add Data or Log Files to a Database is for your reference:
    http://msdn.microsoft.com/en-us/library/ms189253.aspx
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • When I try to use Safari I get an error message that states it can not find server Xn--%20%20-1ia0eb092a

    When I try to use safari I get a message that states can not find server Xn--%20%20-1ia0eb092a

    It sounds like you've got a messed-up homepage. Click the Safari menu, click Preferences, and under "Home page", re-type the page you'd prefer to load when Safari starts (eg "nytimes.com" or whatever). Close preferences and try again.
    Matt

  • When to use prepared statement in java?

    Hi all,
    If we have query like select * from {tablename} (Here tablename is the variable) then will the use of prepared staement improve the performance? My guess is use of statement in this case is a better option rather than prepared statement as the tablename may change for every other query.I think are not useful if tablename changes.They are useful only when the where clause has dynamic values.

    cantor wrote:
    Are you sure that your approach is possible? The next example causes exception for me.
    PreparedStatement ps = conn.prepareStatement("select * from ?");
    ps.setString(1, "TABLE_NAME");
    ps.executeQuery();
    I didn't say that he should solve it in that way. He should create one prepared statement like this "select a, b, c from tablename1" and another prepared statement when he wants to execute "select d, e, f from tablename2"
    >
    And as I understand, this code will not improve perfomance (and even will not work). As I said it can.
    Prepared statements make possible usage compiled queries inside DB. When DB gets prepared statement call, it need to parse it only once. And it can collect some statistic to improve execution plan. But when table name is not specified, this approach will not work.Yes it might. There are database drivers that can cache prepared statements and it's isn't likely that he executes that query on more than e.g. 20 tables?
    The database can also cache compiled statements in a cache.
    Kaj

  • I recently purchase an ipad2.  I also have a mac laptop.  Now, when I facetime call using my iphone to my ipad2 or mac, it states busy.  how can i fix this problem?  I have the same apple id e mail for both ipad2 and mac.  it might be getting confuse now.

    I recently purchase an ipad2.  I also have a mac laptop.  Now, when I facetime call using my iphone to my ipad2 or mac, it states busy.  how can i fix this problem?  I have the same apple id e mail for both ipad2 and mac.  it might be getting confuse now.  I want to be able to face time also using my ipad2 to my laptop especially if one of the members of the family is traveling.  Thanks.

    thanks.  your answer was correct, clearer.  I have another question, maybe you can answer.  I just purchase my ipad2 2 days ago.  yesterday, there was a sound.  today there is no sound.  there is a sound only in movies and you tube and music.  but no sound on all apps and keyboards.  I look it up and seems like ther are few that have this problem.  I called walmart coz I bought it there and they told me that they have not heard that before but if I can't fix it, just return it and exchange it with anew one since I have 14 days to do that.  I tried rebooting it and still won't work.  Should I just restore it?

  • I have a new hard drive as my old one crashed. Everything seemed to transfer fine except for my entire iTunes library. It shows all of my old songs, but when I click on one it states "the song could not be used as the original file could not be found

    I have a new hard drive as my old one crashed. Everything seemed to transfer fine except for my entire iTunes library. It shows all of my old songs, but when I click on one it states "the song could not be used as the original file could not be found.would you like to locate it".
    Either how do I locate it, and I've tried every trick I know, or how do I restore all of my songs from one of two sources. I have my old hard drive backedup on an external drive which should have all of my songs, and I have most of my songs on my old iPhone 3S which I'm using as a backup iPod.

    The "missing file" error happens if the file is no longer where iTunes expects to find it. Possible causes are that you or some third party tool has moved, renamed or deleted the file, one of its parent folders, or the drive it lives on has had a change of drive letter. It is also possible that iTunes has changed from expecting the files to be in the pre-iTunes 9 layout to post-iTunes 9 layout, or vice-versa, and so is looking in slightly the wrong place. In the case of a library moved from one system to another there are also potential permissions issues. See Repair security permissions for iTunes for Windows.
    Select a track with an exclamation mark, use Ctrl-I to Get Info, then click No when asked to try to locate the track. (Due to a bug in iTunes 12 you currently have to say No twice!) Look on the summary tab for the location that iTunes thinks the file should be. Now take a look around your hard drive(s). Hopefully you can locate the track in question. If a section of your library has simply been moved, a folder renamed, or a drive letter has changed, it should be possible to reverse the actions. If the difference between the two paths is an additional Music folder in one path then this is a layout issue. I can explain further if that is the case.
    In some cases iTunes may be able to repair itself if you go through the same steps with Get Info but this time click Locate and browse to the lost track. It may then offer to attempt to automatically fix other broken links.
    If another application like Windows Media Player has moved/renamed the files then the chances are that subtle differences in naming strategies will make it hard to restore the media to the precise path that iTunes is expecting. In such cases, as long as the missing files can be found somewhere, you should be able to use my FindTracks script to reconnect them to iTunes. See this post for an explanation of how it works.
    See also Recover your iTunes library from your iPod or iOS device.
    tt2

  • After importing images from my card using LR 5.4, the GPS data does not show in the metadata panel. However, when I look at the imported images using Bridge, the GPS data is visible. Anybody know why LR is not seeing the GPS data? Camera is Canon 6D.

    After importing images from my card using LR 5.4, the GPS data does not show in the metadata panel. However, when I look at the imported images using Bridge, the GPS data is visible. Anybody know why LR is not seeing the GPS data? Camera is Canon 6D.

    Ok, the issue seem to be solved. The problem was this:
    The many hundred files (raw and xmp per image) have been downloaded by ftp in no specific order. Means - a couple of files in the download queue - both raw and xmps. Most of the time, the small xmp files have been finished loading first and hence the "last change date" of these xmp files was OLDER than the "last change date" of the raw file - Lightroom then seem to ignore the existence of the xmp file and does not read it during import.(a minute is enough to run into the problem)
    By simply using the ftp client in a way that all large raw files get downloaded first followed by the xmp files, we achieved that all "last changed dates" of the xmp files are NEWER than the related raw files. (at least not older)
    And then LR is reading them and all metadata information has been set / read correctly.
    So this is solved.

  • Why does my hard drive state I have used 500 gb when I have only used 280 gb?

    Why does my hard drive state I have used 500 gb when I have only used approximately 280 gb?

    Have you emptied your trash lately...
    Also... See these links...
    Apple ML = Increase Disc Space
    http://support.apple.com/kb/PH10677
    See Here  >  Where did my Disk Space go?
    And Here  >  The Storage Display

  • When to use import and export directives?

    I'm very confused about what the import and export language extensions do and when one should use them.
    I have a Bridge application with multiple source files. As long as I don't call code in another file from the startup execution path (before all source files are loaded) and only call across modules after Bridge is running (e.g. from events in Bridge), I don't seem to need import and export. All source files seem to be in the same namespace and all can see each other's global objects/functions.
    So, when would someone use import or export? And, what is the #engine that the manual discusses in relation to import and export? If some of my source files are library files that I intend to be used by multiple different files/applications, should I be using import/export for that use? Or is this only applicable when there are somehow multiple JavaScript engines involved? And when would that situation arise?
    --John

    John,
    The import and export directives don't really matter in Bridge. All scripts execute in the same namespace. That's why namespacing your scripts is crucial in Bridge.
    The #engine directive creates another JavaScript engine instance containing the script with the directive. If you then wanted to use stuff from that engine, the import and export directives would be needed. But even with that, in Bridge, the main engine will contain the script. There will just be a second engine (you can see this in the ESTK) containing the same stuff. Since it's in the main engine, there's no point in using the import and export.
    Some of the other apps, GoLive, for instance, each script executes in its own engine and namespace. And import and export are needed.
    This could change in future versions, and if it does, we'll be certain to make sure everyone knows about it.
    Bob

  • Using case statement in merge when matched

    Hi,
    I want to use case statement in the when matched clause of merge statement to ensure that I update only those fields that are undated.
    create table TEST1
    NAME1 VARCHAR2(25),
    NAME2 VARCHAR2(25),
    ID NUMBER not null
    create table TEST2
    ID NUMBER not null,
    ID2 NUMBER not null,
    NAME1 VARCHAR2(25),
    NAME2 VARCHAR2(25)
    merge into test1 t1
    using
    test2 t2
    ON (t1.id = t2.id)
    when matched
    then
    case
    when t1.name1 != t2.name1
    then
    update set t1.name1 != t2.name1
    when t1.name2 != t2.name2
    then
    update set t1.name2 != t2.name2
    else
    null;
    end
    it does not work and raises invalid sql command. Any idea how can I do that?
    Thanks.
    Sajid
    Edited by: 808255 on Nov 12, 2010 4:22 AM

    Hi
    In that case you would have to use multiple statements and you may as well just use UPDATE instead of MERGE. Also, are you sure that you aren't trying to to fix a problem that doesn't actually exist.
    Think about where the execution time is going to come from...
    I would be tempted to do 1 UPDATE like this...
       UPDATE test1 t1
       SET    (t1.name1,
               t1.name2) = (SELECT  t2.name1,
                                    t2.name2
                            FROM    test2 t2
                            WHERE  t1.id = t2.id
                            AND   (t1.name1 != t2.name1
                             OR    t1.name2 != t2.name2))If you get specific performance issue with this, then post an explain plan and trace and I'll have a look.
    I don't this the cost of the update is going to be as great as you think.
    Cheers
    Ben

  • Error when I import classes using directive JSP page

    Hi all!
    I have installed JDeveloper 11g (11.1.1.3.0)
    My applications are located in the C:\dir (JDEV_USER_DIR = C:\dir)
    I Created application "Appliation1". In it i created 2 projects (Project1, in it beans session entity and other java classes; Project2, in it JSP).
    I want import classes from Project1 to Project2 using next directive:
    <%@ page contentType="text/html;charset=windows-1252"
    import="project1.*"%>
    so in Project properties of Project2 set the way to classes in Project1.
    When i run JSP an error occurred:
    Error(4,9): The import project1 cannot be resolved
    Maybe i'm not set correctly the way to the classes
    Thanks in advance.

    angelr, thanks, it helped me)
    In jdeveloper 10g i set address in Project Properties->Libraries and Classpath->Add JAR/Directory;
    and set the way to my classes;
    and it worked.
    in the 11 version seems different

Maybe you are looking for