0

我在 mxml 中有一个火花路径:

<s:Group id="group" click="clickHandler(event)" >
                <s:Path id="na259" x="385.301" y="140.422" winding="nonZero"   data="M2.01562 0.141602 2.32812 0.110352 2.78125 0.0322266 3.15625 0.0322266 3.59375 0 4.04688 0 4.5625 0.0322266 5.04688 0 5.59375 0 5.95312 0.0166016 6.39062 0.0166016 6.875 0.0478516 7.29688 0.0712891 7.76807 0.0712891 8.29688 0.0947266 8.78125 0.141602
                        9.28125 0.141602 9.6875 0.188477 10.0469 0.219727 10.5625 0.282227 11 0.313477 11.4062 0.360352C11.4062 0.360352 11.7969 0.422852 11.8438 0.438477 11.8906 0.454102 12.3281 0.547852 12.3281 0.547852L12.8281 0.641602 13.3125 0.782227 13.6562 0.860352
                        14.0312 0.985352 14.3906 1.1416 14.7031 1.28223 15.0781 1.43848 15.3594 1.68848 15.6719 1.98535 15.9062 2.29785 16.1875 2.79785 16.25 3.46973 16.1875 4.09473 16.125 4.6416 15.9375 5.17285 15.6875 5.79785 15.3906 6.25098 15.0469 6.73535 14.5938
                        7.15723 14.125 7.42285 13.6719 7.5791 13.208 7.5791 12.5938 7.3291 11.9844 6.90723 11.4062 6.53223 11.0625 6.29785 10.7188 6.03223 10.3438 5.93848 9.96875 6.11035 9.70312 6.37598 9.57812 6.81348 8.3125 7.04785 7.79688 6.92285 7.45312 6.7666 6.98438
                        6.67285 6.23438 6.61035 5.84375 6.6416 5.70312 6.6416 5.53125 6.67285 5.45312 6.8291 5.07812 6.65723 4.6875 6.54785 4.26562 6.48535 3.79688 6.53223 3.3125 6.65723 2.89062 6.98535 2.57812 7.23535 2.22607 7.5791 1.9375 7.8291 1.73438 8.12598 1.39062
                        8.2666 1.03125 8.12598 0.65625 7.8291 0.59375 7.5166 0.4375 7.1416 0.328125 6.68848 0.296875 6.15723 0.234375 5.7041 0.234375 5.23535 0.3125 4.65723 0.234375 4.2627 0.15625 3.84473 0.046875 3.15723 0 2.61035 0.03125 2.04785 0.078125 1.67285 0.21875
                        1.37598 0.46875 1.12598 0.734375 0.766602 1.01562 0.469727 1.39062 0.266602 2.01562 0.141602Z">
                    <s:stroke>
                        <s:SolidColorStroke weight="0.25" caps="none" joints="miter" miterLimit="10"/>
                    </s:stroke>
                </s:Path>
            </s:Group>

所以,我的问题是,我需要精确地使这条路径可点击......而不是它周围的组......该组是一个盒子,所以它不够精确。

这个标签:

<s:Path>

bot 是否接受属性“click”,因此我无法为此标签创建 click 事件侦听器。

4

2 回答 2

3

将您的路径包装成一个组并将组的 mouseEnabledWhereTransparent 属性设置为 false。

于 2013-04-16T08:20:55.447 回答
0

有时会通过使用Rect类似的组件来提供帮助

<!-- hit area -->
<s:Rect left="0" right="0" top="0" bottom="0">
    <s:fill>
        <s:SolidColor color="#000000" alpha="0"/>
    </s:fill>
</s:Rect>


<s:Group id="group" click="clickHandler(event)" >
                <s:Path id="na259" x="385.301" y="140.422" winding="nonZero"   data="M2.01562 0.141602 2.32812 0.110352 2.78125 0.0322266 3.15625 0.0322266 3.59375 0 4.04688 0 4.5625 0.0322266 5.04688 0 5.59375 0 5.95312 0.0166016 6.39062 0.0166016 6.875 0.0478516 7.29688 0.0712891 7.76807 0.0712891 8.29688 0.0947266 8.78125 0.141602
                        9.28125 0.141602 9.6875 0.188477 10.0469 0.219727 10.5625 0.282227 11 0.313477 11.4062 0.360352C11.4062 0.360352 11.7969 0.422852 11.8438 0.438477 11.8906 0.454102 12.3281 0.547852 12.3281 0.547852L12.8281 0.641602 13.3125 0.782227 13.6562 0.860352
                        14.0312 0.985352 14.3906 1.1416 14.7031 1.28223 15.0781 1.43848 15.3594 1.68848 15.6719 1.98535 15.9062 2.29785 16.1875 2.79785 16.25 3.46973 16.1875 4.09473 16.125 4.6416 15.9375 5.17285 15.6875 5.79785 15.3906 6.25098 15.0469 6.73535 14.5938
                        7.15723 14.125 7.42285 13.6719 7.5791 13.208 7.5791 12.5938 7.3291 11.9844 6.90723 11.4062 6.53223 11.0625 6.29785 10.7188 6.03223 10.3438 5.93848 9.96875 6.11035 9.70312 6.37598 9.57812 6.81348 8.3125 7.04785 7.79688 6.92285 7.45312 6.7666 6.98438
                        6.67285 6.23438 6.61035 5.84375 6.6416 5.70312 6.6416 5.53125 6.67285 5.45312 6.8291 5.07812 6.65723 4.6875 6.54785 4.26562 6.48535 3.79688 6.53223 3.3125 6.65723 2.89062 6.98535 2.57812 7.23535 2.22607 7.5791 1.9375 7.8291 1.73438 8.12598 1.39062
                        8.2666 1.03125 8.12598 0.65625 7.8291 0.59375 7.5166 0.4375 7.1416 0.328125 6.68848 0.296875 6.15723 0.234375 5.7041 0.234375 5.23535 0.3125 4.65723 0.234375 4.2627 0.15625 3.84473 0.046875 3.15723 0 2.61035 0.03125 2.04785 0.078125 1.67285 0.21875
                        1.37598 0.46875 1.12598 0.734375 0.766602 1.01562 0.469727 1.39062 0.266602 2.01562 0.141602Z">
                    <s:stroke>
                        <s:SolidColorStroke weight="0.25" caps="none" joints="miter" miterLimit="10"/>
                    </s:stroke>
                </s:Path>
            </s:Group>
于 2013-04-16T07:40:17.410 回答