惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

博客园 - netlynx2000

flex如何删除一个XML Node flex TabContainer 类实例化问题 一个追风筝的人,追寻着什么 flex加载Module遇到的问题 如何一个Loader加载多个资源 Flex- 将Sprite控件添加到FLEX UI中 ex metadata tag 自定义flex中的事件 从EAI到SOA OMG工作流规范翻译 男人,信仰,爱,恨,人性 开源产品公司如何生存 拔拔草,开源与闭源 其实现在的我们也有很多梦想,比如低谷时想未来做一个什么样的公司,未来买什么样的豪宅。但是仅限于自我满足的想想,然后继续平庸的生活。 做事情的好习惯 使用Ajax读取aspx页面源代码 挣钱,买个照相机 友情提示的一个问题 苍天开眼,刘青云终于获奖了
Action script如何复制一个Bitmap对象
netlynx2000 · 2008-03-11 · via 博客园 - netlynx2000

本人最近遇到需要复制一个Bitmap对象的问题,应用场景如下:

在我的一个Flash中经常需要加载同样的图片,而这张图片也是比较大的,所以就想第一次使用后就把这张图片缓存起来,以后用时直接从缓存读取就可以了,因此就遇到Bitmap对象的复制问题,在网上搜了一下,网友们有两种解决方案,如下
方案1:

Title public class MyImage{
  public var bitmap: Bitmap;
  public var url: String;
  public var x: number;
  public var y: number;

  public function clone(): MyImage()
  {
      var myImage: MyImage = new MyImage();
      myImage.bitmap = this.bitmap.clone;
      myImage.url = this.url;
      myImage.x = this.x;
      myImage.y = this.y;
      return myImage;
  }
}

这种方案网上有人说可以,但是我自己试了一下,好像不行,“this.bitmap.clone”这句话不对,Bitmap就没有clone这个属性
方案2:

...

import flash.net.registerClassAlias;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;

...

public function clone(source:Object) :* {
        var typeName:String = getQualifiedClassName(source);//获取全名
        var packageName:String = typeName.split("::")[1];//切出包名
        var type:Class = Class(getDefinitionByName(typeName));//获取Class

        registerClassAlias(packageName, type);//注册Class
       
        //复制对象
        var copier:ByteArray = new

ByteArray();
        copier.writeObject(source);
        copier.position = 0;
        return copier.readObject();
}

这种方案虽然不报错,对象也复制成功了,但是好像图片就是无法正常显示
方案3:这是我自己的方案,其实也是很简单的事情

new Bitmap(sourceBitmap.bitMapData.clone())

Bitmap的bitmapData有clone的方法
这个方法我试过,可以正常使用