ActionScript 3.0 :: Mixin Instead Of Include For Common Function?
Aug 12, 2010
If I have say a dozen classes, that may or may not be called at runtime, and that all have a common function; is there an advantage to creating a separate class with just this common function in it and then having it mixin at runtime ?I am wondering would this allow me to reduce the size of each class and thereby the swf file size? I figure this must be wrong else why would we ever extend anything when we could just mixin the functionality we want at runtime?
We are working on a project where we have multiple modules- all these share a common set of functions like rounding, string parsing etc.Currently, we have added these functions into the parent container (which calls these modules) and use them in the respective modules. Likewise, if we have to share variables between modules, we add them to the parent module- so it becomes shareable across.Is this the right approach- both from a performance and structure perspective?
how to implement a Mixin/Trait style system in AS3. I want to be able to compose a number of classes together into a single object. Of course this is not a language level feature of AS3, but I'm hoping that there is maybe some way to do this using prototype based techniques or maybe some bytecode hacking that I believe AsMock uses to implement it's functionality.
An existing Java example is Qi4J where the user define interfaces that the Qi4j framework implements based on metadata tags and coding by convention.
I am using an include file, and I've noticed that sometimes the the fla file does not refresh new changes to my include file. When exporting with "Ctrl, Enter" Is Flash loading the include file from the cache?
Simple question: In AS3 you can't do sharing of a MC between more MCs, right? In AS2, you can. How can I work around this?
Let me be specific: in ActionScript *TWO* I do something like this:
movie.attachMovie(LargeImage, "image", 20);
LargeImage = movie clip of 400 x 480.
Now... the thing is: I do this for 20 MovieClips but they all REUSE the same original MC apparently (with no memory increase, of course). If I animate the MC, it will animate within all 20 MovieClips. I'm using a mask to show only portions of the MC, but I think that's not important.
But in ActionScript 3 this wouldn't work, right?
Because in AS3 every time we .addChild, the child is REMOVED from the parent, so the same MovieClip / Sprite couldn't be in 2 places at once. How would you work around this without creating a separate instance of the "LargeImage" MovieClip for each object? Note that I don't want to use BitmapData & CopyPixels: the object may be animated.
In AS3 you can't do sharing of a MC between more MCs, right? In AS2, you can.Let me be specific: in ActionScript *TWO* I do something like this:
Code: movie.attachMovie(LargeImage, "image", 20); LargeImage = movie clip of 400 x 480.
Now... the thing is: I do this for 20 MovieClips but they all REUSE the same original MC apparently (with no memory increase, of course). If I animate the MC, it will animate within all 20 MovieClips. I'm using a mask to show only portions of the MC, but I think that's not important. But in ActionScript 3 this wouldn't work, right?
Because in AS3 every time we .addChild, the child is REMOVED from the parent, so the same MovieClip / Sprite couldn't be in 2 places at once.How would you work around this without creating a separate instance of the "LargeImage" MovieClip for each object? Note that I don't want to use BitmapData & CopyPixels: the object may be animated.
I need a calculator for a flex app I am making, and was wondering if there was any official widget prebuilt or already in good quality. I could make one myself but it would be nice to use one that already existed and had a nice api to customize it with.
Video format that play on any browser , with play/pause/stop buttons? i have the following code for .swf but i cant get any button to control. [code]...
is there a site out there that has a translation from all the common AS2 commands?I'm just learning AS3 now and i have no idea how to do the basic things such as _root.mc.loadMovie("asd.swf"); anymore
I want to know how to find the Least Common Denominator between two fractions so I can make them into integers. I understand to do this you probably need to get the denominator itself but I can't figure out a way mathematically to do this.
I've extended Sprite to add some common functionality - this is a generic class I use in most of my real-world applications.Everything "works", but I'm curious if there's anything I'm doing that could be done better, or if there are common tasks that should be included that aren't, or if there are members that aren't really that handy and perhaps could be omitted.
For example, there are several members to handle display-list traversal - I've kind of gone back-and-forth on this, and various versions have had methods to remove all siblings, or retrieve an array of elderSiblings and youngerSiblings,etc,but that seemed a little overboard so have been removed.The offsetWidth and offsetHeight are inelegant at best (so clumsy in fact I'm really leaning toward removing them entirely), but AFAIK there's no other way to get back the "true" height/width of an object whose first child is not a position 0.Also I'm curious about the event management overrides. I've run these on several commercial applications and have found them both useful and without any obvious drawbacks, but have never seen anyone else do anything similar,
Here is the code that I've got, I'm also using SWFaddress: Code: function whyPageLoad(event:Event):void { var link:URLRequest = new URLRequest("[URL]"); navigateToURL(link, "_self"); }
The swf exists on a page [URL] and the link above [URL] doesn't work/do anything. I tested the swf on a different URL and it loads the page correctly or if I load it into "_blank" it also works. So it seems to be something with the common URL string that is not causing a page reload.
I have a simple question that hopefully has a simple answer (which mocks me with its elusiveness). In the code below (taken from Gary Rosenzweig's "ActionScript 3.0 Game Programming University" (2nd ed.)), I am declaring a simple style sheet using all AS3 supported tags/attributes to underline an HTML link. My question is this: why won't AS3 underline the chosen font (Arial) but yet it will underline certain other fonts that I substitute it for (such as "Times New Roman" and "Garamond")?
Is there a way to set a common Backgroundcolor for all the tabs in a given TabBar? Rightnow I am able to set color only for selected tabs using tabBar.getChildAt and setStyle
I'm not a flash developer, I'm having issues figuring out how I should set up these two projects that I have in Flex Builder.I've already created projA which has a .mxml that references several custom controls & skins from com.xxx.controls within projA.I now have to build projB which also has a .mxml that will create a different .swf. I want to use some of the same controls from projA.I currently build projA through the command line and nant and will need to do the same for projB.
Should I create a new project to move all of the common controls into? How do I then use this library project in both the projects & compile via command?
The game is written in Flash, and I plan to develop the server in node.js because (a) it would be a cool project for learning node.js, and (b) it's fast, which is important for games.The server's architecture is based on messages sent between the server and client (sort of like Minecraft's server protocol). The message format I have so far is a byte (the packet type), two bytes (the message length) and that many bytes (the message data, which is a mapping of key-value pairs). Problem is, I really don't want to develop my own serialization format (because while I probably could, implementing it would be a pain compared to using an existing solution).Unfortunately, I am having problems finding a good candidate for the message data serialization format.
ActionScript's own remoting format might work, but I don't like it much.SON has support in node.js (obviously) and in ActionScript, but it's also textual and I would prefer binary for enhanced speed.MessagePack looked like a good candidate, but I can't find an ActionScript implementation. (There's one called as3-msgpack on Google Code, but I get weird errors and can't access it.)BSON has an ActionScript implementation, but no node.js support besides their MongoDB library (and I'm planning on using Redis).
I have a flex app that loads a WSDL at runtime and shares that across several different web services I have defined. Unfortunately each call to loadWSDL() makes a network request for it, and while it's not really a problem due to caching it's still annoying and wasteful to have all those requests generated. Is there a simpler way to solve this problem and only make one network request?[code]
I'm struggling with something that shouldn't be too difficult but I can't figure it out I have a number of Arrays with different values and I want to find the common values all of the Arrays have, see example below: var arrayOne:Array = ["1","2","3"]; var arrayTwo:Array = ["1","2","7"]; var arrayThree:Array = ["1","2","9","12"]; _resultArray = ["1","2"];
I would like to extract the most common color of a bitmap. My first idea was to do this by looping through the bitmapData and extracting every pixel color and storing it in an array. But the function has to be as light as possible so my question is; Is there a more lightweight approach to achieve this? The function is used to extract background color of a Bitmap.
url...I'm using this code i made some changes like changing the array for a xml.In some part i put a button to stop the movement and i used [code] and it works perfectly, but then i want to return with another button to the movement. and i can't make it work.
I'm building a media player with alot of tweens in the interface , I'm wondering what is common or exceptable in the professional flash community. When I tween the whole Interface into another view firefox spikes to 12 - 16 cpu on a 3.01 GHz duo-core. Is this normal? After the tween Firefox flunctuates between 2 - 8 cpu while idle.
I have created few actionscript projects and most of them uses same com/ dir with same classes library such are adobe or greensock.In Flash builder, on one of the projects, I`ve created new source path, to that common dir.So now I have structure like this: MyProject
[source path] com src (with AS documents) fla (flash file)
When I edit one of my AS files from src dir in Flash Builder, I can normaly see reference to [source path] com directory, and I have full tooltip reference to it`s content.
However, if I try to edit that same file in flash professional, I get no reference and there is no way I can compile file.What am I doing wrong, why flash professional does not see classes from my com directory? I even try to point it to that dir in actionscript settings but that did not work either.
Is there an online cheat-sheet to graphs of common tween / easing functions? I want a bookmark I can refer to when picking a function for a tween (e.g., Quintic, Quadratic, "Bounce"). The only one I can do in my head easily is linear.