开发者

Actionscript 3.0 Rotating an Image, by 90 degrees, that was loaded from a url

开发者 https://www.devze.com 2023-01-24 02:43 出处:网络
I got an error saying \"Attempted access of inaccessible method rotation through a reference with static type flash.display:Sprite.ssd.rotation(90)}\"

I got an error saying "Attempted access of inaccessible method rotation through a reference with static type flash.display:Sprite.ssd.rotation(90)}" I just want to know how to rotate my image by 90degrees when I double click on it.

var shootingstar:Loader = new Loader();
shootingstar.load(new URLRequest("http://i51.tinypic.com/m开发者_开发百科8jp7m.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)
 }


The error suggests that the rotation method is not accessible , i.e , private or protected. Therefore you're not able to call it directly as in your code rotation(90).

Instead you should be using the rotation public property

    rotation = 90;

As superfro points out, you should also get an error from the rotate method which requires a MouseEvent parameter. So practically..

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

Finally, makes sure that the doubleClickEnabled property of the Sprite is set to true

function onLoadingComplete(event:Event):void
{
   ssd.doubleClickEnabled = true;
   etc....


Have you tried ssd.rotation = 90; ?

0

精彩评论

暂无评论...
验证码 换一张
取 消