Hi. I have created a really simple custom component called
myComp. It is a simple Canvas 100 pixels x 100 pixels with an Image
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
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.