首页 \ 问答 \ 如何获得嵌入式图像/ swf的大小?(How to get the size of an embedded image / swf?)

如何获得嵌入式图像/ swf的大小?(How to get the size of an embedded image / swf?)

通常情况下,如果您从URL加载图像,您可以执行以下操作:

m_image = new Image();
m_image.addEventListener(Event.COMPLETE, image_completeHandler, false, 0, true);
m_image.source = "http://www.example.com/image.jpg";

private function image_completeHandler(event:Event):void
{
    // Image content has now loaded, we need to wait for it to validate it's size
    m_image.addEventListener(FlexEvent.UPDATE_COMPLETE, image_updateCompleteHandler, false, 0, true);
}

private function image_updateCompleteHandler(event:FlexEvent):void
{
    // Do stuff with width / height
}

但是,如果将源设置为嵌入式图像类,则完整的事件不会触发。 所以我的问题是,如何获得嵌入式图像/ swf的宽度/高度?


Normally if you were loading an image from a URL you would do the following:

m_image = new Image();
m_image.addEventListener(Event.COMPLETE, image_completeHandler, false, 0, true);
m_image.source = "http://www.example.com/image.jpg";

private function image_completeHandler(event:Event):void
{
    // Image content has now loaded, we need to wait for it to validate it's size
    m_image.addEventListener(FlexEvent.UPDATE_COMPLETE, image_updateCompleteHandler, false, 0, true);
}

private function image_updateCompleteHandler(event:FlexEvent):void
{
    // Do stuff with width / height
}

But, if you set the source to an embedded image class, the complete event doesn't appear to fire. So my question is, how can you get the width / height of an embedded image / swf?


原文:https://stackoverflow.com/questions/1229949
更新时间:2022-02-15 14:02

最满意答案

该行评估函数并将undefined的返回值设置为Dog.prototype.bark

Dog.prototype.bark = barkWithMe();

将其更改为:

Dog.prototype.bark = barkWithMe;

This line evaluates the function and sets the return value undefined to Dog.prototype.bark:

Dog.prototype.bark = barkWithMe();

Change it to:

Dog.prototype.bark = barkWithMe;

相关问答

更多
  • 是的,由于JavaScript原型继承的灵活性,两种方式都是允许的。 首先让我们看看这两种情况下的原型链。 为了简单,我只考虑文字对象。 Object.prototype与函数原型 最后使用literal创建的对象Object.prototype (internal [[Prototype]] )的最后一个值是Object.prototype 。 例如: /*Example 1*/ var o = { foo: 1, bar: 2 } Prototypical chain: o -> Object.pro ...
  • 在JavaScript中没有覆盖的真正概念。 使用new实例化时,只需在新对象中引用原型对象(如__proto__ ),对对象中不存在的属性的任何访问都将路由到原型对象。 仍然,调用“构造函数”函数,以便在调用者使用之前有机会修改新对象。 在构造函数中,正如您所知,新对象被引用this对象。 在您的情况下,您实际上将swingSword函数添加到之前不存在的新对象。 如果没有,所有对swingSword属性(函数)的访问都将回swingSword原型。 换句话说,你“覆盖”原型功能,而不是相反! 确保您了解 ...
  • 组织代码,以便在创建原型对象后定义所有原型方法。 例如: Pirault.prototype = Object.create(Person.prototype); Pirault.prototype.constructor = Pirault; Pirault.prototype.mySkill = function(){ console.log('My skill is '+this.skill); } 演示 。 就目前而言,你正确地在原型上定义一个方法 - 但是当一个对象(由Object.c ...
  • 请注意,所有函数共享相同的call方法,从Function.prototype继承。 Object.prototype.hasOwnProperty.call === Function.prototype.call // true 当你在一个函数上调用call时,该函数就成为this call值,所以call可以调用该函数。 这是你的第一个代码,它的工作原理。 但是,在你的第二个代码中,你不会把call作为一个对象的方法。 因此,它的this值在严格模式下是undefined ,或者是在非严格模式下的全局 ...
  • 该行评估函数并将undefined的返回值设置为Dog.prototype.bark : Dog.prototype.bark = barkWithMe(); 将其更改为: Dog.prototype.bark = barkWithMe; This line evaluates the function and sets the return value undefined to Dog.prototype.bark: Dog.prototype.bark = barkWithMe(); Change ...
  • 因为它的原型继承。 以下方法可行: myClass.prototype.age = 22; var myobj = new myClass(); window.alert(myobj.age); 在您的示例中,您将向类原型添加属性。 只有在实例化该类的对象时才能看到这些。 要实现您想要的,只需依赖expando属性: myClass.age = 22; window.alert(myClass.age); 如果它有用,可以将第一个示例视为在C#中声明类的公共属性。 您只能在实例化时访问它。 第二个例 ...
  • var a = []做了一件事:它将a设置为new Array的实例但没有任何成员,因此继承了prototype[0] 。 var b = [1]做了两件事:它将b设置为new Array的实例(与a ),但是然后直接设置subscript [0] = 1 (绕过JavaScript的原型系统),这意味着[0] = 1 覆盖 “ defineProperty ”属性,从而完全避免了prototype[0] defineProperty 。 这与对象的工作方式相同: Object.defineProperty ...
  • 由于Base是一个构造函数,如果你想要一个使用Base.prototype作为其基础的单个对象,正如Brian Peacock在下面指出的那样你可以使用构造函数: var concrete2 = new Base(); concrete2.notify(); // Works 如果要向concrete2实例添加更多功能,可以直接执行此操作: concrete2.doSomethingElse = function() { /* ... */ }; 这是因为你已经有了构造函数,所以创建由该构造函数原型支持 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)