actionscript

What is an elegant way to position 8 circles around a point

℡╲_俬逩灬. 提交于 2019-12-07 15:41:13
问题 var circles:Array = new Array(); for(var i:int = 0; i < 8; i++) { var ball:Ball = new Ball(); ball.x = ??? ball.y = ??? circles.push(ball); } What is the best way to position balls around some point lets say in 5-10 distance of each other, is there some formula? 回答1: for(var i:int = 0; i < 8; i++) { var ball:Ball = new Ball(); // Point has a useful static function for this, it takes two parameters // First, length, in other words how far from the center we want to be // Second, it wants the

How to make a Timer accurate? (Flash / ActionScript 3.0)

流过昼夜 提交于 2019-12-07 15:15:00
问题 I'm using the following method to dispatch a sound in X times/minute (X is determined through bpm, which is a NumericStepper object) var mainTimer:Timer = new Timer(60 / (bpm.value * 1000),0); mainTimer.addEventListener(TimerEvent.TIMER, fl_TimerHandler,false, 0, true); mainTimer.start(); function fl_TimerHandler(event:TimerEvent):void { metroTransform.volume = vol; flash.media.SoundMixer.soundTransform = metroTransform; metroChannel = metro.play(); mainTimer.delay = 60 / bpm.value * 1000; }

Flash events on mouse over

这一生的挚爱 提交于 2019-12-07 14:06:18
问题 Is there any way to find out what methods get called when moving the mouse over an object in a Flash project? 回答1: So far @rvmook's partial solution is the closest from my point of view. It would help if you use DisplayObjectContainer's getObjectsUnderPoint() method to get a list of display objects you roll over, then loop through them and check which one has rollover/mouseover event handlers, then continue drilling down. So one short solution would be: Load the swf you want to find out the

Is it possible to profile CPU / memory inside an Adobe AIR application?

◇◆丶佛笑我妖孽 提交于 2019-12-07 13:04:33
问题 Couldn`t find any ActionScript native APIs even in the beta documentation, am I right supposing that this means the only way to measure CPU / memory consumption is by cooking up a custom native solution, hooking it up with AIR and making it work on each targeted platform? Basically the aim is to be able to have this information available inside AIR and not having to use an external application for profiling, not even Flex / Flash builder. Thanks for the helpful answers, System.totalMemory

Automated testing (non-UI) for existing Flash component

自古美人都是妖i 提交于 2019-12-07 11:55:09
问题 I build and maintain a set of Flash components that is distributed to publishers and allows them to integrate with our system. Currently the component has no UI and simply contains compiled code for querying our system servers, parsing the response, and modifying the params sent in the query. There's an As2 version and AS3 versions for both Flex and CS3. Our typical workflow is like this: 1.) load the component 2.) set parameters on the component 3.) tell the component to query our system 4.)

How to play a sound in Actionscript 3 that is not in the same directory as the SWF?

こ雲淡風輕ζ 提交于 2019-12-07 11:45:37
问题 I have a project with a bunch of external sounds to a SWF. I want to play them, but any time I attempt load a new URL into the sound object it fails with either, Error #2068: Invalid Sound or raises an ioError with Error #2032 Stream Error // Tried with path prefixed with "http://.." "file://.." "//.." and "..") var path:String = "http://../assets/the_song.mp3"; var url:URLRequest = new URLRequest( path ); var sound:Sound = new Sound(); sound.addEventListener( IOErrorEvent.IO_ERROR,

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

How do I get flash to reload the parent HTML page it is embedded in?

一个人想着一个人 提交于 2019-12-07 07:25:09
问题 I have a flash app (SWF) running Flash 8 embedded in an HTML page. How do I get flash to reload the parent HTML page it is embedded in? I've tried using ExternalInterface to call a JavaScript function to reload the page but that doesn't seem to work. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ 回答1: Check the ExternalInterface in Action Script. Using this you can call any JavaScript function in your code: if (ExternalInterface.available) { var result = ExternalInterface.call("reload"); } In the

How to access top level package in ActionScript?

浪尽此生 提交于 2019-12-07 07:10:23
问题 I would like to access an ActionScript 3.0 top level function from a class of mine, in which a symbol with the same name ( trace ) as the top level function is already defined: class A { public static function trace():void { } trace("Test"); } I would like to call the global ActionScript trace function with trace("Test") , but this is not possible as another symbol function trace() is defined. In a case where the external definition which I would like to access would be located in a package (

Replacing character at a particular index with a string in Javascript , Jquery

▼魔方 西西 提交于 2019-12-07 05:28:29
问题 Is it possible to replace the a character at a particular position with a string Let us say there is say a string : "I am a man" I want to replace character at 7 with the string "wom" (regardless of what the original character was). The final result should be : "I am a woman" 回答1: Strings are immutable in Javascript - you can't modify them "in place". You'll need to cut the original string up, and return a new string made out of all of the pieces: // replace the 'n'th character of 's' with 't