UIComponent override question

within my custom UIComponent when I want to addchildren, should I always be overriding and using the
protected function createChildren ?
I notice I can use addChild anywhere without overriding the protected createChildren function and it still works.
Should I not be doing this ?
Thanks

It depends on what purpose you are trying to addChild().
If you are doing that initially while creating the component only then it's better to use createChildren() function, but id you are tring to add child for displayng some data, say like list components or so, then try to use updateDisplayList() method.
cause, as far as I know, createChildren() method gets called when the component it self is added to display list, that is only single time, and updateDisplayList() gets called whenever th component needs to get updated.
Hope, this should help u

Similar Messages

  • Extending UIComponent, createChildren question

    All,
    I'm trying to make some simple components.  For the sake of making this exercise very simple, I'm using a callout control from Adobe posted here.
    http://www.adobe.com/devnet/flex/samples/fig_callout/
    The source of that component can be viewed here:
    http://www.adobe.com/devnet/flex/samples/fig_callout/srcview/index.html
    More specifically, I'm looking at the src/AirportCallout.mxml file.
    I'm looking at making a class that extends UIComponent.
    public class AlertWrapper extends UIComponent
            private var callout : Callout;
            public function AlertWrapper(){
                super();
                this.buttonMode = true;
                //this.addEventListener(MouseEvent.CLICK, alertClicked);
                this.graphics.drawCircle(25, 25, 5);
           override protected function createChildren():void{
                super.createChildren();
                this.callout = new Callout();
                this.callout.x = 25
                this.callout.y = 25;
                this.addChild(this.callout);
            override protected function measure():void{
                super.measure();
    This is obviously a very simple example dumbed down for the sake of figuring out what's going on.  I'm drawing a circle at point (25, 25) with a radius of 5.  I'm then trying to place a callout component (something that adobe made and works well) onto this component as a child.
    When I add an instance of the AlertWrapper class to the display list (In the real world situation, I add it to a container using the addChild method), it does not render the callout correctly (it's the wrong size, much smaller than it should be).  I'm stumped trying to figure out why this is.  If I look at the AirportCallout.mxml class, I see that it isn't given a size by default.  If I give it a size of 200, it does render correctly (albeit the wrong size).
    Can anyone shed any light of this?  I'm new to designing my own controls that extend UIComponent.
    Thanks,
    Dan

    public class AlertWrapper extends UIComponent
             private var callout : Callout;
            public function  AlertWrapper(){
                super();
                this.buttonMode =  true;
                //this.addEventListener(MouseEvent.CLICK,  alertClicked);
                this.graphics.drawCircle(25, 25, 5);
            override protected function createChildren():void{
                 super.createChildren();
                this.callout = new Callout();
                 this.callout.x = 25
                this.callout.y = 25;
                 this.addChild(this.callout);
             override protected function measure():void{
                 super.measure();
                this.measuredHeight = this.callout.getExplicitOrMeasuredHeight();
                this.measuredWidth = this.callout.getExplicitOrMeasuredWidth();
    Doing something like this does not render correctly.  It looks cut off like this.
    var alertWrapper : AlertWrapper = new AlertWrapper();
    var canvas : Canvas = new Canvas();
    canvas.addChild(alertWrapper);
    When debugging, the alertWrapper measuredHeight and measuredWidth are set to 35 and 32.
    It looks like this
    If I change the code in alertWrapper and change the createChildren and measure functions to as follows, I can hack my way through it:
    override protected function createChildren():void{
                 super.createChildren();
                this.callout = new Callout();
                 this.callout.x = 25
                this.callout.y = 25;
                //  this.addChild(this.callout);
             override protected function measure():void{
                 super.measure();
                // this.measuredHeight =  this.callout.getExplicitOrMeasuredHeight();
                 // this.measuredWidth =  this.callout.getExplicitOrMeasuredWidth();
    Then, if I add it to my container as such, it renders correctly but I don't understand why.  When I debug with this second method, the measuredWidth and measuredHeight of the alertWrapper are both 0 (which is weird since the circle is being drawn).
    var alertWrapper : AlertWrapper = new AlertWrapper();
    var canvas : Canvas = new Canvas();
    canvas.addChild(alertWrapper);
    canvas.addChild(alertWrapper.callout);
    This second method seems very hacky and I would like to understand what I have to do to make it work so I only have to add the alertWrapper to the container to get it to render correctly.  Please help!

  • Override Question

    this is my code.
    import java.io.*;
    import java.security.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    public class TextEncryptor implements Encryption, Cloneable, Serializable {
         String encryptedFileName;
         String userText;
         boolean successfulEncryptionPerformed = false;
         KeyGenerator kg;
         SecretKey skey;
         SecretKeyFactory skf;
         DESKeySpec dks;
         Cipher c;
         CipherOutputStream cos;
         PrintWriter pw;
         public TextEncryptor(String encryptedFileName, String userText) {
              this.encryptedFileName = encryptedFileName;
              this.userText = userText;
         public void generateSecretKey() {
            try {
              kg = KeyGenerator.getInstance("DES");
              kg.init(new SecureRandom());
              skey = kg.generateKey();
              skf = SecretKeyFactory.getInstance("DES");
            }catch(Exception e) {
              e.printStackTrace();
         public void initialiseCipher() {
            try {
              Class spec = Class.forName("javax.crypto.spec.DESKeySpec");
              dks = (DESKeySpec)skf.getKeySpec(skey, spec);
              c = Cipher.getInstance("DES/CFB8/NoPadding");
              c.init(Cipher.ENCRYPT_MODE, skey);          
            }catch(Exception e) {
              e.printStackTrace();
         public boolean performEncryption() {
            try {
              cos = new CipherOutputStream(new FileOutputStream(encryptedFileName), c);
              pw = new PrintWriter(new OutputStreamWriter(cos));
              pw.println(userText);
              pw.close();
              successfulEncryptionPerformed = true;
            }catch(Exception e) {
              e.printStackTrace();
              return successfulEncryptionPerformed;
         public DESKeySpec getDESKeySpec() {     
              return dks;     
         public Cipher getIV() {
              return c;
         public boolean equals(Object o) {
              if(o == null) {
                   return false;
              TextEncryptor te;
              try {
                   te = (TextEncryptor) o;
              }catch(ClassCastException cce) {
                   return false;
              return (encryptedFileName.equals(te.encryptedFileName)) && (userText.equals(te.userText));
    }My question is since the only two variables that can be set (in th constructor) are encryptedFileName and userText, do i need to override the clone() method, as these two variables are immutable(strings), but what about the other variables, these are always set to the same values in the methods listed above.please help,
    thanks

    My question is since the only two variables that can be set (in th constructor) are encryptedFileName and
    userText, do i need to override the clone() method, as these two variables are immutable(strings), but
    what about the other variables, these are always set to the same values in the methods listed above.please
    help,
    thanksWell, if you implement Cloneable, then you really should implement clone(), otherwise it doesn't make much sense. Even if you do implement it just as
    public Object clone() {
        return super.clone();
    }

  • FORMCALC (or JS) Default date today with user override questions

    I have a date field where if null, I want today to be inserted. If the user overrides the today date and saves the form, I want the user entered date to stay.
    What I have in FORMCALC is:
    if ($.isNull)
    then
    $.rawValue = num2date(date(), DateFmt(2))
    endif
    The first part works, it populates with today, and I can overrided the date. When I save and then reopen the form, the date is "0".
    Any ideas here?

    I'm having the same problem as described above but I am using JavaScript to reflect the current date:
    var msNow = (new Date()).getTime();
    var d1 = new Date(msNow);
    this.rawValue = util.printd("mm/dd/yyyy", d1);
    The user can override the current date and save the form, BUT when the form is reopened it will run again and insert the current date over the user entered date.
    (I've tried several variations of "if (this.isNull)" to the above code which results in "01/00/0000" when opening the saved form --so it still doesn't retain the date entered by the user.)
    Does anyone know what code I need to add to to keep the user entered date that was saved with the form? Or if there is a better way to make the date calendar default to today, allow user override and save that user entered date on the form?

  • UIComponent validator question

    i use flex 3.5 sdk
    i have a textinput and have several validations on it, then i want click a button named "Reset" to reset the textinput content and clear the red border
    i do like this
    textInput.text = "";
    textInput.errorString = "";
    this is wrong, because in UIComponent.as, add two array errorObjectArray and errorArray to control the validatorResult
    so i add a function in UIComponent.as like this
    * reset the errorString
    public function validationResultReset():void
        if (errorObjectArray != null)
            errorObjectArray.splice(0, errorObjectArray.length);
            errorArray.splice(0, errorArray.length);
        errorString = "";
    then change call
    textInput.text = "";
    textInput.validationResultReset();
    i feel this is not a good solution, someone give me a suggestion.
    Thanks a lot

    Thanks for your reply, Johnny
    if use errorString="", the if the validator validate invalid, then it will not show the errorString.
    because is 3.5 sdk, have two array errorObjectArray and errorArray to control the validationResult
    in UIComponent.as validationResultHandler function it will judge the validator is in the errorObjectArray, if exists and the errorMsg not change it will not set the errorString
    so if you do not clear the errorObjectArray and errorArray  when you reset, it will not show the errorString again.
    what is your sdk version used?

  • Button Override Question Encore CS5

    Hey everyone.
    I have added chapter points to a single timeline and then linked these chapter points to corresponding menu buttons. These chapters will be viewed via the Chapter Selection menu.  After a chapter has been watched, I want the user to be returned to the Chapter Selection menu. So, I set the Override for the menu buttons to return to the menu.
    But, this does not work
    SO ...
    How do you create Chapters in a single timeline and have the user return to the Chapter Selection menu once the chapter has been viewed?
    thanks

    I did not look a second time, but if you did what you said, it should work. But overrides can be tricky.
    However, the current two methods most recommended (for DVD, the first does not work on bluray) is
    1) to create a single chapter, chapter playlist for each chapter, with an end action on each chapter playlist to return to the menu.
    or
    2) make each chapter its own asset (from Premiere), and its own timeline. Then each chapter is a timeline (and the timeline end action is to the menu), and you make a playlist (not a chapter playlist) for the play all.
    Their are no overrides and no end actions on chapters.

  • Inheritance/Overriding question

    Morning :)
    Here is my situation. I have the following situation, within the same package
    Class C, with a protected method doStuff(int x), and a public startStuff() method. This startStuff method calls the doStuff method.
    Class IC, which extends C, which also has a separate protected doStuff(int x) method, and a public startStuff() method
    I am instantiating an object of class IC, and calling the startStuff method, which first calls super.startStuff(), which in turn (in my mind) should call the doStuff method within Class C, but it isn't. In the stack trace, I can see Class C.startStuff being called, but when it gets to the doStuff method, it invokes the one in class IC, which isn't what I want.
    Any way for me to fix this, or am I going about it all wrong?

    I think you are talking about something like this :
    public class SuperClass
         protected void doStuff()
              System.out.println("doStuff in SuperClass");
         public void startStuff()
              System.out.println("startStuff in SuperClass");
              doStuff();
    public class SubClass extends SuperClass
         protected void doStuff()
              System.out.println("doStuff in SubClass");
         public void startStuff()
             super.startStuff();
              System.out.println("startStuff in SubClass");
         public static void main(String args[])
              SubClass aSubClass=new SubClass();
              System.out.println("This is main ");
              aSubClass.startStuff();          
    }What is happening here (why doStuff() in SubClass is getting invoked)is as follows:
    We invoke any method on a target reference(i.e.aSubClass.startStuff()),the invoked method has a reference to the target object so that it may refer to the invoking(or target )object during the execution of the program.That reference is represented by this.
    In method overriding the instance method is chosen according to the runtime class of the object referred to by this.So during the execution of statrStuff() in SuperClass , the doStuff() is invoked on the this reference that is the actual run time type of the target object i.e. SubClass.
    That's why doStuff() in SubClass is getting invoked.
    If you want to invoke SuperClass.doStuff(),declare doStuff() as class method (Static) in both the classes.The class methods are not invoked by the runtime class of the object,because these are not related with any instance od a class.

  • Flex component setActualSize

    I am a little confused about the setActualSize method. It appears from what I've read, that if it is not called on a component by its parent, the component will not be rendered.
    So it appears that setActualSize is a critical method that is directly bound to rendering the UIComponent. It also appears that the width and height properties of UIComponent override the functionality of the width and height properties of flash.display.DisplayObject, in that they are not directly bound to the rendering of the object but are virtual values that are mainly used by the getExplicitOrMeasured when the parent of the component calls the component's setActualSize method.
    So the question are:
    1) Why isn't the default behavior of every component to just call setActualSize(getExplicitOrMeasuredWidth(),getExplicitOrMeasuredHeight()) on itself?
    2) I guess this question stems from the above question and the behavior as I understand it as described above: does setActualSize change the visibility of the component?
    It appears that that the behavior is that a component is not rendered until setActualSize is called, but if it contains display object children itself (expected behavior as it can calculate measure on itself) and is added to the display list, the only reason why flash isn't rendering it, is because its not visible.
    3) Relating to question #1, does updateDisplayList of UIComponent have a method that goes through its children calling setActualSize on each of them?

    In Flex, parents size their children.  SetActualSize (or setLayoutBoundsSize) is recommended since it does not set the explicitWidth/Height and therefore prevent the component from responding to new measurements.
    Many parents don’t use getExplicitOrMeasuredWidth/Height because some other layout rule actually dictates the size (like percentWidth/Height or the left/right/top/bottom properties).
    UpdateDisplayList() is where a component should modify any children to set up the display list for that component.  IOW, that’s where the component sizes its children.  But the call can be delegated to a replaceable layout in Spark and a few other places.

  • Web sharing & 403 Firbidden, one more time

    I've read, to varying degrees of understandability, various articles and help files on the 10.5 web sharing issue. I've tried & failed. I've come to the article below, which I think states clearly why web sharing does not work out of the box with 10.5.5. I want to follow the ix it offers, but, as with so many other articles, it talks a level or 2 above my expertise.
    My questions include:
    • How do you "Navigate to the Apache2 user configuration directory"? What does that mean?
    • What is "cd /private/etc/apache2/users"? Is it a file? Is it something you type in Terminal?
    • What it "tee"?
    Questions go on along these lines until the end of the article; in short, is there a how-to for Apache / Terminal beginners. The overriding question is, why hasn't Apple addressed the web sharing snag by the 10.5.5 iteration of the OS?
    FYI I am hung up on web sharing directly due to my move from Palm to iTouch as PDA. With the Palm Zire31 I was able to do light word processing, and did hundreds of paragraphs with it; also as a reader, and reads tens of thousands of articles on it. I want to do the same with the iTouch. To that end I've duly downloaded and installed BookZ and eReader, to enable me to move articles back & forth from the iTouch to my new iMac, to be blocked by the dreaded 403 error.
    After reckoning this problem I hope a 3rd party will come out with a real light WP app like that for the Palm: WordSmith.
    Here's the article-
    Configure Apache Web Sharing for user accounts in Mac OS X 10.5 Leopard:
    http://www.gigoblog.com/2007/11/08/configure-apache-web-sharing-for-user-account s-in-mac-os-x-105-leopard/
    Someone please help me.

    Leopard web sharing works just fine out of the box (well, it does for me anyway), although if you updated from Tiger rather than doing a fresh install (not really a good idea for new OS version), you may get the 403 error. Once turned on, it is as simple (?) as dropping files into your user's Sites folder.
    That article is horrible - I don't know what the heck they are doing using a utility such as tee to edit configuration files. For stuff like this, the free text editor TextWrangler works as well as shell utilities (especially for those not comfortable with them), and it can also navigate to and open those normally hidden files.
    As for Apache, it is industrial strength, so there is a lot of stuff you can do with it (don't ask me, I'm just a duffer). The default websites on your computer (as shown in the System Preferences > Sharing > Web Sharing pane) have links to the documentation on your computer, or you can wander around and find other references such as Apache DevCenter.

  • What folder is the music library stored in?  If all music, why 1 folder?

    When I loaded music from CDs into the Library, or downloaded from the itunes store into that same library:
    1.The overriding question is whether this music is always loaded into 1 file folder, specifically which one is it (\my music or is it \my music\itunes or something else), and why would it be in more than that one folder?
    2. for a backup of my library - why can't I just copy that onto my external harddrive (instead of doing as article 1751 suggests which is to back up the library by consolidating the library to one folder)?
    I'm just trying to understand this.
    Thank You for your help!!!!
    Windows XP

    tom111 wrote:
    When I loaded music from CDs into the Library, or downloaded from the itunes store into that same library:
    1.The overriding question is whether this music is always loaded into 1 file folder, specifically which one is it (\my music or is it \my music\itunes or something else), and why would it be in more than that one folder?
    Unless you have changed something, new rips and iStore purchases go into MyMusic\iTunesFolder\iTunesMusicFolder
    2. for a backup of my library - why can't I just copy that onto my external harddrive (instead of doing as article 1751 suggests which is to back up the library by consolidating the library to one folder)?
    If you are sure all your music is in the folder we just talked about, you can skip the Consolidate step. If you have any music in other folders, due to manual activity, ripping with other programs, etc, then Consolidate will put a copy into the iTunesMusicFolder, which prevents it from getting lost when you move the library.
    I'm just trying to understand this.
    No problem. That is the purpose of this Forum. (-:

  • Need to use DSL vs. Airport but can't connect

    I could not find the answer to this, and I'm sure it's probably an easy fix, but I have tried to connect via my DSL router -- instead of my airport and it won't connect. Large downloads (like movies) can take a while, and HD movies are not smooth-playing, so I wanted to use a direct connection to my DSL router instead of my WiFi/Airport. I disconnected the ethernet cable from my router and put it in my laptop (MacBook Pro 10.6.3), no connection. There is a connection called ethernet in my config). I'm not sure how to set it up otherwise (DHCP??) (think I had help last time) but my overriding question is, shouldn't I be able to go back and forth? I plugged in the ethernet cable and rebooted the laptop, thinking it would automatically recognize it, but it didn't. I didn't see anything else that needed to be hooked up. Am I missing a cable? Do I need to use a firewire from my laptop to the router? Do I need to manually set up the DSL each time I want to use it vs. Airport?
    Thank you!!
    Mary

    This is an excerpt from Snow Leopard Help on how the network preference pane works:
    "You can connect to the Internet or a network in several ways (using a modem, AirPort, or Ethernet, for example). If you have multiple active network port configurations, Mac OS X tries the configuration at the top of the list first, and then tries the other port configurations in descending order when you attempt to connect to the Internet."
    I connect with a DSL using PPoE, and I have a port for PPoE and a separate one for Ethernet in my network preference pane. You may find FAQ on your provider's site that will give you the type of connection you have.

  • Pre-amp and mic recommendation

    for a while now I've been recording vocals from my condenser mic directly into the pre-amp on my presonus firebox. im told that in many cases, to get the best out of your mic, it's not necessarily the quality of the mic but the quality of the pre-amp. i spoke to someone earlier who mentioned that the pre-amp on my firebox probably isnt the best for direct mic input. he said i would definately benefit from some sort of pre-amp between my mic and my firebox.
    can anyone recommend a good, affordable pre-amp for the home studio? better yet, can someone confirm what ive been told?
    also considering getting a new mic altogether... im eyeballing the SE electronics z3300a multi-pattern mic. any vouchers or recommendations for good mics in the home studio? I'll be bumping up from an unimpressive m-audio nova condenser mic.
    thanks!

    hey fellas---
    thanks for the replies. to answer some of the overriding questions:
    budget: I'd probobly like to keep in in the range of a few hundred dollars, no more than a grand. if i can get a better sound out of my existing mic by getting a decent pre, that'd be ideal. if i need to upgrade mics, that might take time. still, trying to keep it around $500-$800.
    application: EVERYTHING. anything from male vocals to voiceover work to film ADR to acoustic guitars. everything EXCEPT drums. wont be doing any drum or percussion micing anytime soon. lots of acoustic instruments like guitar and solo violin. might also, if its doable, run electric guitar and bass through the pre-amp if that will help with my electric guitar signal (like i said with the mic, the e-guitar is going straight into the instrument input on the presonus firebox, nothing between to sweeten, warm, or strengthen the signal consistently).
    preference: a clean, dry sound with faithful reproduction. but to be honest, i wouldnt mind a little warm colouring. something with a stronger bass response, but still accurate and faithful mids and highs.
    its been suggested to me that i stick with solid state mics for now, but a tube pre-amp wouldn't hurt. I've got a tube preamp, but im not happy with it so i havent used it in ages (the ART Tube MP Studio V3)
    Thanks!

  • Flex 3 RichTextEditor - move controlbar to top

    I want to move the controlbar of the RichTextEditor above the TextArea instead of the default of being below the TextArea.
    I've been playing around with it as follows but I have a feeling I should not do this in the updateDisplayList method.
    Should I do it in the initialize method?
    <?xml version="1.0" encoding="utf-8"?>
    <mx:RichTextEditor xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import mx.controls.TextArea;
          import mx.core.UIComponent;
          override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
            var txt:TextArea = TextArea(super.removeChild(textArea));
            var cb:DisplayObject = DisplayObject(super.removeChild(this.controlBar as DisplayObject));
            super.addChild(cb);
            super.addChild(new TextArea());
            super.updateDisplayList(unscaledWidth, unscaledHeight);
        ]]>
      </mx:Script>
    </mx:RichTextEditor>

    This doesn't work either:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:RichTextEditor xmlns:mx="http://www.adobe.com/2006/mxml"
      creationComplete="setupUI();">
      <mx:Script>
        <![CDATA[
          import mx.controls.TextArea;
          import mx.core.UIComponent;
          private function setupUI():void{
            var taIndex:uint;
            var cbIndex:uint;
            for(var a:uint=0;a<this.rawChildren.numChildren;a++){
              trace(this.rawChildren.getChildAt(a));
              if(a==2){
                var disObj:DisplayObject = this.rawChildren.removeChildAt(a);
                this.rawChildren.addChildAt(disObj, 1);
            trace("**************************");
            for(var b:uint=0;b<this.rawChildren.numChildren;b++){
              trace(this.rawChildren.getChildAt(b));
        ]]>
      </mx:Script>
    </mx:RichTextEditor>

  • 30EA2 - refuses to unload results into new file

    With ver 3.0.02.83 I'm getting "Not writable" message every time when I try to unload the results into a new file. SqllDeveloper refuses to write to a new file and I have to preallocate it first and then answer yes on override question.
    Does anybody else have the same situation?

    On what OS version?
    K.

  • VerifyError: Error #1053: Illegal override of z in mx.core.UIComponent in adobe flex  pease help me!

    While I tried to run already existing adobe AIR application in Flex Builder3 using  Flex SDK4. I got this error
    VerifyError: Error #1053: Illegal override of z in mx.core.UIComponent in adobe flex
    please anyone help me to solve it

    Try setting your target player for 10 in your compiler options. It might be compiling for flash player 9.

Maybe you are looking for

  • ItunesU podcasts won't sync to ipod

    Hi, I've tried to follow the instructions about how to sync podcasts from itunesU to your ipod. It says to select your device when it appears then click on the itunesU button and select the podcasts you want to sync and click "apaly". Well if I'm sel

  • Windows 2008 Server - Cannot run Active Directory Users and Computers

    Hi, I am running Windows 2008 Server with latest windows updates installed. Directory Services Role also. I attempt to open Active Directory Users and Computers tool and I get a; Microsoft Visual C++ Runtime Library error; "The Application has reques

  • Invoking a function in a loaded swf file

    Hi, I have a SWF file which loads an additional SWF file, in the following method:             var loader:Loader = new Loader();             loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);             var request:URLRequ

  • Global Type declaration/definition of name duplicated error

    Hi, All, We have two EJB exposed as the Webservice , so WS-1 and WS2, When I insert these two WS into the SOA Application to used by BPEL process. I get the compile error from jdev(11.1.1.1.3) like this: Global Type declaration/definition of name '{h

  • Service entry sheet error.with new material group for services

    Dear Experts We need to create material group for  roll shop spare parts service,we created a new material group. when we are creating PR/PO with item category as D and a/c assignment K( entered cost center here).its giving error message as RC= 3M8 4