易截截图软件、单文件、免安装、纯绿色、仅160KB

Flex 重复加载图片对内存和性能的影响

采用Image重复加载图片极大影响性能,并且占用大量内存,下面是我对比验证的代码。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
initialize="loadImage()">
<mx:Button x="122"
y="94"
label="add Low memory Images"
click="addLowMemImages()"/>
<mx:Button x="22"
y="94"
label="add Images"
click="addImages()"/>
<mx:Script>
<!--[CDATA[
import mx.controls.Image;
private var pairImage:BitmapData=new BitmapData(100, 100, false, 0x000000FF);
private function loadImage():void
{
var imageLoader:Loader=new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoadComplete);
imageLoader.load(new URLRequest("pair.jpg"));
}
private function imageLoadComplete(event:Event):void
{
pairImage=event.target.content.bitmapData;
}
//低内存高性能方法
private function addLowMemImages():void
{
var canvas:Canvas;
for (var i:int=0; i < 30; i++)
{
for (var j:int=0; j < 30; j++)
{
canvas=new Canvas();
canvas.width=40;
canvas.height=40;
canvas.x=50 * i;
canvas.y=50 * j;
canvas.graphics.beginBitmapFill(pairImage);
canvas.graphics.drawRect(0, 0, 40, 40);
canvas.graphics.beginFill(0xFF0000, 0.5);
canvas.graphics.drawCircle(20, 20, 10);
canvas.graphics.endFill();
images.addChild(canvas);
}
}
}
//慢且占内存高
private function addImages()
{
var canvas:Canvas;
var img:Image;
for (var i:int=0; i < 10; i++)
{
for (var j:int=0; j < 10; j++)
{
canvas=new Canvas();
canvas.width=40;
canvas.height=40;
canvas.x=50 * i;
canvas.y=5


相关文档:

flex时序图示例

<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the DateTimeAxis class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>

import mx.collections.ArrayCollection;
......

关于FLEX生成的SWF设置stage.displayState的问题

首先注意一下.
这里说的是在"FLEX"生成的"SWF"直接运行时,使用"stage.displayState"启用全屏时所遇到的问题...
注意上面""号所提到的关健词..
现在我们先看看代码,下面的代码装在creationComplete事件中调用init()来启动全屏.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www ......

flex tree默认展开第一个节点

<?xml version="1.0" encoding="utf-8"?>
<mx:Application fontSize="12" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
 <mx:Script>
  <![CDATA[
   public var treeXml: XML = <nodes name="所有">
 &n ......

Flex主题

Flex支持的样式设置方式
1.直接使用CSS文件,系统默认使用default.css
<mx:Style source=“style.css”/>
2.使用<mx:Style>标签
3.使用style设计器(->MXML)
4.使用对象的getStyle( )和setStyle( )
5.使用StyleManager类
主题是一套配置完成的样式风格
Flex提供的几种主题,文件类型.swc ......

Flex通信篇——Flex和外部应用程序进行通信

Flash To EXE
Flex端
Flex创建一个Flex Project命名为Demo1,类型选Web application(runs in Flash Player)
在Demo1.mxml上添加一个按钮,并未按钮添加点击事件
    private function ButtonClick(event:MouseEvent):void
    {
       ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号