Undefined Constructor for Polygon

Hello,
I have a undefined constructor error message for polygon in Eclipse and I cannot figure out why.
Initially I have this method and everything worked fine; public void drawing (Graphics g, List <int []> x_Points, List <int []>y_Points) {
          Graphics2D g2d = (Graphics2D) g;
          g2d.setColor(Color.blue);
          g2d.setStroke(new BasicStroke(1F));
          ArrayList<Polygon> list = new ArrayList<Polygon>();
           for( int p = 0; p < x_Points.size(); p++) {
               list.add(new Polygon(x_Points.get(p),y_Points.get(p),x_Points.get(p).length));
                }During the course of writing other methods, I found out that using List<List<Integer>> will be better than List<int []>, so I decided to modify the code above to:public void drawings(Graphics g, List <List<Integer>> x_Points, List <List<Integer>>y_Points) {
          Graphics2D g2d = (Graphics2D) g;
          g2d.setColor(Color.blue);
          g2d.setStroke(new BasicStroke(IF));
          ArrayList<Polygon> list = new ArrayList<Polygon>();
           for( int p = 0; p < x_Points.size(); p++) {
               list.add(new Polygon(x_Points.get(p),y_Points.get(p),x_Points.get(p).size()));
                } But I got this Error; The constructor Polygon(List<Integer>, List<Integer>, int) is undefined
Thanks,
Jona_T

The polygon constructor you are using accepts arrays of ints, not Lists. I think it will work if you change it to:
list.add(new Polygon(x_Points.get(p).toArray(new Integer[0]),y_Points.get(p).toArray(new Integer[0]),x_Points.get(p).size()));toArray converts the list to an array, which is what the Polygon constructor accepts, and the argument of an Integer array tells it to make an array of Integers instead of an array of Objects.

Similar Messages

  • Can I define a constructor for a Custom Component?

    I have a custom component which I instantiate through ActionScript.  For the sake of clean code, I would like to be able to assign the variables through the constructor like any other class:
    var myComp:CustomComponent = new CustomComponent(arg1, arg2, ...);
    However, when I try to write a constructor in the Script block for the component, it gives me a compile error telling me that I have multiple constructors:
    //In Script tag//
    public function CustomeComponent(arg1, arg2 ...):void { ... }
    Are we not able to define constructors for Custom Components?

    If this post helps, please mark it as such.
    If you create an array variable in your MXML component, and then set it with myVar="[val1, val2, val3]" in the opening tag of your component, then you basically have a constructor in MXML.
    You can use the [Bindable] metadata tag in three places:
    Before a public class definition.
    The [Bindable] metadata tag makes usable as the source of a binding expression all public properties that you defined as variables, and all public properties that are defined by using both a setter and a getter method. In this case, [Bindable] takes no parameters, as the following example shows:
    [Bindable]
    public class TextAreaFontControl extends TextArea {}
    The Flex compiler automatically generates an event named propertyChange, of type PropertyChangeEvent, for all public properties so that the properties can be used as the source of a data binding expression.
    If the property value remains the same on a write, Flex does not dispatch the event or update the property, where not the same translates to the following test:
    (oldValue !== value)
    That means if a property contains a reference to an object, and that reference is modified to reference a different but equivalent object, the binding is triggered. If the property is not modified, but the object that it points to changes internally, the binding is not triggered.
    Note: When you use the [Bindable] metadata tag before a public class definition, it only applies to public properties; it does not apply to private or protected properties, or to properties defined in any other namespace. You must insert the [Bindable] metadata tag before a nonpublic property to make it usable as the source for a data binding expression.
    Before a public, protected, or private property defined as a variable to make that specific property support binding.
    The tag can have the following forms:
    [Bindable]
    public var foo:String;
    The Flex compiler automatically generates an event named propertyChange, of type PropertyChangeEvent, for the property. If the property value remains the same on a write, Flex does not dispatch the event or update the property.
    You can also specify the event name, as the following example shows:
    [Bindable(event="fooChanged")]
    public var foo:String;
    In this case, you are responsible for generating and dispatching the event, typically as part of some other method of your class. You can specify a [Bindable] tag that includes the event specification if you want to name the event, even when you already specified the [Bindable] tag at the class level.
    Before a public, protected, or private property defined by a getter or setter method.
    You must define both a setter and a getter method to use the [Bindable] tag with the property. If you define just a setter method, you create a write-only property that you cannot use as the source of a data-binding expression. If you define just a getter method, you create a read-only property that you can use as the source of a data-binding expression without inserting the [Bindable] metadata tag. This is similar to the way that you can use a variable, defined by using the const keyword, as the source for a data binding expression.
    The tag can have the following forms:
    As far as binding, you can add the [Bindable] tag before the class declaration to make bindable all public properties defined as variables, and all public properties defined by using both a setter and a getter method.

  • Multiple constructors for BPM Object

    I need to create BPM object which can have more than one (overloaded) constructors.
    Somehow I am not able to find out a way to create new constructor for a BPM object in Studio.
    I guess if I create a Java class and import it in the project, it may work, but I would prefer to create a BPM object rather than java code so that I can easily modify the code as and when required.
    Can someone help?

    Hi,
    Sorry - there's no way to create multiple constructors for a BPM Object (unless as you mentioned - you create an hier from a Java jar file).
    Dan

  • Error compiling "Undefined symbols for architecture armv6:"

    Hey, I seem to be getting errors like this a lot... I only just started making apps yesterday, so they are all still very basic, but I was wondering if I am doing something wrong when I import frameworks?
    This may be caused from something else entirely, but this is what I seem to think is causing it...
    Basically the error I'm getting is:
    Undefined symbols for architecture armv6:
    "_kUTTypeImage", referenced from:
    -[CameraViewController(CameraDelegateMethods) imagePickerController:didFinishPickingMediaWithInfo:] in CameraViewController.o
    -[CameraViewController(CameraDelegateMethods) startCameraControllerFromViewController:usingDelegate:] in CameraViewController.o
    "_kUTTypeMovie", referenced from:
    -[CameraViewController(CameraDelegateMethods) imagePickerController:didFinishPickingMediaWithInfo:] in CameraViewController.o
    "_OBJC_CLASS_$_CameraViewController", referenced from:
    objc-class-ref in CameraViewController.o
    l_OBJC_$_CATEGORY_CameraViewController_$_CameraDelegateMethods in CameraViewController.o
    ld: symbol(s) not found for architecture armv6
    collect2: ld returned 1 exit status
    As you can probably tell, I am trying to make a very simple camera app. Most of the code is copied and pasted straight from apple's site.
    If it would help I can put the full source code I have so far on these forums, just let me know.
    Thanks for any help!

    I've got this error while importing a project from XCode 3 to XCode 4
    A simple workaround which has worked for me was :
    1) Start a new project from scratch in XCode 4 using a template... I know, it should be tedious... ;-(
    2) You should change the build settings  « Architectures » of your project (under TARGETS) to compile with « armv6 » instead of the default value which is « Standard (armv7) »
    Double click « Standard (armv7) » in the « Architectures » setting 
    Add « armv6 » in the popup after clicking « + » button in the bottom-left of the popup

  • Multiple constructors for methods

    I have to write a method that takes both ArrayList and array so i'm assuming that i'll need something like multiple constructors for classes but i can't seem to find anything about this anywhere. Is it possible?

    Uhm, then you don't need multiple constructors, just overload your method.
    [http://java.sun.com/docs/books/tutorial/java/javaOO/methods.html]

  • GetTreeLock during constructor for swing components

    I've noticed some dead locks in our application that are showing up in the call to getTreeLock that exists in the constructor for various JComponents. Specifically, the updateUI method winds up calling validateTree.
    I thought it was OK to construct JComponents from any thread, this suggests it is not.
    Has anyone else experienced this?

    It goes like this:
    On win32, thread 0 is our windows message pump. If dispatching one of our messages results in a call from C into Java that constructs a JComponent, we call getTreeLock from thread 0.
    Imagine that at the same time, the awt event disptatch thread is trying to show a frame. Since the awt event dispatch thread is part of our process, when the native implemention of the frame calls SendMessage to show the frame, the call to SendMessage blocks until thread 0 calls GetMessage.
    Since thread 0 is now blocking waiting for synchronized(getTreeLock()) to return and the awt event dispatch thread has the tree lock - fetched while executing the show() method - we are in a dead lock.
    This is not a problem with AWT components, only swing components.
    The stack looks like this:
         at java.awt.Component.getTreeLock(Component.java:811)
         at java.awt.Container.invalidateTree(Container.java:1116)
         at java.awt.Container.setFont(Container.java:1148)
         at javax.swing.JComponent.setFont(JComponent.java:2310)
         at javax.swing.LookAndFeel.installColorsAndFont(LookAndFeel.java:89)
         at javax.swing.plaf.basic.BasicButtonUI.installDefaults(BasicButtonUI.java:124)
         at com.sun.java.swing.plaf.windows.WindowsButtonUI.installDefaults(WindowsButtonUI.java:63)
         at javax.swing.plaf.basic.BasicButtonUI.installUI(BasicButtonUI.java:60)
         at javax.swing.JComponent.setUI(JComponent.java:449)
         at javax.swing.AbstractButton.setUI(AbstractButton.java:1616)
         at javax.swing.JButton.updateUI(JButton.java:119)
         at javax.swing.AbstractButton.init(AbstractButton.java:1952)
         at javax.swing.JButton.<init>(JButton.java:109)
         at javax.swing.JButton.<init>(JButton.java:64)
    It seems like we could simply have the invalidateTree method return early if there is no parent or there are no children or somesuch.
    A work around we've done is to have the updateUI method delegate to the event dispatch thread. This is a drag as we need to subclass all the JComponents and make sure developers use the safe subclass.

  • How to create a constructor for this class?

    Hi everybody!
    I have an applet which loads images from a database.
    i want to draw the images in a textarea, so i wrote an inner class, which extends textarea and overrides the paint method.
    but everytime i try to disply the applet in the browser this happens:
    java.lang.NoClassDefFoundError: WohnungSuchenApplet$Malfl�che
         at java.lang.Class.getDeclaredConstructors0(Native Method)
         at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
         at java.lang.Class.getConstructor0(Class.java:1762)
         at java.lang.Class.newInstance0(Class.java:276)
         at java.lang.Class.newInstance(Class.java:259)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
         at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
         at sun.applet.AppletPanel.run(AppletPanel.java:293)
         at java.lang.Thread.run(Thread.java:536)
    so my class has no own constructor, it just has the paint method overwritten.
    my class looks like this:
    public class Malfl�che extends javax.swing.JTextArea{
    public void paint(Graphics g){
    Color grey=new Color(220,220,220);
    g.drawImage(img,10,10,null);
    how should a constructor for this class look like?
    sorry i am quite new to this, so i really dont have a clue!
    my class does not have any attributes or requires any so it doesnt need a constructor, doesnt it?
    thanks a lot
    tim

    If you have no constructor you cant instanciate (I know i just murdered that spelling) the object.
    Malfl�che thisHereThingie = new Malfl�che()assuming that you want to run that class by itself you will need a main method that has the preceeding code in it. If you are running it from another class you need to instanciate it... but anyway at the very least for a constructor you need.
    public Malfl�che(){

  • [WARNING] skipping exception constructor for java.io.IOException: could not

    Hi,
    this is happening in osb server output:
    [WARNING] skipping exception constructor for java.io.IOException: could not find property corresponding to ctor param 'arg0' on public IOException(java.lang.String,java.lang.Throwable)
    [EarFile] Application File : /opt/Oracle/Middleware/user_projects/domains/tests/sbgen/alsbejbtransport/95105653848417/build/ear/META-INF/application.xml
    [WARNING] skipping exception constructor for java.io.IOException: could not find property corresponding to ctor param 'arg0' on public IOException(java.lang.String,java.lang.Throwable)
    [EarFile] Application File : /opt/Oracle/Middleware/user_projects/domains/tests/sbgen/alsbejbtransport/95109698253471/build/ear/META-INF/application.xmlwhat is this?

    Yeah -- what is that? I have same issue during application (on OSB) import from jar file.

  • "Undefined symbols for architecture"  when building Universal Binaries

    The build I'm doing works fine when specifying either i386 or x86_64 or ppc *by itself*, however whenever I try to combine the archs to make a UB, I get problems building libraries. I'm using an existing makefile system as this needs to be portable across many platforms. Any ideas?
    Here's the output (trying i386 & x86_64):
    gcc -I/Users/Documents/AccurevWorkspace/RDMe-AurigaDevmacosx/include -D_REENTRANT -DOSX_X86 -DNO_TERMCAP -DNOPOSIXMUTEXES -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -DNO_ENCRYPTION -DTASK_DEFN -DNO_ENCRYPTION -c sddlp_util.c -o osx/static/sddlp_util.o
    ar ru osx/librdmeddl9_static.a osx/static/ddlp.o osx/static/ddlalign.o osx/static/ddllex.o osx/static/ddlp_util.o osx/static/ddltable.o osx/static/ddlxref.o osx/static/writejni.o osx/static/sddlp.o osx/static/sddlp_util.o
    ar: creating archive osx/librdmeddl9_static.a
    cp -f /Users/Documents/AccurevWorkspace/RDMe-AurigaDev_macosx/source/tools/ddl/osx/librdmeddl9static.a /Users/Documents/AccurevWorkspace/RDMe-AurigaDevmacosx/lib/osx
    gcc -c -I/Users/Documents/AccurevWorkspace/RDMe-AurigaDevmacosx/include -D_REENTRANT -DOSX_X86 -DNO_TERMCAP -DNOPOSIXMUTEXES -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -DNO_ENCRYPTION -DTASK_DEFN -DNO_ENCRYPTION ddlp_main.c -o osx/static/ddlp_main.o
    gcc -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -o osx/ddlp_static osx/static/ddlp_main.o -L/Users/Documents/AccurevWorkspace/RDMe-AurigaDevmacosx/lib/osx -lrdmeddl9_static -L/Users/Documents/AccurevWorkspace/RDMe-AurigaDevmacosx/lib/osx -lrdmebase9_static -L/Users/Documents/AccurevWorkspace/RDMe-AurigaDevmacosx/lib/osx -lrdmepsp9_static
    ld: warning: in /Users/Documents/AccurevWorkspace/RDMe-AurigaDev_macosx/lib/osx/librdmeddl9static.a, file is not of required architecture
    ld: warning: in /Users/Documents/AccurevWorkspace/RDMe-AurigaDev_macosx/lib/osx/librdmebase9static.a, file is not of required architecture
    ld: warning: in /Users/Documents/AccurevWorkspace/RDMe-AurigaDev_macosx/lib/osx/librdmepsp9static.a, file is not of required architecture
    Undefined symbols for architecture i386:
    "pspinit", referenced from:
    _main in ddlp_main.o
    "pspterm", referenced from:
    _main in ddlp_main.o
    "ddlpmain", referenced from:
    _main in ddlp_main.o
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status
    ld: warning: in /Users/Documents/AccurevWorkspace/RDMe-AurigaDev_macosx/lib/osx/librdmeddl9static.a, file is not of required architecture
    ld: warning: in /Users/Documents/AccurevWorkspace/RDMe-AurigaDev_macosx/lib/osx/librdmebase9static.a, file is not of required architecture
    ld: warning: in /Users/Documents/AccurevWorkspace/RDMe-AurigaDev_macosx/lib/osx/librdmepsp9static.a, file is not of required architecture
    Undefined symbols for architecture x86_64:
    "pspinit", referenced from:
    _main in ddlp_main.o
    "pspterm", referenced from:
    _main in ddlp_main.o
    "ddlpmain", referenced from:
    _main in ddlp_main.o
    ld: symbol(s) not found for architecture x86_64
    collect2: ld returned 1 exit status
    lipo: can't open input file: /var/folders/0H/0H34PYrnF7SXdZBPnDciuU+jA/-Tmp-//cciWTBHk.out (No such file or directory)
    make: * [osx/ddlp_static] Error 1

    OK, solved the problem. AR requires the -s flag when building UBs:
    If you are building for multiple arches then you should pass ar the -s
    flag (as Rainer said) to ar to ensure that the table of contents is
    created. As you can see from the ar sources it calls ranlib -q normally,
    and ranlib -f if it saw the -s flag. Ranlib -q will "Do nothing if a
    universal file would be created." whereas ranlib -f will create the fat
    archive.
    http://www.nabble.com/Why-ar-doesn't-call-ranlib-on-Mac--td22319721.html

  • No-arg constructor for SQJL iterator class

    I'm to use SQLJ with EJB:
    I used SQLJ to define a public DeptRecs:
    #sql public iterator DeptRecs implements java.io.Serializable
    ( int deptNo, String dName, String loc );
    I wish to pass the iterator out of EJB:
    DeptRecs departments = deptEJB.getDepartments();
    As EJB communication is based on object serialization /
    deserialization, it is critical to provide a no-arg constructor
    for all the classes passed. But the SQLJ iterator has only one
    constructor:
    public DeptRecs(sqlj.runtime.profile.RTResultSet resultSet)
    How can I have a no-arg constructor for the iterator class?
    Or if this is a wrong way to have SQLJ work with EJB, could
    anybody tip me the correct structure?

    You may want to look at the following SQLJ demo file:
    sqlj/demo/SubclassIterDemo.sqlj
    This demonstrates the following:
    - a class Emp to hold the values of the rows
    - a subclass EmpColl of the iterator to read the rows into Emp
    objects.
    The EmpColl class has a getEmpVector() method that returns a Java
    vector with Emp objects as elements. Such a vector would be
    serializable and can be passed around. However, you are likely
    not able to pass the original iterator or its EmpColl subclass
    around.

  • Undefined symbols for architecture armv7

    Hello,
    I'm in the process of creating an ANE for an iOS SDK and I'm encountering issues when using the generated ANE in a test project.
    When trying to debug the app on the device via Flash Builder here is the error I'm getting:
    Error occurred while packaging the application:
    Undefined symbols for architecture armv7:
      "_OBJC_CLASS_$_ASIdentifierManager", referenced from:
          objc-class-ref in com.mycompany.MySDKANE.o
    ld: symbol(s) not found for architecture armv7
    Compilation failed while executing : ld64
    It looks like the error is saying that I've not added the AdSupport.framework when packaging my ANE.
    When I look at the ANT script I've implemented I can see that the platform.xml file correctly lists all the iOS frameworks I need.
    Here is an excerpt of my ANT script :
    <!-- Package -->
         <target name="package" description="Create the extension package">
              <exec executable="${flex.sdk}/bin/adt" failonerror="true" dir="../temp">
                   <env key="AIR_SDK_HOME" value="${flex.sdk}"/>
                   <arg value="-package"/>
                   <arg value="-target"/>
                   <arg value="ane"/>
                   <arg value="${name}.ane"/>
                   <arg value="../build/extension.xml"/>
                   <arg line="-swc swc/${name}.swc"/>
                   <arg line="-platform iPhone-ARM -platformoptions ../build/platform.xml -C ios/ ."/>
                   <arg line="-platform iPhone-x86 -platformoptions ../build/platform.xml -C iosSimulator/ ."/>
                   <arg line="-platform default -C default/ ."/>
              </exec>
            <move file="../temp/${name}.ane" todir="../bin"/>
            <delete dir="../temp"/>
        </target>
    and the content of the platform.xml :
    <?xml version="1.0" encoding="utf-8" ?>
    <platform xmlns="http://ns.adobe.com/air/extension/13.0">
         <sdkVersion>7.1</sdkVersion>
         <linkerOptions>
              <option>-ios_version_min 5.1.1</option>
              <option>-framework Accelerate</option>
              <option>-weak_framework AdSupport</option>
              <option>-framework CoreGraphics</option>
              <option>-framework Foundation</option>
              <option>-framework QuartzCore</option>
              <option>-framework Security</option>
              <option>-weak_framework StoreKit</option>
              <option>-framework SystemConfiguration</option>
              <option>-framework UIKit</option>
         </linkerOptions>
    </platform>
    The script runs fine and generates a valide ANE but when I use is in my project I encounter the error above.
    Here is my environment:
    - Flash Builder 4.7
    - AIR SDK 13.0.0.76
    - Xcode 5.1 with iOS 7.1
    Does anyone have an idea on the source of my problem?
    Thank you.

    I have the sam issue with Parse SDK. ANE is generated without errors but project compilation fails with error:
    Undefined symbols for architecture armv7:
      "_OBJC_CLASS_$_PFPush", referenced from:
    My platformoptions.xml is:
    <platform xmlns="http://ns.adobe.com/air/extension/3.5">
      <sdkVersion>6.1</sdkVersion>
        <linkerOptions>
            <option>-ios_version_min 5.0</option>
            <option>-framework Parse</option>
        </linkerOptions>
        <packagedDependencies>
            <packagedDependency>Parse.framework</packagedDependency>
        </packagedDependencies>
    </platform>
    Some help would be greatly appreciated.

  • Error while packaging app for iOS - Undefined symbols for architecture armv7

    First time trying to package an AS3 Air app for development on iOS.
    App works fine on Android and is available on the Google/Amazon store etc. The version I'm trying to package has all references to the ANE I use removed to simplify matters.
    I'm using Flash Builder 4.7, AIR v4.0 and am developing on a Windows 8 PC.
    When using fast packaging no error is thrown but the app just shows a black screen on my test Ipad (v3).
    Using standard packaging I get the following error at 57%:
    Error occurred while packaging the application:
    Undefined symbols for architecture armv7:
      "__Z15abcOP_nullcheckIPN7avmplus6AbcEnvEEvPNS0_9MethodEnvET_", referenced from:
          _abcMethod_builtin_2_2_function public::global21.describeType in AOTBuildOutput-3.o
          _abcMethod_builtin_3_3_function public::global21.describeTraits in AOTBuildOutput-3.o
          _abcMethod_builtin_6_6_function public::global21.describeParams in AOTBuildOutput-3.o
          _abcMethod_builtin_5_5_function public::global21.describeMetadata in AOTBuildOutput-3.o
          _abcMethod_builtin_4_4_function public::global21.finish in AOTBuildOutput-3.o
          _abcMethod_builtin_26_26_function public::Object$._dontEnumPrototype in AOTBuildOutput-3.o
          _abcMethod_builtin_30_30_null ::_init. in AOTBuildOutput-3.o
    ld: symbol(s) not found for architecture armv7
    Compilation failed while executing : ld64
    Any help you can offer would be very welcome.

    Thanks for your reply Nimisha.
    Can you please tell me how to install the AIR 15 beta in such a way that I can easily go back to the AIR 14 release so I may continue to develop builds for release safely. I do not want to release anything built with beta builds for obvious reasons. Thank you.

  • Undefined constructor and model nodes

    Hi all !!
    I have one custom controller SolicitudesViaje for which its internal counterpart InternalSolicitudesViaje.java says: "The constructor SolicitudesViaje(IPrivateSolicitudesViaje) is undefined"
    The code inside the internal class where the problem is shown are the following lines:
    Creates a new instance of this controller.
      public InternalSolicitudesViaje(com.sap.tc.webdynpro.progmodel.gci.IGCICustomController alterEgo) {
        this.wdAlterEgo = alterEgo;
        wdInitContextNode();
        this.delegate =  new SolicitudesViaje((IPrivateSolicitudesViaje) this); //***** This is the line with the problem
    Another related problem is that my custom controller (SolicitudesViaje again) doesn't recognize the model nodes I have in it. But the other nodes are ok.
    I've tried to rebuild the project with no success. Can anyone help??
    Thanks!

    Alejandro,
    Try this.
    1)Close the project in studio
    2)delete gen_wdp folder for this project
    3)open the project
    4)do a "reload+rebuild" of the project.
    That should help.
    Rajit

  • Can you create a "constructor" for movie clips?

    What I'm doing:
    var this_array[counter] = new monster; //monster is a movie clip
    init_monster(); //set's things like .name, .x, .y, etc.
    What I want to do:
    var this_array[counter] = new monster();
    When I add a "monster"  I then call a function to "initialize" all of it's stats.
    Is there a way in the creation of the object, like with a constructor, where it automatilly does it on 1 line?
    I'm teaching myself and am a little stuck on this part.  If I have to create a "monster class" to do what I want just say so.
    Any simple examples or links to simple examples would be great. Thanks in advance.

    Ok so I've made a class Monster, and I have my movie object Red_Monster
    How would I go about creating the variable so it knows it's both?
    The only thing I can think of is linking them together as a .variable of the other.
    Example:
    var this_monster[x] = new Red_Monster();
    this_monster[x].stats = new Monster();
    It just seems a bit slopy, it would be nice to have this_monster know it's both.  Is there a way to do that?
    (added)
    I've gotten Monster to extend MovieClip, and this is working to use it as a movieclip.
    Currently trying to change the image of the movie clip in code to Red_Monster. Is there a way to do that?
    (added)
    Found how to do it, sort of.  Change the class linkage name to Monster instead of Red_Monster.  I just have to make classes for each movie clip.
    (last add, answer for anyone else)
    Ok the answer is to create a Monster class that extends MovieClip.  Then for each color_Monster they all extend Monster, no other code needed inside each class other then the constructor.

  • Use of synchronized in constructor for accessing static SimpleDateFormat

    Just a little confused. I have
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
    in my class. I made dateFormat static final, because its a costly operation that I dont want to do more than once. I access dateFormat in the constructor of my class to format a date. Since SimpleDateFormat is not threadsafe, my understanding is the access has to happen in synchronized block to ensure thread-safety, as follows
    public MyClass (date) {
    synchronized(dateFormat) {
    dateFormat.format(new Date());
    Is that right? I know that constructors dont need to be synchronized because they are object creations, hence cant have multiple threads stepping on one another. But since dateFormat is a static field, doesnt it need to be protected, inspite of the above argument? Would appreciate responses/comments. Thanks

    this constructor constructs a log record and uses the dateformatter to add timestamp to the log. It is executed very frequently. My tests indicate that using a static dateformatter is better performing than using a new formatter per thread. I am including the results below. 'u method' stands for unsynchronized (new formatter for each thread) and 's method' for synchronized (with static formatter)
    run completed, took [ 10] milliseconds to format date, using 'u method' for [ 1] threads
    run completed, took [ 0] milliseconds to format date, using 's' method for [ 1] threads
    run completed, took [ 10] milliseconds to format date, using 'u method' for [ 10] threads
    run completed, took [ 0] milliseconds to format date, using 's' method for [ 10] threads
    run completed, took [ 40] milliseconds to format date, using 'u method' for [ 50] threads
    run completed, took [ 30] milliseconds to format date, using 's' method for [ 50] threads
    run completed, took [ 70] milliseconds to format date, using 'u method' for [ 100] threads
    run completed, took [ 40] milliseconds to format date, using 's' method for [ 100] threads
    run completed, took [ 260] milliseconds to format date, using 'u method' for [ 500] threads
    run completed, took [ 170] milliseconds to format date, using 's' method for [ 500] threads
    run completed, took [ 491] milliseconds to format date, using 'u method' for [ 1000] threads
    run completed, took [ 310] milliseconds to format date, using 's' method for [ 1000] threads
    run completed, took [ 1793] milliseconds to format date, using 'u method' for [ 5000] threads
    run completed, took [ 1472] milliseconds to format date, using 's' method for [ 5000] threads
    run completed, took [ 3164] milliseconds to format date, using 'u method' for [ 10000] threads
    run completed, took [ 2524] milliseconds to format date, using 's' method for [ 10000] threads
    run completed, took [ 14571] milliseconds to format date, using 'u method' for [ 50000] threads
    run completed, took [ 12819] milliseconds to format date, using 's' method for [ 50000] threads
    run completed, took [ 28050] milliseconds to format date, using 'u method' for [ 100000] threads
    run completed, took [ 25107] milliseconds to format date, using 's' method for [ 100000] threads

Maybe you are looking for