如何在createjs中获取movieClip的宽度和高度?
我正在做的是创建一个形状,然后转换为movieClip,并给它一个名字,我可以使用js中的名称访问该实例,但我无法获得宽度和高度?
有任何想法或方法可以实现这一目标吗? 我注意到Flash CS6的createJS扩展,将我所做的movieClip转换为容器
答案 0 :(得分:0)
从Flash CC导出的所有库项目都有nominalBounds
,这是一个EaselJS矩形(x,y,宽度,高度)。
(lib.test = function() {
this.initialize();
// Layer 1
this.shape = new cjs.Shape();
this.shape.graphics.f("#339900").s().p("AHZMiQAognC8hzQDJh6AYgTQAjgdBGh7QBGh5AAgfQAAgogGgTQgKgngigaQhdhIkdAAIhiACQhVACgsADQgqAiiIBlQBPCfA8B6QBlAIArAJIACAHIgBAOQgDAGgQAAIhrgEIAlBNQgKAPgKACQgbgsgegzIn+gZQgfAYgUAQQgPgTgCgYIh2gGIhzAdIjmAAQgLgCgDgCQgGgDAAgQQAAhABVh2QBYh7CEhxQCWh+CbhEQA9gbA4gPQguhrgphSQiGkFhxAAQgRAAknHpQljJLh0CsQgYgpgdidQgbiKAAghQAAgWCUnbQCWniAMAAQANAAD0AbQDzAcANAAQAZgBAdgwQAgg1ALgEQAcBMBnAjQBkAjD6AWQITArD+A0IACAHIgBANQgDAIgQgBQgMABnfg1QoAg4iTgLQBCCHCOEgQBkgXBcAJIAPAVQAFAHAAAHQAAAVgYBEQBXhIBNg+QAHADAIAAQAFACAAAQQAAAPjeDBIgIALIgCAGQEGgqCoiYQAsgpBNhMQBDg+BDgcIAHAQQgiAciaCQQh5BvhgBFQHAguCHB+QAsApAJA7QAEAggFAlQAACOirCjQi1CrkqB4QgMgEgIgIgAsNrDQgzAYgUBFIhVEWQhFDYhgFUIAvEaIAAADQCLjeDflnIFppJIAHgIQhFgFhxgWQhzgWgpgEQgSgBgRAAQgzAAggAQgAB4ECQh4BahLA6IDyAKQBxAFBTAGQgshQgwhfIglhOIhyBUgAmBBHQhIBHhEBvIhmCpQDKgDBkgTIAMgCQAmgsCuiXQALgNANgKQAYgWAugkICXiAIgcg3IgphiQkmBFimChgAiBGAIgQAIIgBALIAFAAIAFgEIAOgPIgDAAIgEAAgABxBUIjhDAQgXAhAAAVQAAAZAFgSQB/gsA2hRQAKgPAdg1QAWgqAVgXIADgCIgXAHgACYBsQgIATgKAnQgMAigkAWIgDAFQA1gbBRg9IghhCQgXAQgJATgADcA1IAfA9IB4hcIAMgIQhpANg6AagABsimIA8B3IAIAPIAHgHQBNhRgJhCIACgFQhMAJhFAQgAjyrXIgKAQIgFAHQAvAJAKgDQgWgugDgHQgHAIgKAQg");
this.shape.setTransform(114.6,81.5);
this.addChild(this.shape);
}).prototype = p = new cjs.Container();
p.nominalBounds = new cjs.Rectangle(0,0,229.3,163);
var instance = new lib.test();
console.log(instance.nominalBounds);
您也可以使用getBounds()
方法,该方法对形状有一些限制,但会考虑对象变换(以及子对象)。