flex3

Why there are no private constructors in AS3 version of Singleton?

泄露秘密 提交于 2019-12-07 09:44:32
问题 I am confused: In AS3, why do we keep the Singleton class constructor public and not private , like in Java? If we keep the constructor public , then we can directly access it from the outside! Please check the MODEL part in this example. 回答1: Actionscript 3 does not support private constructors. In order to enforce the singleton pattern, many developers cause the constructor to raise an exception if there is already a singleton instance created. This will cause a runtime error, instead of a

Is it possible to do a #define in Adobe Flex?

两盒软妹~` 提交于 2019-12-07 02:15:34
问题 I'm looking for a way to do something similar to a c/c++ #define in adobe flex. I'd like to have lots of different paths a project build can take depending on wither or not something was defined. Does such a thing exist in flex? I know there is ways to set global variables but that wont really suit my purpose. being able to have structures with numerous #ifndefined and such is really what i'm in need of. thanks! 回答1: Actually MXMLC (the compiler in the Flex SDK) does support some limited

Resize images in Flex using as3

自古美人都是妖i 提交于 2019-12-06 16:38:18
I am loading an image using a Loader. Once loaded, I can get the bitmap data using Bitmap(event.target.loader.content).bitmapData . However since the images I am loading are quite large (around 2000 x 1600), I would like to reduce the size and create a new smaller bitmap maybe 200 or 300 pixels wide, sort of like a thumbnail. I think it has to do with creating a new BitmapData with the new size. However I am not able to get that working properly. Any ideas? Not tested, but this should give you an idea: public function scaleBitmap(src: BitmapData, ratio: Number): BitmapData { var bmd:

Positioning Flex/AIR Desktop App Window to the bottom right corner

二次信任 提交于 2019-12-06 10:42:48
问题 Any clues how this can be achieved? It needs to work on all resolutions .. is there any parent/stage object available to find out the resolution of the system? 回答1: public function init():void { nativeWindow.x = ( Screen.mainScreen.bounds.width - 300 ) nativeWindow.y = ( Screen.mainScreen.bounds.height - 65 ) } This is a 300x65 window positioned in the bottom right. You are looking for Screen. 回答2: Screen.mainScreen.visibleBounds takes the taskbar into account 回答3: Another option is to create

Display List ItemRenderer Index in Flex3

六眼飞鱼酱① 提交于 2019-12-06 09:55:13
Is there a direct way to get the item index of the data inside an itemRenderer? I need to display the item number against each item. I am currently doing a workaround and won't allow reuse of my itemRenderer component. var index:int = model.dataColl.getItemIndex(data) + 1; itemNo = index.toString(); This is what i am using now, it works, but the concepts of component reuse and data abstraction are compromised. I am using Flex 3. The first answer seems to be working, but slow. It takes O(n^2) time as it runs through dataProvider array to get item index each time. We can access rowIndex from

Connecting any database directly from flex

こ雲淡風輕ζ 提交于 2019-12-06 09:52:54
Is it possible to connect any database from flex directly? Not unless you use Adobe AIR for desktop at which time you'd be using the SQLLite api's to create/connect to a sqlite database file. http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html Anything else is going to require a back end service to handle such transactions. You can use asSQL as mentioned by michael, or use the Adobe Air runtime. However, this must be said about using this library: It is EXTREMELY insecure to have a straight database connection from the client unless it's from Adobe Air since the db is local.

Removing all event listeners in Flex

最后都变了- 提交于 2019-12-06 07:32:44
问题 How can I remove all event listeners on all components at once, especially when it is not known what listeners are attached to each component? 回答1: You can override mx.core.FlexSprite, which UIComponent inherets from, and generate an array of listeners created. Doug Mc Cune put up source code here. His blog says: removeAllEventListeners() – removes all event listeners of all types. This completely wipes out all event listeners for the component all at once. Let us know if this does the job!

Find the total bytes used by a bitmap in Flex

一世执手 提交于 2019-12-06 04:34:45
If I load a bitmap using a loader in Flex, I can use the loaderInfo.bytesTotal to get the size, total bytes used, of a bitmap. If I create a bitmap in run time, how can I find out the size, the total bytes used, by that bitmap. Please advice. Thanks var bitmapByteSize:int = bitmap.bitmapData.getPixels(bitmap.bitmapData.rect).length; That might do the trick. I think a better solution than the one above would be: var bitmapByteSize:uint = bitmap.bitmapData.width * bitmap.bitmapData.height * 4; This is because using the getPixels() method creates an additional ByteArray, so it's both slow and

HTTPService/ResultEvent with Flex 3.2 versus Flex >= 3.5

北城以北 提交于 2019-12-06 03:43:43
through a design decission or what-so-ever Adobe changed the content of the ResultEvent fired by a HTTPService Object. Take a look at following example: var httpService:HTTPService = myHTTPServices.getResults(); httpService.addEventListener(ResultEvent.RESULT,resultHandler); httpService.send(); /** * Handels the login process */ function resultHandler(event:ResultEvent):void { // get http service var httpService = (event.target as HTTPService); // do something } It works like a charm with Flex 3.2. But when I try to compile it with Flex 3.5 or Flex 4.0 event.target as HTTPService is null. I

flex 3 iterate through object values

心已入冬 提交于 2019-12-06 03:08:26
问题 i have an object which represents a database table. I want to iterate through this object and print printing each value. What can i use to do this? i want to do this inside my mxml not actionscript for each object attribute i want to create an imput field 回答1: Look up the documentation on Flex 3 looping. If you do, you'll find this: for..in The for..in loop iterates through the properties of an object, or the elements of an array. For example, you can use a for..in loop to iterate through the