actionscript-3

3D paralax layers impeding Flash framerate

I have created a Paralax effect in Flash 10 where I have about 5 layers each sitting on a different Z-axis. These 5 layers have been grouped in a symbol, so when moving the symbol around its x and y axis, the layers move in 3D perspective as expected. We need to dynamically render text on each layer, but the problem is, I am using addCh...

Removing invalid characters from string in AS3 ready for XML

I need some code for ActionScript 3.0 which will remove any characters which are not valid in an XML attribute. Have spent some time searching google and not found what I'm after. Can anybody help me out? ...

Flash CS4, frame head position following the mouse

I have a small script that moves the frame head backwards and forwards depending on where my mouseX coordinate is inside the main flash movie. Here's my code and it's working so far: function onEnterFrame(event:Event):void { var frame:Number = Math.round(mouseX / (stage.stageWidth / animation.totalFrames)); animation.gotoAndStop...

Custom Actionscript 3.0 Events: Build separate Classes for different purposes or use one for all?

I'm using custom Events in Actionscript 3.0 for the first time and I'm unsure about how to best design them. I need a couple of Events. Some of them need to transport different kinds of data and some don't. Now I don't know whether I should use a single class to implement them all or use separate classes for different kinds of purposes. ...

Flash AS3 javascript popup on Safari

Hi, I'm trying to do a popup window that is sized at 300x200 when clicking a button using the following code var jscommand:String = "window.open('http://www.mydomain.com','win','height=200,width=300,toolbar=no,scrollbars=yes');"; var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);"); navigateToURL(url, "_self")...

Action Script 3 get sounds total time and current time?

Hi, i have a player in flash action 3. i need to take a the total time of the sound file and current time of the sound file. how can i code like this. function onPlayProgress(evt:Event):void { var sndLength:int = Math.ceil(snd.length /(snd.bytesLoaded / snd.bytesTotal)); var seekbar = 100 * (channel.position / sndLength); ...

Why is iconField ignored for branch nodes with the Flex Tree component?

I'm using the iconField property of the Flex Tree to dynamically set the icon that a node should use. This works fine for leaf nodes but for branch nodes it doesn't seem to respect my iconField and instead just shows the default folder node. Here's a simple repro: <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absol...

Adobe Air - Read updates to File with FileStream

I'm trying to get two different apps to communicate through a file. I would like app 1 to append some text to a file, and app 2 to notice, and read the new bytes (not the whole file). There is an event, ProgressEvent.PROGRESS, that is supposed to fire when new data is available on a FileStream, but it only fires when I first open the f...

Flash-AS3: Calling a function in a Class from another Class (Part 2) via DispatchEvent

Hey this question is in reply to Joel Hooks's comment on an older question of mine (How to call a function in a Class from another Class?) I was able to fix my own problem using a public static var to reference one of my Classes, so in the other class I just needed to use the this keyword so it could be called. instance = this; // in N...

AS3 - getting symbols from an assets library WITHOUT Flex

Been searching around for a long time, and the only examples I can find for doing this are something like this: [Embed(source="Assets.swf", symbol="dog")] private static var _Dog:Class; public static function get Dog():MovieClip { return new _Dog(); } But this seems to be flex-only (I get the error "unable to resolve 'Assets.sw...

AS3 reflection. How to find out if a method is overridden?

Is it possible to use AS3 reflection to find out if a method was overridden? I need a method like: protected function isOverriden(methodName:string) : bool { //magic here! //... return awesomeLocalVariable; } So, I pass in the method name as a string and the isOverridden method yields true only if and only if the object...

Pretty Date Text in Flex / Flash / Java / C#

Is there a free library or class for formatting a date in a pretty way such as "5 minutes ago" or "yesterday"? I'd be satisfied with the same code in another language that I could port to Actionscript (like Java or C#) ...

Action Script 3 code design question

I have a simple flex3 project with and mxml file (with some as inside of it) and FMSConnection.as I have something like this public class FMSConnection extends NetConnection { //this methods is called from the media server public function Message(message:String):void { //how to display (add it to a textarea) this mess...

how to use the Function type in AS3 (var f:Function) for a method f(s:String)

i have a class that has something like this public class Foo { public var f:Function; public void method(s:String) { f.invoke(s); } } so i need to assign to the f a function that takes an argument f(s), something like myFoo.f = thefunction function(s:String) how to do all this, so it will work correctly ? ...

AS3 sortOn woes

Hi all, I have an Array called alarmQueue. I'm pushing a new arrays in to it with the contents [hours:int, minutes:int, seconds:int] and I'd like to use alarmQueue.sortOn() to sort the queue of alarms Ascending but I'm having problems getting my head around the logic. // the function to push the alarm in to a queue public function setAl...

Extract part of string in flash

Hi all, I have this string <p><img src="http://www.foo.com/bar.jpg"&gt;&lt;/p&gt;&lt;p&gt;other content here</p> I need to extract the src url . The img tag appears only at the beggining of the string. Thanks in advance. ...

AS3: Accessing custom class public functions from a MovieClip on a timeline

Hi, I've got a AS3 program with a Main.as custom class. In this class I load an instance of a 'menu' movieclip which has simpleButton instances inside... How do I access the Main class public functions by the menu movieclip buttons? I.e. Menu button -> gotoPage(5); (which is a Main public function) If I try to access the Main functio...

Making a smooth path from an irregular number of x,y points to simulate handwriting

Hi all I am trying to make a 'brush' tool in AS3 (pure, not Flex) which simulates handwriting, making strokes to be smooth instead of cornered. Then, the trace must be reduced to cubic bezier curves which can be dragged and deformed, affecting the previously drawn path (like the illustrator's pen tool). I'm tracking the mouse movement ...

How do disable a SimpleButton including changing it's appearance

Here is the premise: I have 10 buttons each with on normal state image (buttonX.png) and a mouseover state (buttonXglow.png). The buttons are created manually in flash, but referenced in my as3 main class. I need to add different states to the buttons. I want do the following: mark on of the buttons as selected, e.g. show it with the...

Loading .swc assets into array, in pure Actionscript 3 project

Hello, I know how to get Flash CS4 symbols into Flash Builder via .swc. The class names become available in the main class, but I can only instantiate those one by one, writing each name into the code. How can I loop through the .swc and load its assets in an array without mentioning their name, then obtain and use these names for inst...