views:

114

answers:

1

How do you say or achieve container.child.source = image.png?

I have a hexagon map built by specifying width and height. I draw a wireframe and place a base image for each hex into a canvas. Next, the canvas listens for a mouse click. I then run a calculation to determine which hex the mouse click was closest to. My intent is to change the source of the image that the user clicked on.

I know that mapSlate.getChildByName(mapProperties[closestHex]['baseName']) is the intended hex but I can't quite get to the point of doing a .source as Flex doesn't know that the selected object is an image.

+1  A: 

If u are sure that mapSlate.getChildByName(mapProperties[closestHex]['baseName']) is the intended hex and that it is in fact an Image, can't you cast it into Image and change the source like:

Image(mapSlate.getChildByName(
    mapProperties[closestHex]['baseName'])).source = "image.png";

or

(mapSlate.getChildByName(
    mapProperties[closestHex]['baseName']) as Image).source = "image.png";
Amarghosh
Awesome. That is exactly what I needed. I didn't know the syntax of how to classify it as an image. As a workaround, I was removing the image, creating a new one and placing it. It worked, but it was slow. This method is much quicker. Thank you.
Charles Shoults