Indexing instances of specific class inside MovieClip authored with Flash Pro

Hi there.
I'm writing a class that extends MovieClip and that is linked to the MovieClip Object authored via Flash Pro during development (Father object).
The hierarchy of this MovieClip Object is hidden from me - everything I know is that it may contain instances of other Class that was authored during development and extends MovieClip in the same manner (Son objects).
I have no information regarding names or hierarchical positions of these Son objects inside Father object.
Now the question is: how to get them listed?
So approach I've taken was to implement current events:
public class Son extends MovieClip
     public static const INITIALIZED : String = "son_initialized";
     public function Son ()
          this.dispatchEvent (new Event (INITIALIZED));
public class Father extends MovieClip
     public var son : Vector<Son>;
     public function Father ()
          son = new Vector<Son> ();
          this.addEventListener (Son.INITIALIZED, this.onSonInitialized);
     public function onSonInitialized (event : Event)
          this.son.push (event.target);
Well, this code compiles with no errors whatsoever, but it turns out that onSonInitialized gets never called. I assume that's because children constructors are called ahead of their parent one.
Is there any way to get them listed?
Thanks in advance.

kglad,
I'm trying to get an array of references to Son objects (Son extends MovieClip), randomly located deep inside display list hierarchy of Father object (extends MovieClip too).
The Father movieclip is authorized in Flash Professional and is a black box for me - I can only manipulate Father.as and Son.as.
Since I can't know exactly their pathes and names (i.e. father.child1.child5OfChild1.son32 for example), I decided to make them self-aware, dispatching event during construction time, messaging everybody that this instance of Son exists:
public function Son ()
     this.dispatchEvent (new Event (INITIALIZED));
And then I attached a listener inside Father's constructor:
public function Father ()
     this.addEventListener (Son.INITIALIZED, this.onSonInitialized);
The idea was that this event listener should have been catching all the Sons, located inside Father. But it doesn't work that way - Father's constructor seems to be called after all constructors of its children, so this event listener catches nothing.
I've worked this around by straightforward display list traversing - it works, but doesn't look so elegant. May be there is still a way to make it work through events?

