actionscript-3

Confused about garbage collection and events with weak references in actionscript 3.

I have a reference to an object. This object has a timer event with a weak reference. Example: timer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true); Now I remove this reference (test is the variable containing the reference): test = null; And yet, the timerHandler keeps being fired. Is this impossible, so that I m...

How do I tell a DataProvider to update?

I'm using an array to populate a DataProvider, which I'm using to populate a list component. Like this: var myDataProvider = new DataProvider(this.myArray); this['list'].dataProvider = myDataProvider; When changes are made to the array, I want to tell the DataProvider to update so that those changes will be reflected in the list compo...

Getting a Specific Object from a Loader in Actionscript 3.0

Hello. I am learning ActionScript 3.0 and I am seeing this paradigm often: package util { import flash.display.Sprite; import flash.display.Bitmap; import flash.display.Loader; import flash.display.LoaderInfo; import flash.net.URLRequest; import flash.events.Event; public class BitmapLoader extends Sprite ...

Howto extend Loader class and return cached assets in actionscript / flex 3?

I've been trying to create an universal asset loader class (with help of the folks here at stackoverflow), which remembers previousely downloaded assets by storing them in an associative array. This is the end result: AssetLoader.as package { import flash.display.Loader; import flash.events.Event; import flash.net.URLReque...

EventListeners de-registering themselves?

I've got a small sprite that is the "smoke trail" behind a missile in a flash animation. I made a self-contained class to handle the creation and removal of itself: public class Spark extends Sprite { private var lifetime:Number = 15; private var gfxRef:MovieClip = new fx_particleTrail(); private var canvas:Sprite; public function ...

How do I access a movieclip symbol Directly? - Actionscript 3.0

I made a movieclip symbol called "SwordHolder" then went through ALL my animations and put the sword holder in the right spot on another movieclip (took me HOURS). I figured I could change the image in the SwordHolder movieclip symbol so I did all that. Well come to find out I'm having a really hard time figuring out how to change/add/...

Optimizing transition/movement smoothness for a 2D flash game.

Update 6: Fenomenas suggested me to re-create everything as simple as possible. I had my doubts that this would make any difference as the algorithm remains the same, and performance did not seem to be the issue. Anyway, it was the only suggestion I got so here it is: 30 FPS: http://www.feedpostal.com/test/simple/30/SimpleMovement.htm...

Unload embedded video in flash AS3 (skip intro style)

Here's the scenario: i've created an external.swf that contains an embedded video (FLV) in the timeline. i've created another swf file (player.swf) that loads the external.swf using this: var request:URLRequest = new URLRequest("external.swf"); var loader:Loader = new Loader(); loader.load(request); videoContainer_mc.addChild(loader);...

Actionscript 3 high precision time method (microseconds)?

I need a high precision time method in microseconds rather than milliseconds for actionscript, unfortunately I couldn't find much help on the web. I need such control in order to implement the usage of a fixed timestep in transitions as described in this article: http://gafferongames.com/game-physics/fix-your-timestep/, in order to solv...

Can I use other languages in a Flash file using AS3?

I want to create my own systems for flash (like a scoreboard and made a feedback system) but I honestly have no clue where to even begin when it comes to implementing such things using AS3. I know how to create say a scoreboard using PHP but then I have no clue at ALL how I would get that into my game using AS3. Any help/tutorials woul...

Keyboard Application - Best way to have multiple buttons add letter to textinput? Use event handlers?

I'm working on an application and I am building a "Keyboard" component for it. There are 30 keys on the keyboard and it doesnt seem to make practical sense to create an event handler for each button. When the button is clicked, its label should be sent out to a function which adds it to a textinput field. Should I just create a "click...

Flex: Access member variable by using a variable in the name

How can I access the member variable of an object by using a variable in the name. Example: Entries Object has properties 1, 2, 3, 4, 5. Normally I would access them by var i : int = Entries.1; var i : int = Entries.2; However, if I have a loop for (var j : int = 1; j < 6; j++){ trace(Entries[j]); } does not work. Entries.(j)...

Can I store objects in Python class members?

I'm writing a game in Python with the Pygame2 multimedia library, but I'm more accustomed to developing games with ActionScript 3. In AS3, I don't think it was possible to store an object in a static variable, because static variables were initialized before objects could be instantiated. However, in Python, I'm not sure if this holds ...

Flex custom button component

I want my custom button to look like the button sample below. More specifically, I want the width of the button to be determined by the width of the largest word in the label (i.e. width of "Elongated" in my example). The label must wrap, not truncate. And I want only one pixel between the top edge of the icon and my button's top edge. ...

Getting measured width of a button label

Is there a way to get the measured-width of a button label in flex based on its style properties at runtime? ...

How to make a flash file a link (clickable to go to a URL)

I am new to Flash. I am using Adobe Flash CS3 to create simple animations (images moving between keyframes). It produces a SWF file that I put on a website. I want the SWF file to be a link to a URL. How do you do that? Thank you in advanced! ...

Draw a Sine Wave Between Two Arbitrary Points in Actionscript 3

Drawing "flat" waves is easy, but I want to draw the wave between two points x1,y1 x2,y2 Here is the "flat" code: package display { import flash.display.Sprite; import flash.events.Event; public class SineWave extends Sprite { private var angle:Number = 0; private var centerY:Number = 200; private var ra...

UIComponent extended class isn't showing UIComponent extended class

I have 1 class (that is extending a UIcomponent) that is representing a component. In that component I create different instances of another class that is also a UIComponent but this class doesn't show up in de first class. I see that it is running and that it has the correct hights but I got the feeling that it doesn't show up with this...

E4X: Insert nodes in XMLList for missing date?

if I have an XML object like this: <a> <u date="2009-04-10" value="543"/> <u date="2009-04-11" value="234"/> <u date="2009-04-13" value="321"/> <u date="2009-04-14" value="66"/> <u date="2009-04-16" value="234"/> <t date="2009-04-01" value="43"/> <t date="2009-04-02" value="67"/> <t date="2009-04-03"...

Converting escaped html back into HTML string in flash

Using swfobject I'm passing a xml string containg html which i escape using php htmlentites. How would one go about converting it back to a valid xml string in flash as2? flashvars.xmlString = "&lt;?xml version='1.0' encoding='UTF-8'?&gt;&lt;names&gt;&lt;name&gt; Thanks ...