如何获取容器维度?
How to get container dimension?
如何在createjs中获取movieClip的宽高?
我做的是创建一个shape,然后转换成movieClip,给它起个名字,我在js中可以通过这个名字访问到实例,但是我获取不到宽高?
有什么想法或方法可以实现吗?
我注意到 Flash CS6 的 createJS 扩展,将我所做的影片剪辑转换为容器
从 Flash CC 导出的所有库项目都有一个 nominalBounds
,它是一个 EaselJS 矩形 (x,y,width,height)。
(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()
方法,该方法对形状有一些限制,但考虑了对象变换(以及子对象)。
如何在createjs中获取movieClip的宽高?
我做的是创建一个shape,然后转换成movieClip,给它起个名字,我在js中可以通过这个名字访问到实例,但是我获取不到宽高?
有什么想法或方法可以实现吗? 我注意到 Flash CS6 的 createJS 扩展,将我所做的影片剪辑转换为容器
从 Flash CC 导出的所有库项目都有一个 nominalBounds
,它是一个 EaselJS 矩形 (x,y,width,height)。
(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()
方法,该方法对形状有一些限制,但考虑了对象变换(以及子对象)。