Confusion of constructor

Hi all

can someone explain to me how is it that you can write that piece of code without any complaint compilator?

var date: Date = new Date();

I checked the documentation for class dates and I found this:

Date (yearOrTimevalue:Object, month:number, date:number = 1, hour:number = 0, minute:number = 0, second:number = 0, millisecond:number = 0)

I did MyDate class with the same constructor, as it is written above, but when I wrote:
var myDate:MyDate = new MyDate() I got an error: Incorrect number of arguments. How is it?

Thank you
pyso

Not quite correct Greg. The fact that the constructor is "native" is the reason why you don't get any errors (which means to be applied in native code elsewhere too where all it takes is defined or past). If you look closely, you'll see that the first 2 settings DO NOT have a default value. In a normal situation, you would be obliged to pass these values in order to instantiate a class (just one write a fake of the class, you will not be able to instantiate without values to parameters that do not have a default value). The class Date is not "a regular class", that is why it can be instantiated without the need to pass 2 parameters that MUST be passed under normal conditioins.

In case he did use inheritance to create the new class, then Yes, the great appeal should work, but this isn't what he says (at least, this is not what I understand by 'I did MyDate class with the same constructor, as it is written above').

Tags: Flex

Similar Questions

  • confusion in the background process and Globaleventlistener

    Hello

    too confused in Backendprocess.

    Please check my code and then tell me how I can do this.

    I want to add bluetooth address in my tree UIApp MyScreen articles and I bluetooth address storage file and record store.

    but confuesd how do I call the showAdress() method after complition of search BlueTooth.

    public class MyUIApp  extends UiApplication{
    
        public static void main(String[] args) {
            if (args != null && args.length > 0 && args[0].equals("gui"))
            {
                AppBackend appb = new AppBackend();
                appb.enterEventDispatcher();
    
            }
            else
            {
                ApplicationManager appMang = ApplicationManager.getApplicationManager();
                if(appMang.inStartup())
                    return;
                MyUIApp app = new MyUIApp();
                UiApplication.getUiApplication().invokeLater(new Runnable() {
    
                    public void run() {
    
                        ApplicationManager.getApplicationManager().postGlobalEvent(AppConstants.DATA_CHANGED);
                    }
                });
    
                app.enterEventDispatcher();
            }
        }
    
        public void showAdress()
        {
            getting data from record store adding Tree which si on Main Screen.
        }
    }
    
    public class AppBackend extends Application implements GlobalEventListener {
    
        public Timer timer;
        public Vector remote_device;
        public Vector device_found;
    
        BTSearch btSearch;
    
        public AppBackend() {
    
            addGlobalEventListener(this);
            timer = null;
    
        }
    
        public void firststart() {
            btSearch = new BTSearch();
            btSearch.start();
        }
    
        class BTSearch extends Thread implementsDiscoveryListener
        {
    
            boolean stopThread = false;
    
            public void run() {
                startThread();
    
            }
    
            public void startThread() {
    
                timer = new Timer();
    
                timer.schedule(new TimerTask() {
    
                    public void run() {
    
                        startScanBluetoothDevices();
    
                }, 30000, 30000);
    
            }
    
            public void startScanBluetoothDevices() {
                try {
    
                    remote_device = new Vector();
                    device_found = new Vector();
    
                    discovery_agent = LocalDevice.getLocalDevice().getDiscoveryAgent();
                    discovery_agent.startInquiry(DiscoveryAgent.GIAC, this);
    
                } catch (Exception error) {
                    Dialog.alert(error.getMessage());
                }
            }
    
            public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)
            {
                //
            }
    
            public void inquiryCompleted(int discType)
            {
                //
            }
    
        }
    
        public void eventOccurred(long arg0, int arg1, int arg2, Object arg3,
                Object arg4) {
    
            if (arg0 == AppConstants.DATA_CHANGED) {
    
                firststart();
    
            }
    
        }
    
    }
    

    I'm confuesd how do I call the method showAdrees() If you desire to process bluetooth backend made.

    Now I'm for names of Bluetooth and the storage in the RecordStore. but now the problem is how can I display on my main screen located in UIApplication.

    I am struggling to read this code, it seems not to be complete.

    Sorry, beginning with the obvious things, I assume you have another entry.  Usually one who has the 'gui' param starts the user interface, so I guess that BlueFreeBackround is the treatment of the user interface.  Seems a strange name?  But any.  We do not have this code, so can't review it.

    The other entrance is the one who starts the initial treatment.  In case you're MyUIApp.  But you have this:

    If (appMang.inStartup ())
    return;
    Also if this is executed at boot time, the treatment does nothing.  And you start an application that seems to be the associated user interface.  I'm confused.  And we have no code to the constructor for this class, so we can not comment on that either.  All we know is that this class sends a global event.  Now, if I'm wrong, I don't think you need to start an Application to send a global event.  It is enough to have one to receive a.

    And you have given us another class, but there is no indication how it is started.  Assuming that it is started, it will receive the global event and execute the firststart() method.  Confusingly, this method will start a Thread that starts a timer.  Why can't firststart() him and save a Thread and some confusion?

    OK, now we come to the TimerTask, which is launched every 30 seconds (seems too often to me, but maybe not).  This process begins the investigation.  And we arrive at the point of this thread.  InquiryCompleted, I think you want to call showAddress().

    It's actually easy, although I really don't like this approach:

    Instead of using

    postGlobalEvent (long guid);

    use

    postGlobalEvent (long guid, int data0, data1, object0 object, Object1 int);

    and pass the MyUIApp object as a parameter object0.  Then, you can call

    . showAddress();

    I suspect that this will throw IllegalStateException, so you'll need to hire a

    this.invokeLater (...)

    to ensure that you have the thread of events when refreshing.

    But if I were you, I would consider this approach.  It seems some unnecessary steps.  For example, why doesn't MyUiApp start the discovery itself, what s at the point of the AppBackend?  A; Otherwise, you use a global event to initiate treatment, you could send the data in another GlobalEvent.

  • Failed to create the reference to the FXMLLoader controller: "no constructor appropriate."

    Greetings,

    I'm in my first two days, experimenting with JavaFX.

    I am trying to create a reference to my controller class to in my routine of starting application. All the posts I've seen on this call to the code as follows:
     FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MyFXML.fxml")); 
    But in my NetBeans IDE editor this code reports the error "no suitable constructor found for FXMLLoader (java.net.URL)."

    The documentation for the FXMLLoader class undeniably a constructor FXMLLoader (java.net.URL). However, when I access the NetBeans source code, this constructor does not show: the only options are FXMLLoader() and FXMLLoader (Charset arg0).

    I use NetBeans 7.1.2 ee version. I was using JavaFX 2.0, then downloaded the SDK 2.2 JavaFX (beta) to see if it would make a difference - she didn't.

    Any ideas would be very appreciated.

    Hello

    My guess would be that NetBeans resumes still jars of JavaFX 2.0 instead of JavaFX 2.2

    I would say that play with the properties of your project: examine the library dependencies and the platform.
    If you use a Default_JavaFX_Platform then check where it picks up JavaFX (click on 'manage the platform' and look in the JavaFX tab).
    Sometimes, NetBeans is confused and will resume the 2.2 SDK with the 2.0 runtime - check if really all paths!

    Hopes this helps,

    -daniel

    Published by: daniel June 13, 2012 06:18

  • Date confusion

    I have two date variables defined as follows:

    private var baseDate: Date = new Date();  April 12, 2010

    private var currentDate:Date = new Date();  April 12, 2010

    During the initialization of the application, I do the following dates:

    currentDate = baseDate;

    currentDate.date = (baseDate.date - baseDate.day);

    What is confusing to me, it's that this end of setting baseDate AND the currentDate at April 11, 2010, where I expect only the currentDate-April 11, 2010.

    I know I can do this:

    currentDate = Nouvelle_date (baseDate.fullYear, baseDate.month, baseDate.date - baseDay.day)

    but there are other areas where I need to put parts of dates based on other dates, and prefer not to create a new Date object each time. I could end up with hundreds of thousands during an interaction between users, and it's not clear to me whether or not they get cleaned up through the process of garbage collection, so I guess this is part 2 of the question, I generally try to avoid new... inside a function, because these things are created and never go away.

    The thing to remember here is that when you use

    currentDate = baseDate
    

    It's a reference assignment. In other work, the Date used to be referenced by currentDate is lost (except if it is referenced by other var), and that after this line of code the currentDate both var and baseDate refer to the exact same object.

    Therefore, once you have done so, any view that make you on currentDate will be baseDate. If you use the Date() constructor new whenever you want to keep two separate instances of Date.

    You can also use it to 'make the copy' of dates:

    currentDate = new Date( baseDate );
    
  • Confused about the extension of the Sprite class

    Howdy-

    I learn programming with object oriented ActionScript and am confused about the class Sprite and OO in general.

    My understanding is that the Sprite class allows you to group a set of objects that you can manipulate all the objects at the same time.

    I explored the Open Flash Chart code and note that the main class extends the Sprite class:

    Base/public class extends Sprite {}

    What this lets you do?

    Also, on a related note, how to draw, say, a line once I extended?

    Without extend Sprite I could write:

    var graphContainer:Sprite = new Sprite();

    var newLine:Graphics = graphContainer.graphics;

    ...

    And it works very well. Once I have extend the Sprite class, I'm lost. How can I modify this code so that it still draws a line? I tried:

    var newLine:Graphics = this.graphics;

    My understanding is that since I extend the Sprite class, I should still be able to call its method chart (or property? I have no idea). But, he screams at me, saying "1046: Type was not found or is not a constant of compilation: graphs.»

    A number of things.

    First of all, I would not use this approach in your table constructor. Setting the width and height only makes sense if you adjust the width and height of the existing content, and the table (Sprite) does not at this time here. If you want to give the table a 'size', you could do it like this:

    public function Chart (width: Number, height: Number) {}
    This.Width = width;
    This.Height = height;
    put in a background invisible to this size:
    this.graphics.beginFill (0,0);
    this.graphics.drawRect (0,0,width,height);
    }

    There are other ways, including putting in a form or a Sprite of child as a child for the background so that clear will not erase the background of the chart. This way you could have properties for the background in your table class and update the background as a child DisplayObject instance... a few ideas to think to...

    Then, after that, your chart should be functional...

    Then back in your scenario, you could do this:

    import graphics. Table;

    Stop()

    var myNewChart:Chart = new Chart (300,200)
    myNewChart.render ();
    addChild (myNewChart)

  • Adding objects to the stage & amp; Properties of the acceessing Stadium - I'm a bit confused...

    Hello

    I'm a bit confused about the programming of the display's two-pronged:

    A. What are the best way to add objects to the stage?
    B. how to access the properties of the step.

    I can make these two when the project is a 'Action Script Project', but I have a problem when it is a "Flex project" (for example a MXML file). See the attached files two questions included in the commentary to see exactly what I mean.


    A. What are the best way to add objects to the stage?
    =====================================

    In a project of action script which extends Sprite I can call him addChild()

    In a project MXML I add objects to the scene first, adding them to a UIComponent, then adding that the step.

    1 - is the best way to do it?

    In this doc: http://livedocs.adobe.com/flex/3/html/help.html?content=05_Display_Programming_02.html he says this quote from
    :
    Each SWF file has an ActionScript class associated with it, called the main class of the SWF file. When Flash Player opens a SWF file in an HTML page, Flash Player calls the constructor function for that class and the instance that is created (which is always a type of display object) is added as a child of the Stage object. The main class of a SWF file always extends the Sprite class
  • Initialization of fields: constructors vs initializers

    I just thought I could do the wrong thing by using initializers to initialize the fields in the constructor instead. Of cause, I want to talk about DPL...
    I am used to do something like this:
    @Persistent
    class Compound
    {
       private final Map<Integer, Integer> elements = new HashMap<Integer, Integer>();
    
       private Compound() {} //dummy private default constructor to be used by BDB
    
       //actual constructor to be used in the code
       public Compound(int initialValue)
       {
         //some specific initialization...
         //e.g.:
         elements.add(initialValue, initialValue);
       } 
    }
    But thinking about what will be the BDB really when demarshaling the instance of the object, I came to the idea that it re - build the plan of the elements and forget the one I create carefully in the initializer of... In order to avoid the useless object instantiation I have to initialize the field in the constructor as follows:
    @Persistent
    class Compound
    {
       private final Map<Integer, Integer> elements;
    
       //dummy private default constructor to be used by BDB
       private Compound()
       {
         //now I have to assign something to elements field because it's final.. 
         // or just remove the *final* modifier???
         elements = null;
       } 
    
       //actual constructor to be used in the code
       public Compound(int initialValue)
       {
         elements = new HashMap<Integer, Integer>()
         //some specific initialization...
         //e.g.:
         elements.add(initialValue, initialValue);
       } 
    }
    So my question is: is there a real difference between the approaches of the first and the second? Or I just thought the wrong way?...

    Hello

    Persistent fields cannot currently be final, since I place them by reflection after the construction of the object. So I'm a bit confused. You set the final fields and it works with I somehow get? You read and a paper trail?

    The second approach is better, without the final to avoid the redundant design of the hash table.

    -mark

  • Confused about the new iPhone to load

    It seems that online, there are many variations on how to charge an iPhone the first times, we don't know what to believe.

    Historically, I charge my iPhone for a day the first time that I get it or after I got a refurb from Apple. My battery life has always been fantastic, representatives of engineering apply even told to say.

    This time, I couldn't wait to load the device as I normally would. I connected my iPhone to my PC, did a restore of backup and wait for the iPhone to be able to load completely (about 30 minutes).

    Given that I had a lot of things happens, I didn't have the opportunity to "condition" of the battery, charge of the day to the next, or as some reports say that I have to load it only via the provided OEM charger (not PC). Some say that your battery die completely and then get away after the phone two hours before recharging.

    All these 'new' information is downright confusing. And yet, I see Apple suggesting as a result a large part of these 'tips '.

    Any thoughts on pricing?

    There is no requirement to 'manage' load.

    Charge at any time, for any period of time.

    You can use the phone while charging.

    Don't deplete the battery at a low level.

    Another that these steps, no more measures need to be taken.

  • How can I register now. new page is confusing and new

    How can I register the new homepage? everything is new and confused! Or how to make the old version?

    can't give you a print screen. the homepage is back of origin available because he has been and is currently showing. only came for 2-3 days if this. did not keep track of the visual output. Thanks for the reply.

  • iCloud-storage upgrade confusion

    I had a confusion about the upgrade of storage iCloud.

    I want to improve my iCloud storage but it says I have to pay each month. Does this mean that my iCloud storage will continue to increase every month?

    Please help me.

    Thank you.

    NO it does not increase each month, there is a subscription, its like a rent.

  • Help! How to downgrade to 40 of Firefox? I need easy steps. I am very confused.

    I tried to downgrade to Firefox 40 41 is disable my important modules. I need to get instructions. I'm so confused. Please help me.

    If your Firefox 41 said that an extension is disabled because it is not signed or verified, there is a parameter so that it can run anyway. Maybe it's not the problem you are having, but I give the info to the case where.

    (1) in a new tab, type or paste Subject: config in the address bar and press enter/return. Click on the button promising to be careful.

    (2) in the search above the list box, type or paste the xpi and make a pause so that the list is filtered

    (3) if the preference xpinstall.signatures.required is in bold and "user set" true, double-click on it to set it to false

  • Confused.  Try to understand the Photo app Syncing iCloud

    Hi, just bought myself an old 5s iPhone which is big for me.

    I have some questions on how the Photos sync app works on my Mac.  I have a Mac mini desktop computer.

    This sharing of photos is incredible, but I am very new to it and get confused what is actually happening.

    I activated the option "Upload automatically to iCloud" on my iPhone but when I look on my desktop Mac that I do not see my most recent photos appear in the folder called 'iPhone' in my desktop version of Photos.  To get my downloaded photos I must actively download them from my phone.

    This folder has appeared after I connected my iPhone to my Mac via the USB cable.  I did this because someone on Facebook said.  This iTunes open for some reason and other things started happening that I don't understand.  I wanted to share pictures, not tunes and he tried to update but the Wi - fi wasn't working at the time so he kept failing.  When I checked the Wi - Fi works on my phone, it updated but iTunes kept trying to update.  Then the iPhone suddenly had all the records that I had done in Photos on my Mac, but the records were all empty.  Yet, all the Photos I had taken on my iPhone that day appeared on my Mac.  Now finally some pictures randomly my Mac on my iPhone as well and I do not understand why.  Then, when I open Facebook on my iPhone, the pictures that I had taken to a family visit appeared there with a musical slideshow!  What is everything?

    How does this work?  It works by sending photos of the invisible iCloud, which means that it requires action by me to make them appear in my desktop?  In this case, this mean I'll have hundreds, maybe thousands of images are circulating in the iCloud I can forget and end up running out of space on my iCloud?  Or do they stay on my phone until I have actively download them on my Mac?  If I turn off the automatic function, will I still be able to send photos to my Mac?

    If I delete a photo on my Mac, it will also disappear from my iPhone (and vice versa)?

    I have a lot of other questions but my poor old brain melting now and I forgot what I was going to ask, so I'll post them later.

    Thank you for your patience.  I'm old (and a bit thick).

    The IVous article explains works iCloud photo library.

    Photfos user / help guide:

    https://help.Apple.com/photos/Mac/1.0/?lang=en

    IVous has a very detailed and well illustrated article on iCloud photo library:

    http://www.IMore.com/how-use-icloud-photo-library-ultimate-guide

  • I just got an iphone and am confused with itunes.  I the have not used in years.  I can I sync my music from itunes to iphone.

    I just got an iphone and am confused with itunes.  I the have not used in years.  I can I sync my music from itunes to iPhone.

    You need a computer that is running the latest iTunes version to either a Mac or Windows operating system.

    Mac

    1. Open iTunes.
    2. In the MenuBar at the top of your computer screen, choose iTunes > check for the updates.
    3. Follow the prompts to install the latest version.

    Windows

    1. Open iTunes.
    2. In the MenuBar at the top of the iTunes window, choose Help > check for updates. Learn what to do If you see not the menu bar.
    3. Follow the prompts to install the latest version.

    Instructions for syncing your iPhone here > synchronize your iPhone, iPad or iPod touch with iTunes on your computer via a USB - Apple Support

  • Confused. I thought that Firefox for iPad is out? I thought I downloaded but it can not find anywhere. If it's on iPad I want to install it now!

    I'm confused as to whether Firefox is now on iPad too. I can't find. I think it's downloaded?... If I want to uninstall now!

    This isn't Mozilla because it's a fake or a shell. The only thing that Mozilla had on itunes is the application Firefox Home as shown.

    Mozilla probably would have made a mobile version of Firefox for iOS for awhile now, if not for the Apple restrictions on what browser and JavaScript engines can be used.

    Mozilla was really a browser experience for iPad in June 2012, called Junior but of course, it does not use the familiar Gecko engine and say of JavaScript engine used by Firefox. From this moment on, is when some websites started popping up who claims to have a version for iPad, however.

    Also https://support.mozilla.org/en-US/kb/is-firefox-available-iphone-or-ipad

  • I created a photo album that contains 60 photos.  Looking at this album in FCPX there are only 30 pictures inside.  First time this has happened... confused...

    I created a photo album that contains 60 photos.  Looking at this album in FCPX there are only 30 pictures inside.  First time this has happened... confused...

    Using iCloud library in Phoyos? If you're perhaps all the photos in your album have not been downloaded in high resolution.

Maybe you are looking for