如何以编程方式更改名称不明确的图像的来源?
你怎么说或实现container.child.source = image.png?
我有一个通过指定宽度和高度构建的六边形地图。我绘制一个线框并将每个六角形的基本图像放入画布中。接下来,画布侦听鼠标单击。然后,我运行计算以确定鼠标单击最接近哪个十六进制。我的目的是更改用户单击的图像的来源。
我知道 mapSlate.getChildByName(mapProperties[closestHex]['baseName']) 是预期的十六进制,但我无法完全达到执行 .source 的目的,因为 Flex 不知道所选对象是图像。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您确定
mapSlate.getChildByName(mapProperties[closestHex]['baseName'])
是预期的十六进制并且它实际上是一个Image
,您能吗将其转换为Image
并更改源,例如:或
If u are sure that
mapSlate.getChildByName(mapProperties[closestHex]['baseName'])
is the intended hex and that it is in fact anImage
, can't you cast it intoImage
and change the source like:or