actionscript-3

Calculating Dictionary length in Flex

元气小坏坏 提交于 2019-12-23 08:56:44
问题 What's the best way to calculate the length of a Dictionary object in Flex? var d:Dictionary = new Dictionary(); d["a"] = "alpha"; d["b"] = "beta"; I want to check the length which should be 2 for this Dictionary. Is there any way to do it other than looping through the objects? 回答1: No, there is no way to check the length of an object(Dictionary is pretty much an object that supports non-String keys) other than looping through the elements. http://www.flexer.info/2008/07/31/how-to-find-an

Hide default options in right click context menu in flex

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 08:53:38
问题 I'm developing a flex application and I want to add it a context menu. I got it with this code: var myMenu:ContextMenu = new ContextMenu(); myMenu.hideBuiltInItems(); var defaultItems:ContextMenuBuiltInItems = myMenu.builtInItems; defaultItems.print = false; var item:ContextMenuItem = new ContextMenuItem("Go to google"); myMenu.customItems.push(item); item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelectHandler); this.contextMenu = myMenu; But I have a problem. The menu

Does MOUSE_WHEEL have a min delta value before it fires?

走远了吗. 提交于 2019-12-23 08:53:14
问题 I am having some trouble with MOUSE_WHEEL delta values. It seems like the event doesn't fire unless I REALLY spin the dammed wheel. Which makes sense because the only values I get range from 3-30. I was hoping to catch 1-3 as well because if I just spin a few notches, nothing triggers and the app feels sluggish. FYI every other program on my machine feels those 1-notch spins just fine so it's not the mouse. Will AS3 not fire if the delta is less than 3? Here is the code private function

AS3 - Can I know if a class implements an interface (or is a subclass of another class)?

独自空忆成欢 提交于 2019-12-23 07:56:18
问题 With this code function someFunction(classParam:Class):Boolean { // how to know if classParam implements some interface? } i.e. Comparing classParam with IEventDispatcher interface: someFunction(EventDispatcher) // returns true someFunction(Object) // returns false I know it can't be done with is operator. But, is there a way to do it? Is there a way to know if a class implements some interface? (or is a subclass of another class?) Possible solutions: A. Creating an object of classParam and

Is the stack limit of 5287 in AS3 variable or predefined?

天涯浪子 提交于 2019-12-23 07:27:13
问题 I ran a test just now: function overflow(stack:int = 0):void { if(stack < 5290) { trace(stack); overflow(stack + 1); } } overflow(); This always throws a StackOverflow error after 5287 calls. Error #1023: Stack overflow occurred. Is this limit variable (depending on machine specs, environment, etc) or is that a flat value defined somewhere? If I change the if statement to less than 5287, I don't get the error. 回答1: Obviously it's variable. Since all the calculations you really do are located

AS3: Refresh a Function

馋奶兔 提交于 2019-12-23 06:14:33
问题 In Action Script 3 is there a way to refresh a function? I guess what I am looking for is when I switch screens for a function to reset or refresh, also the function is tied into an Array so I don't know if that will effect anything. The program is working like this there are 59 numbers the user picks 5. So here is the code that I am using and the code I am trying to reset. var pickFive:Array = new Array (5); var m_iNextElement:int = 0; var b1:TextField = new TextField(); var b2:TextField =

Copy childs of one movieclip to another movieclip

送分小仙女□ 提交于 2019-12-23 06:12:38
问题 i have two movieclips container. MovieClip_1 MovieClip_2 now MovieClip_1 contains one child _child_1. now by pressing button i want to add that _child_1 of MovieClip_1 to MovieClip_2 without removing from MovieClip_1. i tried following code in button press event but it removes _child_1 from its past container. var mc:MovieClip = MovieClip(MovieClip_1.getChildAt(0)); MovieClip_2.addChild(mc); 回答1: It is not possible to add the same display object to two different parents. Trying to do so will

Copy childs of one movieclip to another movieclip

白昼怎懂夜的黑 提交于 2019-12-23 06:12:02
问题 i have two movieclips container. MovieClip_1 MovieClip_2 now MovieClip_1 contains one child _child_1. now by pressing button i want to add that _child_1 of MovieClip_1 to MovieClip_2 without removing from MovieClip_1. i tried following code in button press event but it removes _child_1 from its past container. var mc:MovieClip = MovieClip(MovieClip_1.getChildAt(0)); MovieClip_2.addChild(mc); 回答1: It is not possible to add the same display object to two different parents. Trying to do so will

Flash CS5…elements are snapping to pixels while moving?

南楼画角 提交于 2019-12-23 05:59:14
问题 I have an imported png in a 'info_icon' symbol. I have another imported png in a 'info_content' symbol. I have some code that allows you to drag an instance of a 'map' symbol around. Inside this map symbol are instances of 'info_icon' and 'info_content'. When I drag the map slowly, I can see the info_icon instances and info_content instances, jiggle ever so slightly...I think to line up to pixels. I'm trying to figure out how to stop that. I'm looking at the pixelSnapping property and it

Album art of music file

泄露秘密 提交于 2019-12-23 05:39:27
问题 Is There any way by which we can have album art of any music file , i am able to extract file detail like album name , length , author , genre , track info. But i am intresred in to showing album art image. Please help 回答1: Apparently someone on this page managed to write some code to extract the image's data as a ByteArray, then finally load it through a Loader object. Here's the code they came up with: var binaryData:ByteArray; var file:URLLoader = new URLLoader(new URLRequest("test.mp3"));