as3 can not move and rotate external image with movieClip

42 Views Asked by At

I spent so much time and did not do it.

I have a animated movieClip called holder1 (instance name) which is animated with 25 frames(moving and rotating). I can load external image, that is Ok. coordinates are ok, same with MovieClip. But it is not moving with holder1. why? earlier I could do it with loadmovie with as2. thanks for your help.

  btn.addEventListener(MouseEvent.CLICK,f);

  var loader_mc : Loader = new Loader();
  var urlRequest : URLRequest = new URLRequest("imagem.jpeg");

 function f(e:Event){
 loader_mc.load(urlRequest);
  holder1.addChild(loader_mc);
  }
1

There are 1 best solutions below

0
esdebon On
btn.addEventListener(MouseEvent.CLICK,f);

var loader_mc : Loader = new Loader();
var urlRequest : URLRequest = new URLRequest("imagem.jpeg");

var speedX:int = 1;
var speedY:int = 1;

function f(e:Event){
    loader_mc.load(urlRequest);
    holder1.addChild(loader_mc);
    holder1.addEventListener(Event.ENTER_FRAME, andMove);
}

function andMove(e:Event){
    holder1.rotationZ += 1;
    if(holder1.x<0 || holder1.x>stage.stageWidth)
        speedX *= -1;
    if(holder1.y<0 || holder1.y>stage.stageHeight)
        speedY *= -1;
    holder1.x += speedX;
    holder1.y += speedY;    
}