首页 新闻 会员 周边

as3 图片旋转问题

0
悬赏园豆:40 [待解决问题]

function load_gallery(xml_file:String):void
{
var xml_loader:URLLoader = new URLLoader();
xml_loader.load( new URLRequest( xml_file ));
xml_loader.addEventListener( Event.COMPLETE, create_gallery );
}


function create_gallery(e:Event):void
{
flashmo_xml = new XML(e.target.data);
total_items = flashmo_xml.photo.length();
trace(total_items);


for (; i < flag; i++)
{
flashmo_photo_list.push( {
thumbnail: flashmo_xml.photo[i].thumbnail.toString(),
description: flashmo_xml.photo[i].description.toString()
} );
}
load_tn();

}

function load_tn():void
{
var tn_request:URLRequest = new URLRequest( folder + flashmo_photo_list[tn].thumbnail );

tn_loader = new Loader();
tn_loader.load(tn_request);
tn_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, tn_loaded);

tn++;
}

function tn_loaded(e:Event):void
{
if ( tn < flag )
{
load_tn();
}
else
{
tn_loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, tn_loaded);
tn_loader = null;
}

var flashmo_tn_bm:Bitmap = new Bitmap();
var flashmo_tn_mc:MovieClip = new MovieClip();

flashmo_tn_bm = Bitmap(e.target.content);
flashmo_tn_bm.smoothing = true;
flashmo_tn_bm.x = - Math.floor(flashmo_tn_bm.width * 0.5);
flashmo_tn_bm.y = - Math.floor(flashmo_tn_bm.height * 0.5);

flashmo_tn_mc.addChild( flashmo_tn_bm );

Multitouch.inputMode = MultitouchInputMode.GESTURE;
flashmo_tn_mc.addEventListener(TransformGestureEvent.GESTURE_ROTATE, onRotate);

flashmo_tn_mc.addEventListener( MouseEvent.MOUSE_DOWN, tn_down );
flashmo_tn_mc.addEventListener( MouseEvent.MOUSE_UP, tn_up );

randomize_tn(flashmo_tn_mc);
thumbnail_group.addChild( flashmo_tn_mc );

}

this.addChild(thumbnail_group);


function randomize_tn( each_mc:MovieClip ):void
{
var random_x:Number = Math.floor( Math.random() * ( stage.stageWidth - each_mc.width ) -
( stage.stageWidth * 0.5 ) + each_mc.width * 0.5 );
var random_y:Number = Math.floor( Math.random() * ( stage.stageHeight - each_mc.height ) -
( stage.stageHeight * 0.5 ) + each_mc.height * 0.5 );

Tweener.addTween( each_mc, { x: random_x, y: random_y,
scaleX:.1, scaleY: .1,
alpha: 1, rotation: Math.random() * 90 - 45,
time: tween_duration * 1.5, delay: Math.random() * 1.0, transition: "easeInOutQuad" } );
}

function tn_down(e:MouseEvent):void
{
e.target.startDrag();

mc = MovieClip(e.target);

stage.addEventListener(MouseEvent.MOUSE_UP, stage_up );


this.addChild( mc );
current_tn_x = Math.round(mc.x);
current_tn_y = Math.round(mc.y);
}

function tn_up(e:MouseEvent):void
{
mc = MovieClip(e.target);
mc.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_up );
}

function stage_up( e:MouseEvent ):void
{
mc.stopDrag();
}


function onRotate(param1:TransformGestureEvent):void
{
mc = MovieClip(param1.target);

var _loc_2:Point;
var _loc_3:Point;
var _loc_4:Matrix;

switch (param1.phase)
{
case GesturePhase.BEGIN :
{

this.mc.removeEventListener( MouseEvent.MOUSE_DOWN, tn_down );
this.mc.removeEventListener( MouseEvent.MOUSE_UP, tn_up );
this.mc.removeEventListener(TransformGestureEvent.GESTURE_ZOOM, onZoom);
break;


};

case GesturePhase.UPDATE :
{
_loc_2 = new Point(param1.localX,param1.localY);
_loc_3 = new Point(param1.stageX,param1.stageY);
_loc_4 = this.mc.transform.matrix.clone();
_loc_4.rotate(param1.rotation * (Math.PI/180));
MatrixTransformer.matchInternalPointWithExternal(_loc_4, _loc_2, _loc_3);
this.mc.transform.matrix = _loc_4;

break;
};

case GesturePhase.END :
{
break;
};

default :
{
break;
}
};

return;
}

 

图片拖动没有问题,使用图片旋转,图片会突然消失,很无奈,为了方便图片管理,加了双层图片容器,是不是这个原因,请求高手指点迷津。

们的士的主页 们的士 | 初学一级 | 园豆:162
提问于:2014-07-09 10:12
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册