Similar Messages

  • How do i create a single instance of a class inside a servlet ?

    how do i create a single instance of a class inside a servlet ?
    public void doGet(HttpServletRequest request,HttpServletResponseresponse) throws ServletException, IOException {
    // call a class here. this class should create only single instance, //though we know servlet are multithreaded. if, at any time 10 user comes //and access this servlet still there would one and only one instance of //that class.
    How do i make my class ? class is supposed to write some info to text file.

    i have a class MyClass. this class creates a thread.
    i just want to run MyClass only once in my servlet. i am afriad, if there are 10 users access this servlet ,then 10 Myclass instance wouldbe created. i just want to avoid this. i want to make only one instance of this class.
    How do i do ?
    they have this code in the link you provided.
    public class SingletonObject
      private SingletonObject()
        // no code req'd
      public static SingletonObject getSingletonObject()
        if (ref == null)
            // it's ok, we can call this constructor
            ref = new SingletonObject();          
        return ref;
      public Object clone()
         throws CloneNotSupportedException
        throw new CloneNotSupportedException();
        // that'll teach 'em
      private static SingletonObject ref;
    }i see, they are using clone !, i dont need this. do i ? shouldi delete that method ?
    where do i put my thread's run method in this snippet ?

  • Check if there is an instance from specific class

    suppose i have i class with name FrmColor
    and i want to write a program that show this Frame by clicking on a button like this
    import FrmColor;
    import java.awt.Button;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.Frame;
    public class Test extends Frame
         private Button b;
         public static void main(String args[])
              new Test();
         public Test()
              super("Test");
              b = new Button("Show Color");
              b.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        b_aciotnPerformed(evt);
         private void b_actionPerformed(ActionEvent evt)
              if there is an instance of FrmColor then
                   bring FrmColor to Front
              else
                   create an instance from this class
    pleaze Help Me.

    hi,
    what you want is a static int variable called count which is incremented everytime the constructor is called:
    public static int count = 0;In the constructor, have:
    count++;and a static method to return this variable:
    public static int getCount() {
        return count;
    }You can then get this count:
    FrmColor.getCount();This would be implemented in your code as follows:
    private void b_actionPerformed(ActionEvent evt)
    if(FrmColor.getCount() != 0)
        bring FrmColor to Front
    else
        create an instance from this class

  • Draw inside movieclip/graphic with Actionscript

    Hi.
    How I can draw inside movieclip/graphic element with Actionscript?
    If i have example movieclip-element in my project and want to draw a single dot in its coordinate (10,10), how I can do that?
    ty m8s!

    The easiest way to draw inside a movieClip is the graphics class.
    You could do something like:
    this.graphics.lineStyle(1, 0x000000);
    this.graphics.moveTo(10, 10);
    this.graphics.lineTo(11, 11);
    This isn't perfect when drawing pixels, however - it only has methods for lines and shapes(circles, rectangles etc).
    If its important for you to draw a single pixel and accuracy is more important you may want to consider converting your Movieclip to a BitmapData class, which has methods for setting Pixels. Realistically though, if you didn't know about the graphics class, then that'll probably be what you're after.

  • Class Inside MovieClip Giving Runtime Error

    Hey guys.
    I'm trying to place an instance of a movieclip (instance
    name: tehMovieClip) from the library within another movieclip
    (instance name: parentMovieClip) on the stage. tehMovieClip, the
    movieclip going inside another movieclip, belongs to a class called
    CollisonDetection (linkage properties, class:CollisonDetection,
    Base Class: flash.display.MovieClip). When I put tehMovieClip
    inside parentMovieClip, I get this runtime error:
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    If I just place tehMovieClip on the stage by itself, it works
    fine but I need it to be inside parentMovieClip. So what should I
    do?
    Just for your information, CollisonDetection extends the
    project's DocumentClass which extends MovieClip.
    Thanks in advanced!

    Thanks for that buddy.
    quote:
    Originally posted by:
    SwapnilVJ
    Is the movie clip your are placing linked from library to a
    class?
    The movieclip in question (the one I am placing inside
    another movieclip) is linked to a class.
    quote:
    Originally posted by:
    SwapnilVJ
    If yes. Is the Class linked to the movieclip have a
    Constructor method with parameters?
    Well this is my current constructor:
    public function CollisonDetection() {
    playerRefFromCollisonDetection.x = 600;
    Now that you've said that, I deleted that middle line and it
    seemed to work
    quote:
    Originally posted by:
    SwapnilVJ
    If Yes. you found the problem.
    And solution will be to update the class' constructor to have
    no parameters.
    Thanks buddy, but what if I need to have statements inside
    the constructor such as triggering methods/functions inside the
    class?

  • URLClassLoader - loading classes inside of JAR archives

    Hi. I'm trying to load get an instance of a class inside of a JAR file. I have:
              try
                   URLClassLoader urlcl = new URLClassLoader(new URL[] { new URL("file://C:/Documents and Settings/Owner/My Documents/Eclipse Java IDE Work/temp/test.jar") });
                   Applet clientClass = (Applet)urlcl.loadClass("myclass").newInstance();
                   clientClass.setStub(new ClientStub());
              catch(Exception e) { e.printStackTrace(); }Problem is, everytime I try to run it, I get:
    java.lang.ClassNotFoundException: client
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)Any suggestions?
    And yes, I can extract and view the file manually. Thanks.

    new File("C:/Documents and Settings/Owner/My Documents/Eclipse Java IDE Work/temp/test.jar").toURL()?Then I have to conclude the JAR file is wrong. Can you show the relevant part of jar tvf test.jar?

  • How to create the instance of a class and to use this object remotely

    I have to change a standalone program to do it working on a local net.
    the program is prepared for this adjustment, because the only problem for this change came from the use of the database; and, in the application, all the accesses to the database come from only a class that supplies a connection to the database.
    In this way I think that I could have (in a local net) a "server application" that has the database embedded inside it.
    Furthermore, some client applications (running in different computers of the net) could get access to the database through the connection that comes from an instance of the class that, in the "server application", is made to provide the connection to the database.
    I think this could be a good idea...
    But I don't have practice with distributed applications and I would ask some suggestion about the way to realize my modification.
    (in particular how to get and use, in the "client applications", the instance of the class that give the connection to the database from the "server application").
    I would have some help..
    thank in advance
    regards
    tonyMrsangelo.

    tonyMrsangelo wrote:
    I have to change a standalone program to do it working on a local net.
    the program is prepared for this adjustment, because the only problem for this change came from the use of the database; and, in the application, all the accesses to the database come from only a class that supplies a connection to the database.
    In this way I think that I could have (in a local net) a "server application" that has the database embedded inside it.
    Furthermore, some client applications (running in different computers of the net) could get access to the database through the connection that comes from an instance of the class that, in the "server application", is made to provide the connection to the database.
    I think this could be a good idea... Which is why JEE and implementations of that exist.
    But I don't have practice with distributed applications and I would ask some suggestion about the way to realize my modification.
    (in particular how to get and use, in the "client applications", the instance of the class that give the connection to the database from the "server application").
    You can't pass a connection from a server to a client. Nothing will do that.
    As suggested you can create a simple RMI server/client set up. Or use a more feature rich (and much more complex) JEE container.
    RMI is simple enough for its own tutorial
    [http://java.sun.com/docs/books/tutorial/rmi/index.html]
    JEE (previously called J2EE) is much more complex and requires books. You can get a brief overlook from the following
    [http://java.sun.com/javaee/]

  • Classes and Movieclips question

    Hey
    I'm just wondering, how do I use/call (say... modify the y
    coordinate) of a MovieClip that is placed on the stage, in a parent
    class of the Document class?

    Fuc*in kglad, I love you man. You ended a week long feud I
    had with flash because I couldn't get this to work. I'm so happy
    about this, it feels so nice to be able to work on my game again
    and suddenly a huge part of flash just made sense.
    I greatly appreciate your help. Thanks mate :).
    For those who may have stumbled across this thread who have
    the same problem (it really isn't a problem, but more of a lack of
    knowledge of something specific), here is what you have to do:
    In my document class I have this function:
    [code]
    public function CallBaseEngine():void {
    helloPerson(player);
    [/code]
    Now in a parent class of the doucment class (meaning that the
    document class "extends" to this class I have this:
    [code]
    public function helloPerson(player):void {
    player.x = 999;
    [/code]
    player being simply the instance name of a movieclip I have
    on the stage.
    So what does this code mean for the n00bies? Well in the
    first block of code I am simply calling a function called
    helloPerson which is located in a parent class, remember children
    can "access" their parents but parents can't "access" their
    children so if I did the same thing but tried to call a function in
    the child class I would get an error saying its not found. However,
    you put "player" in the brackets which means that you want to bring
    the movieclip with an instance name called player through with you
    on your way to call the function helloPerson.
    In the second block of code, I am quite simply modifying
    where the player movieclip is along the x axis, this is to make
    sure that I can access the movieclip called player and the code is
    properly working. Bringing along doesn't mean we create a
    "duplicate" or anything, it basically is bringing along the
    permission to access player.
    Thanks again kglad!

  • How to access var in outter class inside inner class

    I've problem with this, how to access var number1 and number2 at outter class inside inner class? what statement do i have to use to access it ? i tried with " int number1 = Kalkulator1.this.number1; " but there no value at class option var y when the program was running...
    import java.io.*;
    public class Kalkulator1{
    int number1,number2,x;
    /* The short way to create instance object for input console*/
    private static BufferedReader stdin =
    new BufferedReader( new InputStreamReader( System.in ) );
    public static void main(String[] args)throws IOException {
    System.out.println("---------------------------------------");
    System.out.println("Kalkulator Sayur by Cumi ");
    System.out.println("---------------------------------------");
    System.out.println("Tentukan jenis operasi bilangan [0-4] ");
    System.out.println(" 1. Penjumlahan ");
    System.out.println(" 2. Pengurangan ");
    System.out.println(" 3. Perkalian ");
    System.out.println(" 4. Pembagian ");
    System.out.println("---------------------------------------");
    System.out.print(" Masukan jenis operasi : ");
    String ops = stdin.readLine();
         int numberops = Integer.parseInt( ops );
    System.out.print("Masukan Bilangan ke-1 : ");
    String input1 = stdin.readLine();
    int number1 = Integer.parseInt( input1 );
    System.out.print("Masukan Bilangan ke-2 : ");
    String input2 = stdin.readLine();
    int number2 = Integer.parseInt( input2 );     
         Kalkulator1 op = new Kalkulator1();
    Kalkulator1.option b = op.new option();
         b.pilihan(numberops);
    System.out.println("Bilangan yang dimasukkan adalah = " + number1 +" dan "+ number2 );
    class option{
    int x,y;
         int number1 = Kalkulator1.this.number1;
         int number2 = Kalkulator1.this.number2;
    void pilihan(int x) {
    if (x == 1)
    {System.out.println("Operasi yang digunakan adalah Penjumlahan");
            int y = (number1+number2);
            System.out.println("Hasil dari operasi adalah = " + y);}
    else
    {if (x == 2) {System.out.println("Operasi yang digunakan adalah Pengurangan");
             int y = (number1-number2);
             System.out.println("Hasil dari operasi adalah = " + y);}
    else
    {if (x == 3) {System.out.println("Operasi yang digunakan adalah Perkalian");
             int y = (number1*number2);
             System.out.println("Hasil dari operasi adalah = " + y);}
    else
    {if (x == 4) {System.out.println("Operasi yang digunakan adalah Pembagian ");
             int y = (number1/number2);
             System.out.println("Hasil dari operasi adalah =" + y);}
    else {System.out.println( "Operasi yang digunakan adalah Pembagian ");
    }

    Delete the variables number1 and number2 from your inner class. Your inner class can access the variables in the outer class directly. Unless you need the inner and outer class variables to hold different values then you can give them different names.
    In future place code tags around your code to make it retain formatting. Highlight code and click code button.

  • Create multiple instances of same class but with unique names

    Hi,
    I'm creating an IM application in Java.
    So far I can click on a user and create a chat session, using my chatWindow class. But this means I can only create one chatWindow class, called 'chat'. How can I get the application to dynamically make new instances of this class with unique names, for examples chatWindowUser1, chatWindowUser2.
    Below is some code utlising the Openfire Smack API but hopefully the principle is the clear.
        private void chatButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
            int selectedUserIndex = rosterList.getSelectedIndex();
            String selectedUser = rostAry[selectedUserIndex].getUser();
            System.out.println("Chat with: " + selectedUser);
            if (chatBox == null) {
                JFrame mainFrame = CommsTestApp.getApplication().getMainFrame();
                chatBox = new CommsTestChatBox(mainFrame,conn,selectedUser);
                chatBox.setLocationRelativeTo(mainFrame);
            CommsTestApp.getApplication().show(chatBox);
    }  

    yes, an array would work fine, just realize that by using an array, you're setting an upper bound on the number of windows you can have open.
    As for unique names, if you mean unique variable name, you don't need one. The array index serves to uniquely identify each instance. If you mean unique title for the window, set that however you want (username, index in array, randomly generated string, etc.). It's just a property of the window object.

  • JSF Table StyleClass issue for a specific Field inside the Table

    Hi There,
    Am having an issue of dynamically setting the styleClass for a specific field inside a DataTable. Here is how the JSF code is ..
    <h:column>
    <h:panelGrid id="column4" columns="1" cellpadding="0" cellspacing="0">
    <h:inputText id="numberOfApps" value="#{row.submitNumber}" styleClass="#{row.customStyleClass}" maxlength="6" converter="MyNumberConverter" />
    </h:panelGrid>
    </h:column>
    This Table has a specific column which has a input Text Box where user enter's data. This data will be validated in the bean where in after the validation if its exceeding a limit we should throw an error message and also highlight the field with a specific styleClass.
    I am setting the StyleClass dynamically based on the User Input, so that I can display a highlited Error Field on the screen. Strangely enough, styleclass is getting set as expected for the first submit but doesnt show any styles for further submits. Even the existing style is getting removed from the second submit onwards. I am setting this "customStleClass" dynamic parameter as a Bean Property. Am sure these values are properly set coz to make sure I have put an h:output tag inside that table to display the customStyleClass values and they are getting set as expected but I see blank value for the class="" in the source of the Page.
    Any help would be appreciated.
    Thanks
    Edited by: Lalith on Jan 14, 2008 10:23 AM

    One option is you find the data element of that field GUID.
    Now go to SE11 transaction and in data type put that data element and press where used list. In that select tables.
    This will give you a list of tables where that field is used.
    But again if there are lots of them it will be difficult to find.
    The only option in that case is debug the extractor and find out.

  • How to create an instance of a class?

    how do you create sn instance of a class, and how do you call a method from another class?

    You may need to read thru the information provided on this page to understand how to create objects: http://java.sun.com/docs/books/tutorial/java/data/objectcreation.html
    I'd also suggest you read the tutorial available at: http://java.sun.com/docs/books/tutorial/java/index.html
    Regarding how you call a method belonging to another class you could do it in the foll. ways depending on whether the method is static or not - a static method may be called using the class name followed by a dot and the static method name while a non-static method would require you to create an instance of the class and then use that instance name followed by a dot and the method name. All said and done i'd still suggest you read thru the complete Java programming tutorial to get a good grounding on all these concepts and fundamentals of the language if you are looking to master the technology.
    Thanks
    John Morrison

  • Creating different instances of one class

    Hi everyone thanks so much for all the help so far! I want to create a new instance of class coauthorship everytime the loop goes around to a new record! However thats not whats happening it only creates 1 instance of coauthorship and it is overwritten with every loop here is Class Coauthorship
    public class Coauthorship {
        private String name, coauthor, title;
        private List titles;
        /** Creates a new instance of Coauthorship */
        public Coauthorship(String name1, String name2, String TITLE){
            name = name1;
            coauthor = name2;
            title = TITLE;
            //List titles = Collections.synchronizedList(new ArrayList(alltitles));
        public String getauthor(){
            return name;
        public void settitle(String TITLE){
            title = TITLE;
        public void setname(String name1){
            name = name1;
       public void setcoauthor( String name2){
            coauthor = name2;
      // public void addTitle(String TITLE){
        //    if(TITLE != null)
        //    titles.add(TITLE);
        public String getcoauthor(){
            return coauthor;
           public String gettitle(){
            return title;
           public int getTitleCount(){
               return titles.size();
             public void printcoauthors(String currentauthor){
             //Extractdata ed = new Extractdata();
            // Coauthorship c = new Coauthorship(ed.getname1(), ed.getname2(), ed.getTITLE());
             if(currentauthor.equals(getauthor()))
                 System.out.println(getcoauthor());
             else if (currentauthor.equals(getcoauthor()))
                 System.out.println(getauthor());
             System.out.println(gettitle());
             System.out.println("Hello is this thing on?");
    }and here is where the values are coming from in Class Extractdata
    //Checks if the document was cowritten
                    if(authors.getLength() > 0)            
                                for(int z = 0; z < authors.getLength(); z++){
                               //Begin with the second author so not to include the author in the list of coauthors
                                        for(int w = 1; w < authors.getLength(); w++){
                                            Coauthorship coauthorship = null;
                                            //Ensures that the author is not counted as a co-author
                                            if(z != w){
                                                name1 = names[z];
                                                name2 = names[w];
                                                Coauthorship c = new Coauthorship(name1, name2, TITLE);
                                                c.setname(name1);                                           
                                                c.setcoauthor(name2);
                                                c.settitle(TITLE);
                                }Thanks so much for everyones help so far

    One thing to remember is that when you write:
    Coauthorship c = new Coauthorship(name1, name2, TITLE);
    Coauthorship c is creating a reference variable that points to an object that is of class type Coauthorship. It is NOT the object itself. It only points to the object in question.
    It is the new Coauthorship(...) that actually creats the object in memory. So each time through the loop you are asking for a new Coauthoriship object and a new reference to that new object. Of course, Java (meaning the JVM) may (or always will - not sure here) re-use the reference variable at the same memory location. You loose the reference to each object create in the previous loop iteration leaving you with a reference pointing to the last object created in the loop when the loop ends.
    If you could state in plain English what your goal is, that would help. From your code, I can tell that the goal (or problem domain) is not clear. Or at least, how to achieve that goal is not clear. State the requirements using ergular words (not psuedo code or such) that would help get things a little clearer.

  • Is running multiple instances of a class ok?

    hi guys,
    is it ok to have more than one instance of a class running?
    I have a console app that processes requests which have been saved in a db. this app does not need multithreading - but sometimes i may need to have multiple instances of the app running :-
    1) when there are too many requests in the db,
    2) or when i want to start another instance of the app to handle only specific duties.
    i mean this:
    i start my app:
    java myApp
    (the app is started once and does not stop for very long - heavy computing involved)
    then when i need another task to compute another task i start another instance (maybe with an option "specificDutyName" :
    java myApp specificDutyName
    Is this ok? no memory issues may arise?

    I think i am not able to follow your problem...
    when i do a java <AppName> <Any arguments/may be nothing>
    in reality I am starting off a JVM.
    If I do java <AppName> <Any arguments/may be nothing> again.... i would be starting of another JVM altogether..
    You may see two java.exe processes running in the task manager.. in case of a windows box.
    In such case if you may want to talk between applications running on two JVM's on the same machine.. you may need to resort to techniques like RMI and such...
    I dont think your requirement is so.. and this should be satisfied with simple multi-threading concepts.. you may start of a deamon thread that would keep on listening to a particular set of inputs.. which triggers of your new code path..
    Hope it makes sense..
    Vaibhav

  • How to synchronize a method for all instances of a class

    Hi,
    How to make a method synchronized for all instances of a class? If a simple method is synchronized, then multiple threads cannot access it at the same time. If we make the method as static, then we are making it synchronized at class level.How to make a synchronized method so that no two instances (objects) of a class can access it at the same?
    Thanks
    Neha

    Neha_Khands wrote:
    There is nothing wrong with that. Actually this question was asked in an interview. They didnt want to create a static method. They told me that synchronization can be achieved at instance level also. and for that we have to call some Class.getInstance().synchronied method inside constructor. Kind of a dumb question. First, synchronization does not occur "at a class level" or "at an instance level." Syncing is always the same--a single object's lock is obtained, which prevents any other threads from obtaining that lock. The only thing that makes it appear that there are special cases is that declaring a method synchronized obtains the lock associated with the instance or with the Class object for that class. But that's just syntactic sugar. The Class object lock is identical to the instance lock, which in turn is identical to a lock on some other arbitrary Object created just to serve as a lock. There's no such things as "locking the class" or "locking the instance."
    Second, and more important, making an instance method synced across all instances is a grotesquely artificial situation, IMHO, and if it were to ever come up, the right way to do it is to have that instance method call a static synchronized method.

Maybe you are looking for

  • Configuring a BT Home Hub to Reduce Disconnections

    Hi, I have had disconnections over the last 2 days while I was playing poker. This has caused me a great deal of inconvenience. I've been in touch with Pokerstars and have sent them log files, and they seem to believe that they have found the issue,

  • Number values not showing up in GUI

    Here is a picture of what is happening, I can change the values such as scale, rotation, postion,  in the viewport, but there are no yellow numbers and I can't change opacity as you can see by the picture.

  • SAP HANA and UI5 documentations

    Hello Experts, I am looking for the right blog, sites or documents where i can download and setup SAP HANA trail edition into the personal system. Also wandering for the appropriate sites, blogs or documents where we can learn the integration of SAPU

  • Syncing Contacts With An iPad 2

    I recently got an I Pad 2 and want to move my contacts, address book etc. with my iMac running OS 10.6.8. Try as I might I have been unable to figure out a way to do it. Any suggestions would be greatly appreciated! Thanks!

  • Splitting of rawmaterial

    Dear All, I am procuring one SFG (material no:1) from vendor directly.  This SFG is contaning (one spring (material no:2) and cover (material no:3) assembly).  For the  production of FG (material no:4) I will consume this as a whole by specifying thi