這篇文章描述了使用 compress 並不會減少實際記憶體使用量
以及解決方法
http://etrex.blogspot.com/2011/05/bytearraycompress.html
2011年5月18日 星期三
2011年4月26日 星期二
Import fl components into Flash Builder
Download fl packages
http://apdevblog.com/update-using-flvideo-package-w-eclipse-and-fdt3/
Export fl.* components
http://joshblog.net/2008/02/10/how-to-use-the-flash-cs3-component-set-in-a-flex-builder-actionscript-project/
add above swc to the build path of your flash builder project.
http://apdevblog.com/update-using-flvideo-package-w-eclipse-and-fdt3/
Export fl.* components
http://joshblog.net/2008/02/10/how-to-use-the-flash-cs3-component-set-in-a-flex-builder-actionscript-project/
add above swc to the build path of your flash builder project.
2011年4月24日 星期日
2011年4月18日 星期一
Passing parameters to ActionScript from HTML query strings
URL String: http://me.com/index.html?name=redbug&bday=0314
Method 1: root.loaderInfo.parameters
1. get query strings in url by javascript
- window.location.href
- window.location.search
- <object><embed src="Foo.swf?name="redbug&bday=0314/></object> or
- Using FlashVars to pass variables to a SWF
Method 2: ExternalInterface.call('javascript function name')
receiving parameters in ActionScript
Reference:
Flex程序如何获取html容器传递的URL参数值
ActionScript JavaScript Communication
ActionScript 3.0 Cookbook - Chapter 22 Building Integrated Application
2011年4月13日 星期三
[BulkLoader] Failed to get content with url as type: [class Bitmap]
今天試玩Google image search API, 用bulkloader來載圖,
在flash builder上run的好好的,但放在網路就無法執行。
後來trace bulkloader的ImageItem.as source code
才發現bulkloader在發生cross domain security error時,並不會把err丟出來,反而是把載好圖的loader丟給上層。
回去翻文件,才發現其實文件有寫... XD
所以原本寫的
addChild( imageLoader.getBitmap( key ) );
改寫成
addChild( imageLoader.get( key ).content );
就不會有cross domain security 討人厭的問題了.
Ref:
http://groups.google.com/group/bulkloader-users/browse_thread/thread/31189ad472fb1d90
在flash builder上run的好好的,但放在網路就無法執行。
後來trace bulkloader的ImageItem.as source code
才發現bulkloader在發生cross domain security error時,並不會把err丟出來,反而是把載好圖的loader丟給上層。
回去翻文件,才發現其實文件有寫... XD
SecurityError
BulkLoader can handle SecurityErrorEvents. By listening to BulkLoader.SECURITY_ERROR("securityError"), client code can gracefully handle security error events. Listeners can be added to each LoadingItem subtype or to the entire BulkLoader object. Please note that if you add an event listener for a LoadingItem but not for BulkLoader, in case the event fires, it will bubble up and result in a unhandled security error. In order to make sure the error never goes unhandled, add a securityError handler to the BulkLoader instance.
This mechanism will catch events thrown on
.load operations. Event thrown when trying to access content (such as getBitmapData) is still left to client code to handle.When using type=image or type=movieclip (which are loaded using a Loader instance), if, when the asset is loaded, accessing it's loader.content throws an error, then BulkLoader will gracefully recover and use a simple Loader instance. This way, you can still add a Loader object to the stage, but won't be able to run code inside of it (for MovieClip instances) or load it as data (transforming to BitmapData instances).
In this case, you can get the Loader instance either using getContent or getDisplayObjecLoader .
所以原本寫的
addChild( imageLoader.getBitmap( key ) );
改寫成
addChild( imageLoader.get( key ).content );
就不會有cross domain security 討人厭的問題了.
Ref:
http://groups.google.com/group/bulkloader-users/browse_thread/thread/31189ad472fb1d90
2011年4月8日 星期五
AS3 flickr API
先申請Flickr API Key, non-commercial就可以了.
這個下方有列出很多可用的API
這個library會用到as3corelib, 所以先裝一下
這個人為as3flickrlib寫了一個example
從上面這個網頁抓一下他的 flickrGrabber class
trace 他的code,再比對一下 http://www.flickr.com/services/api/
大概就知道怎麼用或hack as3flickrlib了...
必須先將query string用encodeURI()做編碼再送UrlRequest,否則flickr會回傳查無結果。
(這部分要感謝卡卡米教教!! :D)
(這部分要感謝卡卡米教教!! :D)
下面是兩篇有用的參考:
要求Flickr在收到search request時丟回Photo list 的Thumbnail urls
http://www.flickr.com/services/api/flickr.photos.search.html
有個
extras (Optional) 參數把"url_t" assign給extras, flickr就會在search result中加上<url_t>這個tag, 並且把 thumbnail url 內嵌在裡面丟回來。
2011年3月16日 星期三
2011年2月14日 星期一
A rest for your SWF
試過了, 可以work.
好用的trick!
http://imagineric.ericd.net/?p=353
Well, it works for a SWF, but if you’re deploying a projector it doesn’t want to work correctly. It loads nothing in the projector’s viewport. It works if you launch the SWF as a standalone or in a browser.
好用的trick!
http://imagineric.ericd.net/?p=353
Well, it works for a SWF, but if you’re deploying a projector it doesn’t want to work correctly. It loads nothing in the projector’s viewport. It works if you launch the SWF as a standalone or in a browser.
2011年1月19日 星期三
Uniquely random number array generation
http://ticore.blogspot.com/2011/01/as3-unique-random-number.html
三招都很cool!
尤其第三招用了Array.RETURNINDEXEDARRAY會回傳不重覆index array的特性.
超酷!!
Array.RETURNINDEXEDARRAY的用法可參考下面這篇~
http://blogs.adobe.com/actionscriptdocs/tag/returnindexedarray
Ticore大大還用Array.RETURNINDEXEDARRAY
實做簡潔的連續整數(0-n)array
http://ticore.blogspot.com/2011/01/as3-fast-way-generate-integer-sequence.html
三招都很cool!
尤其第三招用了Array.RETURNINDEXEDARRAY會回傳不重覆index array的特性.
超酷!!
Array.RETURNINDEXEDARRAY的用法可參考下面這篇~
http://blogs.adobe.com/actionscriptdocs/tag/returnindexedarray
Ticore大大還用Array.RETURNINDEXEDARRAY
實做簡潔的連續整數(0-n)array
http://ticore.blogspot.com/2011/01/as3-fast-way-generate-integer-sequence.html
Trick on iterating array concatenation
nice trick!!
http://blog.eddie.com.tw/2011/01/18/faster-array-concatenation-in-as3/
array1.push.apply( array1, array2);
http://blog.eddie.com.tw/2011/01/18/faster-array-concatenation-in-as3/
array1.push.apply( array1, array2);
2011年1月9日 星期日
2010年12月2日 星期四
Dispatch Custom Values via DeluxeSignal
http://groups.google.com/group/as3-signals/msg/474cc2ec4e122be1?pli=1
Yes ,that works. Thank you Robert for a fast response. On Sep 17, 1:50 am, Robert Pennerwrote: > Try new DeluxeSignal(this, IEvent, String,int); > Sorry this isn't well-documented. > Robert > On Sep 16, 4:17 pm, iki_xx wrote: > > How can I dispatch custom values via DeluxeSignal? > > Meaning: > > new DeluxeSignal = new DeluxeSignal(this,String,int); > > deluxeInstance.dispatch(new GenericEvent(),'"foo",999); > > it doesnt work , I get runtime errors : Value object <[object > > GenericEvent]> is not an instance of <[class String]>. > > how can I dispatch/catch those parameters ? > > Do I have to extend the GenericEvent class, and add those parameters > > to the subclass of the GenericEvent class? > > Thanks
2010年10月21日 星期四
Vector Initialization with an Inline Array as Source
private const vec:Vector.<Number> = new Vector. <Number>( [0.1, 0.2, 0.3, 0.4] );
The Vector initialization fails silently, i.e. the compiler will not throw any error during the compile time,when you put the identifier "new" prior to the Vector initialization statement.
The Vector initialization fails silently, i.e. the compiler will not throw any error during the compile time,
2010年10月18日 星期一
Objects Sliding on Horizontal Floor (As if there is no friction)
http://www.box2d.org/forum/viewtopic.php?f=4&t=66
Right, there is no rolling friction in Box2D. I can certainly add this. I can also add linear/angular damping. I think I'll do the latter first. For now you can just multiply the linear/angular velocity by a number slightly less than 1 each time step (like 0.95). You can also generate some energy loss by reducing the friction. Then the circles will slide a bit more and slow down, instead of sticking and rolling.
I finally solved this problem by using b2Body.SetLinearDamping()
Right, there is no rolling friction in Box2D. I can certainly add this. I can also add linear/angular damping. I think I'll do the latter first. For now you can just multiply the linear/angular velocity by a number slightly less than 1 each time step (like 0.95). You can also generate some energy loss by reducing the friction. Then the circles will slide a bit more and slow down, instead of sticking and rolling.
I finally solved this problem by using b2Body.SetLinearDamping()
Why Dynamic Bodies Are Never Sleeping in Box2D World ?
What's the fucking bug!!
I figured out why they aren't sleeping. If gravity is greater than 60 then the bodies wont sleep. With 2.0.1 bodies will sleep with gravity as high as 100. The same issue manifests for setting forces directly to objects.
2010年10月13日 星期三
AS3 Signals
AS3 Signals Project Site
http://github.com/robertpenner/as3-signals
AS3 Signals Tutorial Video
http://johnlindquist.com/2010/01/21/as3-signals-tutorial/
Reflecting on AS3 signals
http://alecmce.com/as3/reflecting-on-as3signals
Nice example and clear explanation
http://blog.tkassembled.com/83/
Robotlegs and AS3 Signal Example
http://www.newtriks.com/?p=785
http://github.com/robertpenner/as3-signals
AS3 Signals Tutorial Video
http://johnlindquist.com/2010/01/21/as3-signals-tutorial/
Reflecting on AS3 signals
http://alecmce.com/as3/reflecting-on-as3signals
Nice example and clear explanation
http://blog.tkassembled.com/83/
Robotlegs and AS3 Signal Example
http://www.newtriks.com/?p=785
2010年10月12日 星期二
亂數球體座標
以下轉自ptt flash版
作者 kyzusmugoe (阿達達~鬼王達) 看板 Flash
標題 [問題] 想請教"亂數球體面積座標"的公式
時間 Wed Sep 15 21:58:44 2010
借用cj神的zedbox做demo一下~
swf : http://tinyurl.com/277plu2
其實wiki搜尋"球座標系"裡面就有答案 http://tinyurl.com/24796s6
以下是改過的code~
var rd:uint = 500;
var inclination:Number;
var azimuth:Number
for (var i:uint; i < 200; i++ )
{
var zs:ZedSprite = new ZedSprite();
inclination = Math.random() * Math.PI * 2;
azimuth = Math.random() * Math.PI * 2;
zs.x = rd * Math.cos(inclination) * Math.cos(azimuth);
zs.y = rd * Math.sin(inclination) * Math.cos(azimuth);
zs.z = rd * Math.sin(azimuth) ;
container.addChild(zs);
}
作者 kyzusmugoe (阿達達~鬼王達) 看板 Flash
標題 [問題] 想請教"亂數球體面積座標"的公式
時間 Wed Sep 15 21:58:44 2010
借用cj神的zedbox做demo一下~
swf : http://tinyurl.com/277plu2
其實wiki搜尋"球座標系"裡面就有答案 http://tinyurl.com/24796s6
以下是改過的code~
var rd:uint = 500;
var inclination:Number;
var azimuth:Number
for (var i:uint; i < 200; i++ )
{
var zs:ZedSprite = new ZedSprite();
inclination = Math.random() * Math.PI * 2;
azimuth = Math.random() * Math.PI * 2;
zs.x = rd * Math.cos(inclination) * Math.cos(azimuth);
zs.y = rd * Math.sin(inclination) * Math.cos(azimuth);
zs.z = rd * Math.sin(azimuth) ;
container.addChild(zs);
}
======================================
作者 cjcat2266 (CJ Cat) 看板 Flash
標題 Re: [問題] 想請教"亂數球體面積座標"的公式
時間 Fri Sep 17 22:53:08 2010
其實有另外一招超簡單的偷吃步喔
就是直接用random做出一個亂數(x, y, z)座標向量
然後把這個向量標準化(normalize)之後調整長度為RADIUS
var x:Number = Math.random() - 0.5;
var y:Number = Math.random() - 0.5;
var z:Number = Math.random() - 0.5;
var factor:Number = RADIUS / Math.sqrt(x * x + y * y + z * z);
x *= factor;
y *= factor;
z *= factor;
以上code參考自Flint Particles的SphereZone class
Stardust也是用這種方式取得亂數球體座標
雖然不是說很"均勻",但是我個人覺得夠用了
重點是計算很簡單,不太需要什麼大腦XD
2010年10月6日 星期三
One swf, multiple Classes, multiple ApplicationDomains
讓interface在第一個frame載入,
implementation放在第二個frame載入.
好處是implementation可以在runtime抽換?
2010年8月27日 星期五
Display Frame Rate
1. create a TextField named "frameRate_txt"
2. put following codes in the first frame of a flv file.
2. put following codes in the first frame of a flv file.
訂閱:
文章 (Atom)
