A
A
Alexander Sharomet2014-12-03 12:35:37
Programming
Alexander Sharomet, 2014-12-03 12:35:37

When adding the vcam_as3 component, the buttons become inactive, why?

Hello.
I have added the vcam_as3 component. But when the application starts, this component covers everything that is on the screen (on top of everything), including buttons, you cannot click on them. How can this be fixed. Here is the script of the vcam_as3 component itself

visible=false;
parent.cacheAsBitmap=true;

var button=new button();
this.addChild(button);

var oldScaleMode:String=stage.scaleMode;
stage.scaleMode="exactFit";

var sW:Number=stage.stageWidth;
var sH:Number=stage.stageHeight;

stage.scaleMode=oldScaleMode;

var bounds_obj:Object=this.getBounds(this);

var camH:Number=bounds_obj.height;
var camW:Number=bounds_obj.width;

var rp:Point=new Point(x,y);

addEventListener(Event.ENTER_FRAME,camControl);
addEventListener(Event.REMOVED_FROM_STAGE,reset);

var bmp:Bitmap;
var myBitmapData:BitmapData=new BitmapData(sW,sH,true,0);
bmp=new Bitmap(myBitmapData);

camControl();

stage.addChild(bmp);

function camControl(...event):void {

  parent.visible=true;

  rp.x=x;
  rp.y=y;

  var h:Number=camH * scaleY;
  var w:Number=camW * scaleX;

  var _scaleY:Number=sH / h;
  var _scaleX:Number=sW / w;

  x2=w / 2 * _scaleX;
  y2=h / 2 * _scaleY;

  scaleX2=_scaleX;
  scaleY2=_scaleY;

  rotation2=- rotation;

  myBitmapData.lock();
  myBitmapData.fillRect(myBitmapData.rect,0x00);
  myBitmapData.unlock();

  myBitmapData.draw(stage);

  bmp.filters=this.filters;
  bmp.transform.colorTransform=this.transform.colorTransform;

  parent.visible=false;

}

function reset(e:Event):void {
  removeEventListener(Event.ENTER_FRAME,camControl);
  removeEventListener(Event.REMOVED_FROM_STAGE,reset);

  stage.removeChild(bmp);
  myBitmapData.dispose();
  bmp=null;

  parent.scaleX=1;
  parent.scaleY=1;
  parent.x=0;
  parent.y=0;
  parent.rotation=0;

  parent.visible=true;

}
function set x2(value:Number):void {
  var p:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
  parent.x+= value - p.x;
}
function get x2():Number {
  var p:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
  return p.x;
}
function set y2(value:Number):void {
  var p:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
  parent.y+= value - p.y;
}
function get y2():Number {
  var p:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
  return p.y;
}
function get scaleX2():Number {
  return parent.scaleX;
}
function set scaleX2(value:Number):void {
  setProperty2("scaleX",value);
}

function get scaleY2():Number {
  return parent.scaleY;
}

function set scaleY2(value:Number):void {
  setProperty2("scaleY",value);
}

function get rotation2():Number {
  return parent.rotation;
}
function set rotation2(value:Number):void {
  setProperty2("rotation",value);
}

function setProperty2(prop:String,n:Number):void {
  var a:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));

  parent[prop]=n;

  var b:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));

  parent.x-= b.x - a.x;
  parent.y-= b.y - a.y;
}

Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question