- 浏览: 718830 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (389)
- flex (150)
- java (55)
- flex_sharedObject (4)
- iphone/android (7)
- red5 (4)
- blazeds (19)
- ajax (3)
- flex&java (9)
- 聊天室 (2)
- flex的问题 (1)
- game (8)
- flex_xml (1)
- flex组件学习 (2)
- JGroups (1)
- 中转站 (2)
- ruby (7)
- flex_js (5)
- C/C++ (14)
- perl (2)
- db (13)
- air (10)
- hibernate (8)
- flash_flex_as_3d (2)
- struts (4)
- dwr (8)
- freemarker (2)
- AS (22)
- 工具 (6)
- js_jquery_ext_yui (4)
- .net (1)
- C# (1)
- 前端 (1)
最新评论
-
136900923:
您好,您的代码我不是很懂,我想跟您交流一下,我的qq邮箱:13 ...
hibernate做无限极菜单树如此简单 -
fykyx521:
两个同一个功能
flex_flush_Socket 安全沙箱解决 -
ustb:
你上下两个代码类之间没关系
flex_flush_Socket 安全沙箱解决 -
u010656335:
...
flex发送QQ表情 -
u010656335:
flex发送QQ表情
http://nochump.com/blog/?p=20。还有个想法是,css嵌入的字体编译成swf.相当于动态修改css来改变字体
<!-- mid column --> <!-- header -->
nochump.com
<!-- top tab navigation --> <!-- /top tabs -->AS3 Runtime Font Loading
Here’s a little experiment with loading fonts dynamically at runtime. So what’s this good for? Well let’s say you have a flash application where you want to allow users to customize the text formatting for some text box. Typically you would provide a small set of fonts which would all get embedded into the swf but this isn’t very flexible or ideal. Changing font’s or adding new one’s require rebuilding the swf. Also if only one or two fonts get used then all the other extra fonts do nothing but bloat the swf size. For this situation, it would be ideal to externalize the fonts and only load in the one’s needed.
Flash never supported this feature but some developer’s found ways around it. In particular, there was Shared Fonts Manager . However the author’s approach, although very impressive and useful, was a hack and not the easiest to use. With the major changes in flash 9, I got curious if runtime font loading was easier to do now and fortunately it is.
Approach
This isn’t new or anything, apparently all assets embedded in a swf become associated with a class and the ApplicationDomain object is the way to access classes in other swfs. The Flex documentation describes these topics but here, the focus is on fonts.
So first off, create the external font asset swf with something like the following:
package { import flash.display.Sprite; public class FontLibrary extends Sprite { [Embed(systemFont='Bank Gothic', fontName='emBank Gothic', mimeType='application/x-font')] public static var BankGothicFont:Class; } }
Keep track of the class names you use and the fontName attribute of the Embed statement as that will be font name you’ll have to use in a text format. You can embed as many fonts within the swf as you like. I won’t describe the other features of the embed statement as they have been pretty well covered elsewhere.
After the swf is built (for this example let’s call it fontlibrary.swf), you load it like any normal swf via a flash.display.Loader object. After it is loaded, you just need to register the font class associated with the embedded font. Here’s an example of loading and registering the font library swf from above.
var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); loader.load(new URLRequest("fontlibrary.swf")); private function completeHandler(event:Event):void { var FontLibrary:Class = event.target.applicationDomain.getDefinition("FontLibrary") as Class; Font.registerFont(FontLibrary.BankGothicFont); var tf:TextField = new TextField(); tf.defaultTextFormat = new TextFormat("emBank Gothic", 12, 0); tf.embedFonts = true; tf.rotation = 15; // to demonstrate the embed worked tf.text = "blah blah blahnblah blah blahnblah blah blah "; addChild(tf); }
If you’d like to grab a little demo with source, here’s a download .
More Thoughts
Another approach for the font asset swfs is to keep the main application class empty and include specific font classes thru the -source-path
and -includes
compiler options. A font class would then look something like this:
package { import flash.text.Font; [Embed(systemFont='Bank Gothic', fontName='emBank Gothic', mimeType='application/x-font')] public class BankGothicNormalFont extends Font {} }
With this it won’t matter what the definition name of the main application class is (which was “FontLibrary” in the earlier example) or would you need to know the name of the static property associated with the font, you would just register the included font class such as “BankGothicNormalFont”. I prefer this approach better because of this and that it gives a little more control over to my build scripts. Say you want a font swf to contain more than one font, with the first approach you’ll need to edit the main application class to add the embeds but here you can just edit your build script to include the other font classes (assuming they’re already written).
Another thought was using the component compiler (compc). With compc you can embed non-source files directly however I have not tried it with fonts. It doesn’t seem like it gives you controls over the font style, weight, or other attributes available with the embed syntax. I played with some other options but none seem that great.
There are also runtime shared libraries (RSL) and modules with
2.0.1. I haven’t used them so if I’m wrong please let me know but from
my understanding, RSLs do externalize assets and load at runtime
however they are loaded when the swf loads. There is no control in
actionscript for the loading of RSLs it appears. As for modules, I’m
guessing they would be the better approach but not sure what advantages
they offer over just using the ApplicationDomain
object.
Perhaps it has some management features I dunno. I can see a problem
when loading and registering the same font swf twice. Well I’ll have to
look into using modules.
发表评论
-
转深入理解Flash的沙箱 – Security Domains
2014-01-22 09:35 840一篇很经典的进阶文章,国外牛人的分享,清晰明了,图文并茂,适 ... -
[IE6 only]关于Flash/Flex,返回数据产生流错误Error #2032的解决方式
2010-11-19 14:04 2391转自:http://www.xintend.com/Artic ... -
as3_Matrix3d
2010-09-10 15:45 2331Matrix3D 类使用一个 4x4 正方形矩阵,即一个由 ... -
as3中matrix 解释,终于找到了
2010-09-10 14:57 4827转自:http://blog.sina.com.cn/ ... -
flash安全沙箱_解决测试时安全沙箱的问题
2010-07-18 18:15 1211自己测试的swf 老报安全沙箱 以前看到帖子 设置一个安全文件 ... -
flashlog.txt配置
2010-04-08 15:34 2506本工具特点:1、简单又 ... -
flex as3 元数据标签综合
2010-01-04 13:50 1343http://www.cnblogs.com/chocol ... -
Flex实际复杂项目中RSL(运行时共享库)的使用方法
2010-01-04 13:37 2724http://flash.9ria.com/thread-42 ... -
AS3 event flow 事件冒泡机制 以及 stopImmediatePropagation() stopPropagation()用法
2009-12-28 19:03 3216http://yzzelliot.spaces.live. ... -
event.preventDefault() 取消事件的默认行为
2009-12-28 18:53 6073http://blog.csdn.net/xiang08/ar ... -
gTween:轻便的as3缓动类库分享
2009-12-25 13:25 2252前不久做一个作品,想加入一些复杂点的缓动效果,想到gTween ... -
AS3应用程序模块化开发与ApplicationDomain
2009-12-25 13:22 2749AS3应用程序模块化开发 ... -
用Flex的编译参数实现AS3程序的自身预加载(Self Preloading)
2009-12-17 19:03 1809http://www.riaidea.com/blog/arc ... -
minibuilder 启动命令
2009-12-03 03:50 711http://code.google.com/p/minibu ... -
AS3 Alert
2009-12-02 16:37 1532package { import flash.displ ... -
最新火爆游戏巨献——谈Flash Player的安全机制
2009-11-23 16:30 728最新火爆游戏巨献——谈Flash Player的安全机制 ... -
as3编译器错误中文说明
2009-11-19 13:38 1264http://www.eb163.com/club/threa ... -
aswing进度条改变显示进度条方式
2009-11-11 16:53 1028package org.aswing.plaf.basic.b ... -
aswing布局管理器
2009-11-11 02:23 1847http://hereson.iteye.com/blog/1 ... -
as绘制渐变颜色皮肤
2009-11-10 13:57 926这段代码画了一个球型 var myMatrix:Matrix ...
相关推荐
在ActionScript 3 (AS3)中,动态加载字体是一种技术,允许开发者在应用程序运行时加载和使用新的字体。这可以极大地提高应用的灵活性,尤其是对于那些需要展示各种独特字体或者用户可定制字体的应用。本知识点将深入...
`runtime-font-loader-as3`是一个针对AS3开发的库,用于在运行时动态加载字体资源,从而提高应用程序的响应速度和用户体验。这个库是ASC2(ActionScript Compiler 2)的优化版本,由ru.etcs.utils.FontLoader提供...
在转换过程中,“Save as PDF”加载项会尽可能保留原始文档的样式、字体和图像质量。这对于那些需要保持设计一致性或希望确保接收方查看文档时无误的用户来说非常有价值。例如,设计师可能希望确保他们的布局在不同...
在Flash AS3编程中,加载(Loading)是关键功能之一,允许开发者动态地在应用程序运行时引入外部资源,如图像、SWF文件、XML或文本数据。本资源包含了一个名为"loading_as3"的示例项目,其中包括了loading_as3.fla...
在本项目中,我们关注的是使用ActionScript 3(AS3)在Flash环境中开发的一款类似于苹果操作系统的菜单。ActionScript是Adobe Flash Professional和Flash Player支持的编程语言,主要用于创建交互式内容、动画以及富...
5. **动态内容加载**:在运行时动态添加、删除或更新图文内容。 6. **性能优化**:通过优化的渲染引擎,确保在大量图文数据下的流畅显示。 综上所述,AS3官方图文混排包是Flex 3开发中的重要工具,它扩展了标准Flex...
tryRun.as ---------------------- try catch运行函数 url: Address.as ---------------------- 设置为首页/添加收藏夹/获取地址栏地址并且复制到右键 URL.as ---------------------- 跳转html/获取文件地址 ...
标题中的“用AS3写的滚动字幕”是指使用ActionScript 3.0,这是一种基于ECMAScript的脚本语言,广泛应用于Adobe Flash Professional和Flex框架中。ActionScript 3.0是Flash Player支持的主要编程语言,它为创建交互...
3. **assets**:这个目录通常包含应用程序所需的静态资源,如图片、字体或声音文件。在监测网络性能时,如果应用涉及到加载这些资源,我们可能需要关注它们的加载时间和效率。 在网络监测AS3的实践中,以下是一些...
3. **文本字段(TextField)**:用于展示描述内容,AS3中的TextField类是处理文本的核心,可以设置字体、大小、颜色,以及是否可编辑等属性。 4. **事件处理**:为了实现交互性,你需要监听用户的行为,如点击按钮...
2. **加载字体**:在Kivy应用中,你可以使用`kv`语言或Python代码来加载字体。在`.kv`文件中,可以设置`<Label>`或其他文本类的全局样式,例如: ```kv Label: font_name: 'path/to/微软雅黑.ttf' ``` 或者在...
5. **其他资源**:可能包括图片、字体或其他支持播放器运行的素材。 总的来说,MP3跨域音频频谱AS3播放器是Web开发中的一个创新工具,它利用AS3的强大功能,结合频谱分析,为用户提供了既美观又实用的音乐播放体验...
### AS3的常用类和函数大全 在Adobe Flash平台中,ActionScript 3(简称AS3)是一种广泛使用的编程语言,适用于创建交互式应用程序、游戏和动画等内容。本篇文章将根据给定的信息来深入探讨AS3中的一些常用类和函数...
在标签“源码”中,我们可以查看到`LoadEmbedFont.as`文件,这很可能是一个用于加载并嵌入字体的AS3(ActionScript 3)脚本。在处理字体加载时,沙箱问题同样存在。如果SWF需要加载外部的字体资源,它必须确保正确...
如果不希望在编译时嵌入SWF,可以选择在运行时动态加载。使用 `Loader` 类可以实现这一功能: ```as3 var loader:Loader = new Loader(); loader.load(new URLRequest("myResources.swf")); loader....
- **文本渲染**:AS3提供了丰富的文本渲染功能,包括字体样式、颜色和排版选项。开发者可以根据需求定制文本的外观。 - **富文本支持**:富文本支持使得AS3能够处理包含多种格式和样式的文本内容,这对于制作复杂的...
### AS3 Starling 中文基础教程 #### 一、Starling 概述 **Starling** 是一个基于 **Stage3D** 技术构建的 **2D** 开发框架,适用于 **ActionScript 3 (AS3)**。它利用 **GPU** 加速特性,简化了 **Stage3D API** ...
AS会自动识别项目结构并加载所有模块。 在导入过程中,可能会遇到编译问题,如缺少SDK版本或NDK。此时,你需要在AS的设置中配置相应的Android SDK和NDK路径。进入`File` > `Project Structure`,在`SDK Location`中...
# 加载字体 my_font = fm.FontProperties(fname='C:\\Windows\\Fonts\\YaHei.Consolas.1.12.ttf') # 设置图例字体 plt.legend(loc='best', prop=my_font) plt.show() ``` 这段代码首先导入必要的模块,并准备数据...