0

我收到一条错误消息: “尝试通过静态类型 flash.display:Sprite.ssd.rotation(90)} 的引用访问无法访问的方法旋转” 我只想知道双击图像时如何将图像旋转90 度.

var shootingstar:Loader = new Loader();
shootingstar.load(new URLRequest("http://i51.tinypic.com/m8jp7m.png"));
shootingstar.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadingComplete);
var ssd:Sprite = new Sprite();
 function onLoadingComplete(event:Event):void
 {
    ssd.addChild( event.currentTarget.loader.content );
    ssd.addEventListener(MouseEvent.MOUSE_DOWN, drag);
    ssd.addEventListener(MouseEvent.MOUSE_UP, drop);
    ssd.addEventListener(MouseEvent.DOUBLE_CLICK, rotate)
 ssd.height=180
 ssd.width=124
 }
 function drag(event:MouseEvent):void{
     ssd.startDrag()
  }
 function drop(event:MouseEvent):void{
  ssd.stopDrag()
 }
 function rotate():void{
     ssd.rotation(90)
 }
4

2 回答 2

3

该错误表明轮换方法不可访问,即私有或受保护。因此,您不能像在代码轮换(90)中那样直接调用它。

相反,您应该使用旋转公共属性

    rotation = 90;

正如 superfro 指出的那样,您还应该从需要 MouseEvent 参数的旋转方法中得到一个错误。所以实际上..

function rotate(event:MouseEvent):void
{
   ssd.rotation = 90;
}

最后,确保 Sprite 的 doubleClickEnabled 属性设置为 true

function onLoadingComplete(event:Event):void
{
   ssd.doubleClickEnabled = true;
   etc....
于 2010-11-10T05:34:36.013 回答
0

你试过ssd.rotation = 90;吗?

于 2010-11-10T04:53:35.043 回答