actionscript-3

Is Splice faster than Shift + Pop? Why?

烂漫一生 提交于 2019-12-24 01:05:41
问题 I've heard from some nonspecific sources that using a combination of shift() and pop() is faster than using splice() . I haven't run a benchmark test yet and will most likely not for a while since I'm out of town, but is this true, and if so, why? 回答1: If you don't need to retain the order of your Array, using .pop() is much, much faster than .splice() . .splice() will remove an element at a given index. What happens then is that every other element in the array after that one will need to

Cairngorm SequenceTask + URLLoader throws SecurityError because of missing user interaction

寵の児 提交于 2019-12-24 01:00:01
问题 I am trying to get an application to upload multiple client side generated images (not files, hence I can't use FileReference), while displaying the progress of the upload. This has proved to be way harder than it should be. I am using Cairngorm Task library to perform the following steps on an image generated on the client: Generate a BitmapData object drawing the contents of an area of the stage Encode the image as a JPEG asynchronously, as to show a progress bar (see http://dgrigg.com/blog

How can I use XPath with AS3 and get a result that still reffereced to the XMLDocument object?

不羁的心 提交于 2019-12-24 00:55:30
问题 I'm parsing a XML string into XMLDocument object. I want to search for a specific node using XPath technology by using XPathQuery.execQuery() - this function returns new XML object which means I need to convert it to a different XMLDocument object and lose the reference, how can I do that without loosing the reference? I'm using this XPath library of AS3. 回答1: Amarghosh has a good point. why aren't you using e4x ? here is the livedocs documentation for it http://livedocs.adobe.com/flex/3/html

Microphone detection Actionscript 3

戏子无情 提交于 2019-12-24 00:52:56
问题 I'm having a few problems detecting whether a microphone is detected or not. I'm running the function Microphone.getMicrophone() and that should return null if there is no microphone attached, or if the user has clicked Deny on the security panel, right? The problem I'm facing is, on some computers where there is no microphone installed, Microphone.getMicrophone() still traces out as [object Microphone] . So say for example the user doesn't have a microphone, and clicks allow in the security

Keep selection when refreshing datagrid in ActionScript

喜夏-厌秋 提交于 2019-12-24 00:47:50
问题 I'm working on my first ever AIR application with flashbuilder - just so you know. I've bound a mx:DataGrid component to a DataProvider which is a mx:HTTPService fetching an xml file with items. To keep the data up to data I'm polling the webservice on a given interval. My problem is that I loose the currently selected item in my DataGrid when the data is updated. I've tried to save the DataGrid.selectedIndex and set when the data is updated, but I'm not sure when to do it?! The closest I've

actionscript 3.0 transparent image floodfill

半世苍凉 提交于 2019-12-24 00:47:20
问题 I want to use bitmapData.floodfill() method to fill the image by using "onclick" event (like paint bucket does). But the problem is that this method doesn't work as i excepted when i use transparent images(png, gif). It will only fill using white color(or alpha=0 as i think) when i use something different (like blue, red, etc). This is how it looks when i fill Jerry mouse with red color clip2net.com/s/2nW65 and here is the example i used with Embed image: var container:MovieClip = new

Subtract (mask away?) a path by a circle shape

最后都变了- 提交于 2019-12-24 00:45:02
问题 I'm drawing a path in Flex using Spark:Path. I want to subtract a circle shape from this path, as in the following image: (The path is black and wide) Any ideas? I tried creating a mask using a Shape object but couldn't quite manage to create a mask that has a circular hole in it. 回答1: Found it. No masks involved. I took the Path and wrapped a Group around it: <s:Group blendMode="layer"> <s:Path id="connector" ... /> <s:Ellipse id="hole" blendMode="erase"> I set the blendMode to "layer" and

AS3 Cannot access stage from custom class

社会主义新天地 提交于 2019-12-24 00:44:46
问题 How can I access the stage and especially the width and mouse position of the flash Movie from a custom class? package classes { import flash.events.*; import flash.display.*; public class TableManager extends Sprite { public function TableManager() { sayStage(); } public function sayStage():void { trace(stage); } } } This will only return nill. I know that DisplayObjects don't have any stage until they have been initiated so you can't access the stage in your constructor but even if I call

Adobe Animate CC

人走茶凉 提交于 2019-12-24 00:39:16
问题 TypeError: Error #1034: Type Coercion failed: cannot convert "Um1" to flash.display.MovieClip Um1, Um2, Um3..... MovieClip Object in my Stage var Um: Array = new Array(); for (var i: int = 0; i < 10; i++) { Um[i] = "Um" + Number(i + 1); } this.addEventListener(Event.ENTER_FRAME, HitUm); function HitUm(event: Event) { for (var i: int = 0; i < 10; i++) { if(MovieClip(Um[i]).hitTestObject(car_mc.rabond_mc)) { trace(Um[i]); } } } 回答1: This line here: Um[i] = "Um" + Number(i + 1); is populating

how to efficiently track the use of space on a map, both objects and free areas

孤街醉人 提交于 2019-12-24 00:03:50
问题 OK I start with a blank map, which is 512x512 = 262144 pixels/locations. I need a way to efficiently draw some objects on it, and then be able to find the areas of free space, so that later more different objects can be added to these free areas. I cant figure out the best way to store this data, or algorithms to find the free areas. I had a working solution, but it took forever to compute. I'm working with AS3, in case that impacts what would be the best solution. Any Advice? thanks. 回答1: