1 Reply Latest reply on Jan 2, 2009 9:59 AM by rtalton

    Help with creating a custom component.

    jcahill23 Level 1
      Hi. I have created a really simple custom component called myComp. It is a simple Canvas 100 pixels x 100 pixels with an Image control component.
      <mx:Image id="image1">

      After instantiating the component in Main.mxml eg. var pic1:myComp = new myComp(); I am having a problem setting the source property of the Image component.

      "image1" is the id of mx:Image in the custom compoenent so I tried pic1.image1.source = "assets/ball.jpg" but I get a run time error "Error #1009: Cannot access a property or method of a null object reference".

      Don't really know what I am doing wrong.

      Any help please!

        • 1. Re: Help with creating a custom component.
          rtalton Level 4
          In your custom component, try adding a bindable public var which contains the path to your image. Also, set the image.source to this var.
          In your main app, set the var within the <mx:> tags of the custom component. Since it is a public var, it will show up in the code hint. You can also now change the image var from the main app anytime you like using ActionScript code.