Question legacy/Casting class

I have two classes that extend the base class:

public class MyBase {}

SerializableAttribute public class MyFirstChild extends MyBase {}

SerializableAttribute public class MySecondChild extends MyBase {}

In one of my components, I'm casting the two classes of children as class base, but at some point, I need to know which instance is referenced (for example, a filter for a Collection function).

Right now I'm treated like this:

var myBase:MyBase; used to store a selected item in a tree

private void filterFunction(item:Object):Boolean
{
If (myBase is myFirstChild)
return (point is called myFirstChild);
else if (myBase is mySecondChild)
return (point is called mySecondChild);

Returns true;
}

It is a simplified version of my code, but, I feel like there should be a better/more simple to do this - something more dynamic and not related to class names (for example, what happens if I add another class which extends from MyBase?).

Any suggestions?

Thank you.

This does not work, but you gave me the idea to try this, which works:

return (getQualifiedClassName (reportHierarchyItem) == getQualifiedClassName (item));

Thank you.

Tags: Flex

Similar Questions

  • Question about cast of more generic class

    I refnum controls and pages refnum and I want to know where is the best:

    (1) let LabVIEW doing work

    or (2) use the 'more generic class type conversion.

    In both cases the VI works fine.

    Thank you

    Jean-Marc

    'that's better... »

    I can't say definatively, but I've generally will do top-cast to build a table that you have illustrated LV.

    EDIT

    I just noticed your case apperas to have 50 more digital cases. What you do with this code? We may be able to offer alternatives (maybe).

    Ben

  • Envy 17 model 17-j102ea SSD Boot question, Legacy Support, BIOS

    Hi, first post ever and excuse if this has been covered - if so, please me directly to pertinent information.

    Bought an Envy 17-j102ea...

    Hardware problems I would like help / advice for, please:

    Legacy support / boot from USB Flash Stick:
    Tried to install Windows 8 via a USB bootable work has confirmed...
    The laptop does not detect except Legacy Support is turned on...
    Once Windows is installed on drive (1 TB 5400 original disc), if I turn OFF then Legacy Support again (as DEFAULT) it starts not from the installed windows now HDD - only when I put Legacy Support back on will it boot.
    Can someone please explain / advise?

    Question SSD:
    Try to use a 240GB vertex 3 SSD Drive...
    Computer laptop wont recognize it- whether it is in Legacy Support mode...
    I've seen a few posts on the compatibility and 240 GB not supported...
    It's for real?

    BIOS:
    This is a complaint, I want something on this topic, please...
    REALLY.
    Why so basic bios options?
    Why can't have two readers in the laptop and choose which start from the first that is alternate between discs easily when I choose?
    For a decent computer ", a poor quality BIOS, it disappoints BIG TIME.
    It should be fairly easy for programmers to HP create a GUI BIOS updated with the best options.

    * I'm a student in computer SCIENCE and make a clean installation on this laptop with no product key, SSD and a very basic BIOS incompatibility sticker, I find it a little boring, and it takes a lot of my time...

    Looking forward to some useful answers.
    Thank you in advance.

    Oh, I didn't know you meant that.

    Update:

    I bought 8.1 Pro student - implemented on a USB stick (the same Corsair Voyager one) - activated UEFI mode...

    It set up perfectly om the 240 GB agility SSD 3!

    On the F9 boot menu option it acknowledged even the USB as UEFI.

    Very happy now :))

    BUT, can you please help me with something else?

    I put the 1 TB HDD in BAY2 5400 original, and it is not recognized at all.

    Any suggestions?

    So, thank you for your help miuch. : )

    ... LAST UPDATED:

    After rebooting the system TWO it recognizes the 1 TB drive! : )

    Thanks again for your help.

    You have been great, and I learned a lot on the way :)

    Best wishes...

  • Question about the class of a card SDHC for a Camileo H10

    Hello
    I have recently purchase a Camileo H10 and I want to know what happened if I use a SDHC class 4 card.
    He decrease the perfomance of the camcoder?

    Than you.

    It depends on the video bandwidth.

    Class 4 = 4 MB/s minimum.

    If the video stream is greater than 4 Mbps, there may be a performance issue.

  • Legacy and Class.getConstructor

    Hello Java community.

    I use Class.getConstructor because I don't know what case I need until execution.

    I have a class A with an A (Type1) constructor. Type2 extends Type1. Now, when I call A (Type2), the compiler I have actually been calling the constructor has (Type1) because there is no such thing as A (Type2). However, when I call A.class.getConstructor (Type2.class), I get a runtime error saying that manufacturer that there is no such thing as a (type2). I can understand why this is happening, but I still want to provide a parameter of a subtype, and so that the runtime required manufacturer intuit...

    I don't really know what kind of Builder, I need running (the call simplified to getConstructor above is only to indicate what is happening in my code) and I do not know if, for example, I will be instantiated an object of a subclass of A, or by using a setting of a subclass of Type1 (Type2, say, in the example). How to do a similar thing to arrive on time as this happens at the time of the compilation of performance?

    Thanks for the help,

    Owen.

    Why my answer, marked by the correct OP, was eliminated from this thread?

    I'm not going to type it in again, but it seems also here: http://stackoverflow.com/a/24772118/207421

  • Question of casting translates to error #1009...

    Hello

    I'm having a problem of casting I'm hoping to solve. I have 2 tables:

    1 table = parent of the clip that I am trying to target

    2nd table = the clip I'm trying to target

    When I trace the results, I see the clip and the parent of the element, they exist on the stage and are qualified. When I try to get the element by its name in part 3, I get an error #1009.

    Can someone make a preview of what I am doing wrong, or suggest a better way to do what I'm doing?

    Much appreciation,

    ~ Chipleh

    for (var i:Number = 0;i<hitTargetArray.length;i++)
    {
       //1st array
       var hitClipParent:Object = Object(hitTargetParentArray[i]);
       trace("hitClipParent = "+ hitClipParent.name); //hitClipParent = colClip0
       trace(getQualifiedSuperclassName(hitClipParent)) //flash.display::MovieClip
    
       //2nd array
       var hitClip:Object = Object(hitTargetArray[i]);
       trace("hitClip = "+ hitClip.name); //hitClip = hitTarget0
       trace(getQualifiedSuperclassName(hitClip)) //flash.display::MovieClip
    
    
       //Part 3
       var hitTarget:Object = hitClipParent.getChildByName(hitClip);
       trace("hitTarget = "+ hitTarget.name);//TypeError: Error #1009: Cannot access a property or method of a null object reference.
       trace(getQualifiedSuperclassName(hitTarget))
    }
    
    

    in part 3 you must use hitClip.name if you don't see why you do not use Sakurakiss9131 directly:

      var hitTarget:Object = hitClipParent.getChildByName(hitClip.name);

    and now hitTarget is a reference FRO Sakurakiss9131

  • ByteArray casting class

    Hey guys,.

    I have a utility class which shuts down at startup and load all of my image property and stores its bytearray data in a cache, I wrote.  I can then access any image I want by name at any time.  It works very well for what I used it for that day, with the exception of the tree component icon.  The icon function expects to return a type 'Class' and I have my data as a type "ByteArray".  Normally I would use data bytearray property 'source' to an element of the image, but it doesn't work here.

    How can I convert my bytearray into a type of class?  Normally, you would use an embed, but I already got the data I need.

    There is no practical way to do it.  I would like to make a custom converter that can

    Manage your bytearray.

  • question about custom classes

    I am new to AS3, as well as Flash in general, so forgive me if this seems very basic.  All I'm trying to do is create a custom class that extends the MovieClip class and contains a custom property for 'marker '.  I want to be able to use and change the value of the custom property on the timeline of an instance of this class and have it behave exactly like any other (Ex: this.x == > this.marker).

    Then, my main script, I want to launch certain circumstances according to the value of 'marker '.

    EXAMPLE: if (myCustomClassInstance.marker == 'string')

    {

    doSomething();

    }

    In any case, I checked my classpath and my extenal AS file communicates with my FLA; I know that the problem lies in my custom class, I've pasted below:

    package myClasses
    {
    import flash.display.MovieClip;

    SerializableAttribute public class extends MovieClip PageClass
    {
    public var marker: String;

    public void PageClass()
    {
    }
    }
    }

    I would be extremely grateful for any help.  Sorry for my ignorance.

    I may be forgetting the scenario, but I think that my discussion of event expedition was addressing the wrong event.  If I remember correctly, the buttons of your main timeline would generate menu of wedge activities.  Your sections would be enough to release a 'allowMenu' event when they settle in their display frame.

    I'm going on memory here (too lazy to look back), but I think I mentioned that you can use as a conditional currentLabel property to prohibit the use of a button while you are in the section.  And if you use AS3 and real SimpleButton symbols (aka buttons homemade), AS3 allows you to control the States of the buttons, which means that you can assign btn.upState = btn.downState to have the button appears in its inactive state when it is to the top/intact. Previous versions of actionscript has failed to do this.  You don't end up having to do a bit of juggling to make things that whenever a new item is selected, a single shared function can do this for all, function sense resets all buttons to the upState = condition out of town, before to set the newly selected on his downState.

  • Question of the main application class

    Hey people out there!

    A happy Friday to all just a quick question. The class that contains the main Sub public static in the BlackBerry application method, this class should be one that extends UiApplication or can the main method call the class that is responsible for this?

    Thank you!

    Schalk

    You can try something like that.

    class Test
    {
        public static void main(String args[])
        {
            Xyz xyz = new Xyz();
            xyz.enterEventDispatcher();
        }
    }
    ---------------------
    
    class Xyz extends UiApplication
    {
        Xyz()
        {
            pushScreen(new MainScreen());
        }
    }
    
  • Having the Type Cast issues with FY 2011

    Hi all

    Just to start 2011 with AF in labview and ran through a few examples and I had a pretty good understanding of the functioning of thought.  Ive tried to do a simple on my own now and get error 1448 whenever I launch the joint project.  Basically everything I do is by passing a string message between the vi and followed by reading through an event in the kernel.  Must be failry simple.  IM almost think it of a bug because earlier in the project, I received an error when you try to create a do.vi to override, close the project and reopened, and could then create it.  I see the error in the do.vi of terminal request msg and this typecast should work because I'm down cast class of the actor in senior actor class that inherits from the actor.

    Thanks for any help.

    You must send the right message to the right actor.

    Your message Msg Resquest Terminal cannot send the actor Terminal or a child of the class.

    But in the method of configuration series Port.vi of the actor from Terminal, you send this message to its caller.

    In your program, the appellant of the actor of Terminal is the actor of Diagnostics.

    (The appellant is the one who launched the actor, and as actor of Diagnostics Launches the actor Terminal, the Diagnostics is the appellant for the actor to Terminal)

    What you want to happen in the Port.vi series set?

    You've only made a message for the Diagnostics actor who is will receive, the Terminal result Msg.

  • final in the inner class

    I am trying to manually do a drawing similar to this program
    http://JavaFX.com/samples/draw/

    However, I'm running in final questions and internal classes.

    "size of a local variable is accessible from the inner class; must be declared final.

    He wants me to do either in SIZE or full size. However, once final, I can't change the variable.

    I have often used the variable in a loop for to assign a value (although perhaps it was a bad practice?) but I don't know the best way to handle this.

    Any suggestions?
    Thank you!


    int SIZE = 1; //somewhere else
    ...
            for( int size = 0 ; size < 5 ; size++){
                  Circle circle = new Circle(D/Padding);
                  
                  circle.setOnMousePressed(new EventHandler<MouseEvent>(){
                      public void handle(MouseEvent me){
                          SIZE = size;
                      }
                  }
             );
    Edit:
    I'm well aware that's not necessarily something specific to javafx, but more a general java programming failure.
    I also know that the mouseadapter is an anonymous class and can only access the final.

    I'm just looking for some suggestions on how to better fit this.

    Published by: namrog on July 5, 2011 10:51

    Published by: namrog on July 5, 2011 10:59
    int SIZE = 1; //somewhere else
    ...
            for( int size = 0 ; size < 5 ; size++){
                  final int size1 = size;
                  Circle circle = new Circle(D/Padding);
    
                  circle.setOnMousePressed(new EventHandler(){
                      public void handle(MouseEvent me){
                          SIZE = size1;
                      }
                  }
             );
    

    And Yes, it is a question of Java, not specific to JavaFX.
    http://Java.Sun.com/docs/books/JLS/third_edition/HTML/classes.html#247496

    DB

  • [Need help] Command execution error: null java.lang.ClassCastException - HQAPI

    Hello

    I need your support on the following error, I got from hqapi when I try to «./hqapi.sh alertdefinition sync. My order is:

    # cat ad10100.xml

    <? XML version = "1.0" encoding = "UTF-8" standalone = "yes"? >
    < AlertDefinitionResponse >
    Success of < status > < / status >
    < AlertDefinition mtime = ctime "1331204852666" = "1331204068642" id = "10100" name = "Fs [/] ok" description = "Filesystem sotto soglia critica" priority = "2" enabled = "true" active = "true" frequency = "0" count = "0" range = "0" willRecover = "false" notifyFiltered = "false" controlFiltered = "false" >
    < resource id = "10910" name = "/ dev/map/VolGroup00-LogVol00 of HR-client Linux file system mounted on / (local/ext3)" / >
    < AlertCondition required = "true" type = "1" thresholdValue = "50.0" thresholdComparator = "" & lt; "thresholdMetric ="Use %"/ >"
    < AlertAction id = "10101" className="org.hyperic.hq.measurement.action.MetricAlertAction"/ >
    < / AlertDefinition >
    < / AlertDefinitionResponse >

    # cat ad10100.xml | SH hqapi.sh alertdefinition sync

    Command execution error: null
    java.lang.ClassCastException
    at java.lang.Class.cast(Class.java:2990)
    at org.hyperic.hq.hqapi1.XmlUtil.deserialize(XmlUtil.java:64)
    at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.sync(AlertDefinitionCommand.java:439)
    at org.hyperic.hq.hqapi1.tools.AlertDefinitionCommand.handleCommand(AlertDefinitionCommand.java:152)
    at org.hyperic.hq.hqapi1.tools.Shell.dispatchCommand(Shell.java:245)
    at org.hyperic.hq.hqapi1.tools.Shell.main(Shell.java:260)

    I have tested the following workaround but unsuccessfully:

    -try d'utiliser./hqapi.sh instead hqapi.sh sh

    -try to use different java bin (mine is/usr/java/default jdk6_u31), I tried /opt/hyperic/server-4.5.3/jre/bin/

    -Try sh hqapi.sh alertdefinition sync - file = ad10100.xml

    -try to change the XML, removal of State <>success < / status >

    HQAPI version: hqapi1-client - 4.3.0

    Hyperic HQ version: 4.5.3 - GA

    I need to synchronize alertdefinitions based on XML files please help me around this error.

    Thank you very much.

    Claudio

    Trying some updates for automatic alert via the script API definition, I met this problem as well. No matter what I did, it seemed that this class cast exception would be thrown. I downloaded the Github source HQAPI and started searching. I found that the error was in the call to the XmlUtils.deserialize method, which has invoked a JAXBContext to select the class of the object to return, after analysis of the XML. The code that calls the method waits get an object that can be cast to the type AlertDefinitionsResponse, but he returned to an object that must be cast to type AlertDefinitionResponse.

    After a bit of investigation, I realized that JAXB is the context of the node root XML data. Because the root node is AlertDefinitionResponse, he always returned an object of this type, instead of the expected AlertDefinitionsResponse type. Currently, the only way I found to get around this problem is to change the node root to AlertDefinitionsResponse. So, sync-able XML would look like the following, based on XML of the original poster.



         Success
        
            

            
            
        

    I raise a question on the Github repository so that officials are aware of this problem.

    EDIT: The problem has been discussed here

  • Custom component

    Hello.

    I am creating a custom using ActionScript 3 component. This component has properties that can be changed in the components Inspector, and in this aspect, I create a text field to display a message that the user defines in this Panel.

    So far, works well. But I want to give a chance to the user choose a font for the text field type, I found in the definition of the element, an option called 'Font name', with this option, you can select a font type to use.

    The problem is to recover this font in my class of the component. I try to use the class of the police, but it seems that this class is not born for this. My question is: what class should I use to retrieve the selected font in the name of the font option. I have try this:

    var newFont: Font = 'Arial ';

    [Inspectable (name = "Font name", type = police, defaultValue = "Arial")]
    public function set {corPreloader (cast:Font)}
    newFont = cast iron;
    }
    public function get corPreloader (): uint {
    return newFont;
    }

    Thank you

    PS: Sorry for my English

    Inspectable types work a little differently to different types of variables. The inspectable type you are after is "name of the font. You will then type to a variable of type string.

    var newFont:String = "Arial";
    
    [Inspectable(name="Font name", type = "Font Name", defaultValue = "Arial")]
    public function set corPreloader(fonte:String) {
         newFont = fonte;
    }
    public function get corPreloader():String {
         return newFont;
    }
    
  • Removal of the BIOS on Satellite Pro M10

    Hi all

    Just a quick question, havnt cast an eye at the moment, but no one knows if the bios chip can be removed easily from the motherboard M10 or it is welded?

    Thank you. :)

    Hello

    In my opinion it of not possible to easily remove the module Rom BIOS of the motherboard on PC cards.
    I think that it welded s

  • How to fix: Error 1053 of the print spooler

    Are you an error when you try to restart the print spooler?  Do you have your printer spooler error and now, do not restart?

    You saw "error 1053: the service did not demand launch or control in a timely.?

    There is a page of Microsoft support with information about this error, which can be found here.

    According to Microsoft:

    • Question: The ServiceBase class calls the OnStop method directly from the Service command handler that is defined in the ScDispatcherLoop of the Advapi32.dll file. After 30 seconds, if the ScDispatcherLoop thread is not ready to receive a new order of service from service control manager, Windows brand services controller out service as 'time '. Therefore, you receive this error message.
    • Resolution: to resolve this problem, obtain the latest service pack for Microsoft .NET Framework.

    This resolution works for some, and allows the service to return to the correct functionality.  However, I want to provide workaround incase this option does not work for some.

    • Open the run command by selecting it from the start menu or by pressing the Windows key (to the left of the alt) + R
    • Type services.msc and press enter
    • Scroll down and double click on print spooler
    • Select the tab log
    • Uncheck the Allow service to interact with desktop
    • Click apply
    • Select the general tab for the print spooler, and then select start

    I have the confirmation that this workaround works for some users.  The link below will take you to a thread where this information has resolved this error a user in these forums:

    1053 error print spooler does not start thread

    Here is the video where the workaround steps, listed above, were found.  The video also gives a graphical representation of these steps for those who prefer the Visual instructions.

    I hope this helps users with error 1053 of print spooler.

Maybe you are looking for