actionscript-3

Make a parent function return in ActionScript3? (or make addEventListener return)

Basically I've got a code which should load a lot of images so I need a function to load them. The problem is that addEventListener requires a function which it will call when the event have been raised. I need to find a way to either make the loadImage function return ONLY after the event was raised or make the function raised in addE...

Flex: XMLList of attirubites.... convert to nodes?

say I have an xmllist like this (but with many other attributes not shown for brevity): <node metal="white gold"/> <node metal="yellow gold"/> <node metal="silver"/> and I access the metal attributes via xmllist.@metal which will give me a new xmllist like this: white gold yellow gold silver I want to convert that to an xmllist tha...

AS3: detect if sprite is viewable within scrollRect?

I there a way to "detect" if a particular sprite is within the viewable area of a scrollRect? I have a list of thumbnails in a scrollRect and I only want to load images for these thumbnails if and when the thumbnail sprite is visible in the scrollRect. Any tips or suggestions on how to accomplish something like this? ...

LocalConnection between different instances of the same SWF?

Hi, I'm building a simple audio player in AS3. I would like to embed multiple instance of this audio player in my html and when one's playing, others are paused. Is it possible to use LocalConnection to communicate between different instance of the same swf? From what I could test, once the connection is made with one instance, the othe...

Flex: Render an unrealized UIComponent to BitmapData?

What is the best way to render to a UIComponent which hasn't been added to the stage? (I'm using UIComponents as renderers for objects, and want to render new copies for image export, filtering, etc.) Two strategies I've seen/used so far include realizing the component to ensure it calls all the lifecycle methods: Add the component t...

Setting up Actionscript 3 compiling on Mac

I would like to do some Flash development on my MacBook, utilizing the Flex 3 SDK to compile Actionscript 3 into SWF movies. How would I set up my Mac to do this? I would also like to understand how the flash compiler interprets package names into a directory structure. I took a Flash class in high school, but it relied very heavily o...

Flash CS3 swf loaded inside flex issue (Bitmap)

I have loaded a SWF which is created in Flash CS9 (AS3). I'm having problem passing Bitmap (or BitmapData) from the flex app to the loaded SWF. Invoking of other functions in the loaded from Flex works, but when I try to pass a Bitmap to the loaded SWF, nothing happens. Here's a sample code: FLEX: try{ var bm:Bitmap = (someEvent....

as3 MouseEvent localX acting weird

Hi, I encountered this really weird situation, I have this bar and I addEventListener to it, so when the bar's clicked, trace localX private function _barClicked($e:MouseEvent):void { trace($e.localX) } The weird thing is that, when clicking at the same spot, sometimes it jump to a wrong number which I can't figure out why, I t...

AS3 - Why can't I use stage outside of my root class?

I have the following two classes: package { import flash.display.Sprite; import flash.events.Event; public class Main extends Sprite { public function Main():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void ...

Playing concatinated mp3 files through flash with as3

Hi! I have a list of mp3 files which I automatically build together to different, larger, mp3 files with the *nix command 'cat'. They work fine to play in any installed mp3 player I've tested them in, but I have also written a small, easy-to-use mp3 player in ActionScript 3 where I wanted to play my (concatinated) mp3 files over the web...

Actionscript 3: Solution for reading TAR archives?

Hi! Is there an as3 solution for extracting file content from uncompressed tar files around? / Jonas ...

How to rotate gradient along with sides of 3D cube in Flash - actionscript 3.0

Hello I got goal to achieve, 3d cube manipulated with mouse with gradient filling on each wall. I found some source codes coresponding to gradients and 3d rotating cube but here is the problem: When i put these two things together the effect looks like the cube was a wireframe with transparency to some gradient background hidden behind...

use actionscript 3.0 to detect class of symbol that is clicked

Hi, I am trying to create a simple drag and drop Flash program where a user can drag xmas ornaments onto a tree. Instead of being able to drag the ornament once, I want a function so that every time an ornament is clicked on, it adds a new ornament of the same class to the stage where the ornament is clicked. Currently I have this worki...

What does End Of File on a socket mean?

Using Action Script 3 in Flex Builder 3. When handling a SOCKET_DATA event, I occasionally, seemingly at random, get an "Error #2030: End of file was encountered." when calling socket.readInt(). I'm confused as to what this error means, since I'm not reading a file? I'm a little unfamilier with sockets. Thanks. ...

Actionscript 3.0 image scaling problems

I am currently building a Flash AS 3.0 application that allows a user to load images into a container, move and scale them and the outputs to a DB. Once the user has uploaded and scaled the images, they are directed to an album viewer which gets the photos out of the DB and puts them into heads. The issue i am having is that once the i...

Difference between custom metadata and static functions?

Custom metadata in Actionscript classes are very cool. You can put anything in square brackets in front of classes, functions, and variables; tell the compiler to include it (by name) in the SWF; and use describeType() to retrieve it. [MyMetaData(name1=value1, name2=value2)] Add to "Additional compiler arguments” -keep-as3-metadata+=...

Adding variables together using Actionscript

Hi Everyone - I am trying to translate this statement into Actionscript: "Sally is 5 years old. Jenny is 4 years old. The combined age of Sally and Jenny is 9 years." This is what I have so far: function getAges (sallyAge:Number,jennyAge:Number,combinedAge:Strin g) { trace("Sally's Age:" + sallyAge); trace("Jenny's Age:" + jennyAge); ...

Does Actionscript3 offer list comprehensions or lambda calculus?

I'm porting some code I prototyped in python over to flash and while actionscript doesn't suck quite as bad as I expected (I hear v3 is quite a lot better than v2!) there's still some stuff I'm having to do that seems overly prosaic / boilerplate e.g. summing a list... var a:int = 0; for each ( var value:int in annual_saving ) { ...

Streaming audio receives InsufficietBW from server, what should the player do?

My streaming audio player sometimes receives NetStream.Play.InsufficientBW and shortly after that, the NetConnection is closed. What should the player do in response to the InsufficientBW status? ...

Access stage from the "main" class

I have the following ActionScript: package { import flash.display.Sprite; public class Application extends Sprite { public function Application(){ width=1000; height=500; } } } Which I compile with mxmlc Application.as. What I have noticed is that Application is not the stage object, like I thought it would be, because t...