This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.MovieClip; | |
import flash.display.Sprite; | |
import flash.events.Event; | |
import flash.display.BitmapData; | |
import flash.geom.Matrix; | |
import flash.display.Bitmap; | |
import flash.geom.Rectangle; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.utils.Dictionary; | |
/** | |
* modified RichardLord's Signal version | |
* @see https://github.com/richardlord/Signals | |
*/ | |
public class Signals{ | |
private var nodeDict:Dictionary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Sprite; | |
import flash.display.StageAlign; | |
import flash.display.StageScaleMode; | |
import flash.events.Event; | |
import flash.events.KeyboardEvent; | |
import flash.events.TimerEvent; | |
import flash.utils.Timer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(some notepad++'s theme) | |
http://wiki.macromates.com/Themes/UserSubmittedThemes | |
(Textmate theme to Notepad++ (.tmTheme converted to .xml, go to [users]/AppData/Roaming/Notepad++, replace the stylers.xml with the xml file)) | |
http://framework.lojcomm.com.br/tmTheme2nppStyler/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
在使用Sprite的dropTarget属性的时候发现个容易混淆的问题 | |
//动态创建了一个sprite, 内部绘制一个矩形 | |
sprite.graphics.beginFill(0, 1); | |
sprite.graphics.drawRect(0, 0, 100, 100); | |
sprite.graphics.endFill(); | |
//同时舞台上绘制一个shape转换并转换成一个MovieClip | |
这2者性质是不同的, 可以trace下这2个容器的numChildren可以发现, 动态创建的sprite即使内部绘制图形, 它不属于一个新的显示对象, 而舞台上手动创建的则正好相反, 在fla中还无法创建出来默认有内部绘制图形的MovieClip。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 获取指定显示对象的实际长宽(不论是否在舞台或者是否指定scrollRect属性) | |
* @param dis | |
*/ | |
function getActualSize(dis:DisplayObject):Rectangle{ | |
// solution one | |
// var rect:Rectangle = dis.transform.pixelBounds.clone(); | |
// if(!dis.stage){ | |
// //maybe a bug issue?? this version could work, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
查阅Adobe文档发现ByteArray的shareable属性已经移入了下一版本的FlashPlayer中,也就是目前(11.4)即使设置了该属性,也无作用。 | |
也就是通过MessageChannel发送出去的是副本, 而不是引用。 | |
同时在新创建的Worker中获取主Worker(主swf文件的Worker)中该worker所设置的MessangeChannel时需要注意, 添加监听最好在最后阶段。 | |
例如: | |
在主文件中,我们这样设置 | |
worker = WorkerDomain.current.createWorker(Workers.HandleConcurrent, false); | |
mainToBack = Worker.current.createMessageChannel(worker); | |
backToMain = worker.createMessageChannel(Worker.current); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//将一张图片资源导入至Flash IDE中, 将其转化为MovieClip类型, trace它内部的这张图片得到的类型为Shape, 如果需要得到原始的Bitmap类型,需将库中对应图片资源添加链接名, 以作为BitmapData类型的子类, 同时得到的该Bitmap对象的大小为原始尺寸, (通过transform.matrix可以获得),如需获取在该mc中的实际尺寸(可以使用transform.concatenatedMatrix获取) | |
/**http://stackoverflow.com/questions/4408496/scale9grid-and-bitmaps-do-they-work-together-or-not**/ | |
/**http://www.ovidiudiac.ro/blog/2009/05/scale9grid-work-and-fail/**/ | |
//Graphics类有了beginBitmapFill方法, 实现Bitmap的9slice就方便了很多 | |
function convertBitmaptoScale9(mc:MovieClip, scale9Grids:Rectangle):void{ | |
var b:Bitmap = mc.removeChildAt(0) as Bitmap; //获取到的是Bitmap而不是Shape,就是因为在库中取了链接名 | |
var topDown:Array = [scale9Grids.top, scale9Grids.bottom, b.height]; | |
var leftRight:Array = [scale9Grids.left, scale9Grids.right, b.width]; | |
var g:Graphics = mc.graphics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.MovieClip; | |
import flash.events.Event; | |
import flash.events.MouseEvent; | |
import flash.text.TextField; | |
import flash.display.Stage; | |
public class TextScroll { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getActualBitmapData(dis:DisplayObject):Sprite{ | |
//TODO, the dis must be on the stage | |
var realBounds:Rectangle = dis.getBounds(dis.parent); | |
var c:ColorTransform = dis.transform.colorTransform; | |
var b:Rectangle = new Rectangle(0, 0, realBounds.width, realBounds.height); | |
var mt:Matrix = dis.transform.matrix; | |
var len:int = dis.filters.length; | |
if(len > 0){ | |
for(var i:int = 0; i < len; i ++){ | |
var temp:BitmapData = new BitmapData(realBounds.width, realBounds.height, true, 0); |