ActionScript 3.0 :: Architecture Duplicate Functionality For Multiple Uninherited Classes?
Jun 8, 2011
I want to add some common functionality to a number of display object classes: Sprite, MovieClip, TextField, TLFTextField, Bitmap, Loader, SimpleButton, and possibly more.I can easily extend any one of those and add my code, but I would need to duplicate the same code across a bunch of classes, ie SuperSprite, SuperMovieClip, SuperTextField, etc.
So the options I've thought of: 1. Use includes, so each class extends whatever and simply includes the class code. I haven't tried this so I'm not sure you can even use includes like that, and I'm not sure how it might affect (break) code hinting.
2. Create a new class that takes a target reference and essentially wraps functionality on to any eligible target instance. I'm not crazy about this because it means the instance I'm dealing with isn't the actual display object (ie its some wrapper that references the display object.)
3. Create a core class that takes a target display object and encapsulates all the functionality, then create separate classes each that extend the various display objects and contain an instance of that core class with itself as the target. I think I like this idea but am sure I would come back later and be confused with the structure.
View 4 Replies
Similar Posts:
Nov 2, 2009
I had to create a menu using array and I had to animate it. With some great expertise from people, I've accomplished that. But now I have a question about OOP, because I'm trying to add functionality to the buttons to load swfs into my main movie. Even though I strictly follow tutorials and exercises, I can't figure out how to reference a variable made in one class to another. For instance, I have index.as, navbar.as, and menubutton.as. I assume I need to add a loader to my index.as. But I can't trace the loader in my other classes. I've been told to effectively accomplish this, it is best to use custom event dispatchers. But I'm lost on how to use them.
View 12 Replies
May 21, 2008
I'm trying to extend the functionality (not extend the class itself) of the netconnection.call() function by enclosing a netconnection instance in a class.What I'm attempting to do is have a function that I have defined as "call" make a call to mynetconnection.call("", null, ...rest). For example:
Code:
public function call(method:String, ...rest):void {
this.mync.call(method, null, rest);
}
I have tried repeatedly to do this, and it's not working. The rest parameter feeds the parameters into an array, but is there any way to undo that on the inside of the method and pass a pseudo-list of parameters to nc.call() so that it will see it correctly?Is it possible to duplicate the functionality of a ...rest parameter into another function?
View 9 Replies
Aug 18, 2005
I have 4 defined private arrays defined in the constructor of my class.Later down in one of the methods, im trying to push() variables into these arrays, but nothing seems to happen. I tried using this.arrayname.push(), but that doesn't seem to work either.do i need to manually push them by this.arrayname[arrayname.length+1] = "";
View 3 Replies
May 28, 2008
how to breakdown a given functionality into resuable classes.The style of scripting is very messy and lots of repetitive codes, as most of the time I just jump straight into scripting without prior planning (bad habit).Now with this component as a base, I want to learn how to manage my codes in a cleaner, more efficient way, OOP style. (I only get to know about how good and time-efficient OOP style programming is after I 'discovered' the Tween class a month ago lolx)For a start I will need some planning.. that's the place where I'm now stuck in..I've come out with the core items which I think should be as classes
1) Controller
2) Drag clips
3) Hit boxes
How much further should I break them down? Read from tutorials that generally classes should only perform one task is that true? The controller deals with 2 tasks (handling events and 'calculation part'), should I break them into 2 separate classes?From tutorials I also get to know that we can assign a class to a symbol in the library. Is it possible for to attach classes at runtime to script generated or existing timeline instances? something like instanceName = new classFunction(parameters) ?
View 6 Replies
Nov 4, 2011
I'm loading a number of MP3 files into my Flash (the number changes dynamically). I would like to be able to say, in total, how much longer all the files will take to load.
I can do this for each individual sound.Mp3.addEventListener(ProgressEvent.PROGRESS, test_function);
But each sound is loaded by an instance of my sound loader class, how can I pass the ProgressEvent up to the parent object, and then have it calculate the total time to load?
View 1 Replies
Jan 9, 2010
The examples I'll use don't do anything - they're classes without ANY members - no variables, methods, anything.
Let's say I extends Sprite and call it MySprite.
I save it in test.core
[code]...
Now I create another custom class called MyWindow that extends MySprite.
I save it in test.windows
[code]...
Then I create another class that extends MyWindows (the example I'll use is a document class - but that doesn't matter - I've tested using an instance too).
[code]...
Notice that I'm not even trying to instantiate the helper classes - just having them there throws the error.
If there is only a single helper class, everything runs fine.
Also note that - as far as I can tell - this only happens when extending one class from another package, then extending that class with more than one helper object.I'm pretty sure there's no namespace bumps or typographical errors, as this is a very pared-down version of the original application.
EDIT: seems the problem exists even without the crossing packages - even extending MySprite in the document class with multiple internal classes generates this error.
View 4 Replies
Jul 4, 2010
i am using get and setters in my as3 code to edit values of an other class (because those variables are shared) i dont like to put stage.sharedVar.isScrabble in my code every time to change a variable so i used get/set functions [code]as you van see it has a lot of duplicate code every time the "return stage.sharedVar." and the "stage.sharedVar."+ the value + " = val" is constantly comming back.i was wondering is there a other way of creating these get/sets?[code]
View 3 Replies
Apr 11, 2011
that how can i duplicate a movieclip to as much numbers i want through out the stage using actionscript2. i have searched lots of posts in sites but i can't get it
View 6 Replies
Dec 29, 2010
i inherited a slideshow type of movie at work and there is one part of the movie that takes up 37 slides (all duplicates). i need to edit the text on them all. can i do this easily or do i have to go through and change them all manually?
View 1 Replies
May 4, 2006
i'we tried for years to duplicate multiple movie clip and then hittesting them all but i can't this is my last resort
View 2 Replies
Dec 2, 2010
I am trying to make a frame arround an uploaded picture by repeating 1 image over and over again. The user will have to enter the real dimentions of the picture and the image will be scaled acordingly so that the frame will look as big as it should. The problem is that when I get a bigger pickture and I scale the images something goes wrong and there is some smearing in the movie clip. When I move it to X:0 and Y:0 all is well. When I move it to the center of the screen the smearing is there. Here's the code I use:
[Code]...
View 3 Replies
Jul 7, 2011
I think I inherited bad code, here's the deal: In my command, I create a local var for the remote object and then call a method on it. In the result, if there's no data, I start a timer. This timer broadcasts an event every 2 seconds that continually calls this command until data is returned. Then the timer is stopped.
What we're seeing is that the method returns data once, and then the next time it doesn't (dupe Flex sessions error). It basically alternates. If we click really fast, sometimes we'll get two to work in a row. At times, the Java dev is seeing these requests returned with different JSESSIONIDs. I believe this is causing the duplicate Flex sessions error. I'm using Cairngorm; here's the execute command.
public function execute(event:CairngormEvent):void
{
ruleName = (event as FetchReportEvent).ruleName;
var ro:RemoteObject = ServiceLocator.getInstance().getRemoteObject("quantRemoteObject");
if (model.guid != null)
[code]....
View 1 Replies
Aug 18, 2011
I'm dynamically loading JPG file using Loader class. Everything works except if I want to tile the image few more times using addChild(loader.content) it just doesn't work. It always removes previous instance and leaves only the last one. I've tried everything but with no luck. Here's my code:
var loaderContext:LoaderContext = new LoaderContext(true);
var imageLoader:Loader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaderDone);
[Code]....
View 2 Replies
Aug 14, 2009
I am trying to duplicate a loaded movie clip multiple time. Below is the code. how to dublicate it using loadClip method.
ActionScript Code:
var thumbImgLoader:MovieClipLoader = new MovieClipLoader();
var thumbImgListener:Object = new Object();
thumbImgListener.onLoadProgress = function(target:MovieClip):Void {
[Code].....
View 1 Replies
Dec 8, 2009
I have a full page calendar that uses a duplicate movieclip to add the day squares (actionscript adds the day number)
I want to add a target to that "day" movieclip. (I can do this)
Now the part i don't know how to code:
I want to add a star at the top that can be dragged to the target "day". BUT... On any of the days and multiple days.
So i guess the star needs to duplicate movieclip and be able to drag and drop to any of the targets. The target is on a duplicate movieclip itself so the instance name will need to be the same on all days (or i could have it append 1,2.3 ect to the end of the instance name like: target_mc1, target_mc2...)
View 1 Replies
Jan 20, 2012
I want to use RTMP based HTTP DVR functionality and HLS based IOS functionality, So I need to know how to MPP from my existing DVR app to the livepkgr app so that the stream being recorded at the DVR app can be used by the Flash and Stream MPP over to livepkgr app and can be used by the IOS HLS.
View 1 Replies
Nov 5, 2009
How do you subclass multiple classes. I have a class that subclasses MovieClip. I added a new feature. Now its yelling that my class needs to subclass SimpleButton. I know there both part of the display class. But how do you subclass that?
View 1 Replies
Oct 18, 2010
I'm trying to compile AS files using the mxmlc but the particular class depends on other classes. My command is something like this: mxmlc -includes classA classB -source-path=. com.example.com.classC.
This gave me classC.swf but when I loaded it, it was still looking for classA.swf and classB.swf. Is there anyway I can have just one swf file?
View 1 Replies
Nov 14, 2011
multiple classes and then register each movieclip from the library to a different class? It isnt working for me. I created two different classes and created two entire different movieClips and registered each movie clips to a different class. However, I can only use on movieClip at a time, when I use the duplicateMovieClip. command to create copies of the movieclip, i find that only those movieclips, whose class i declared first, appear on stage
View 2 Replies
Nov 28, 2009
I'm trying to set up an AS3 project using a single package, that will have multiple classes coded in seperate files.I am looking for examples and tutorials for this kind of project.As I understand it, these files must have the same package, and their class must be public. This will allow the multiple files and various classes to be used in the single package.[code]Either of both of these files could then be imported into the main movie and their classes / functions used in the package.
View 6 Replies
Dec 27, 2009
Is there a way I can load an xml-file in a separate as-file and use this for multiple classes? (Or, should I load the xml-file in every class I want to use it in)
for example i set up a basic xml structure
test.xml
Code:
<xml>
<first>use this data in the first class</first>
<second>use this data in the second class</second>
[Code].....
View 1 Replies
Dec 5, 2009
So, what exactly are the rules on several classes inside of one AS file?So far, the only way I have been able to do this is by putting the class outside of the package brackets with no namespace selected (which I believe means 'internal' by default, right?)[code]So, using this notation, I'm wondering if a few things are possible:
1. Putting several 'secret' classes in the same AS file?
2. Making these classes public via the "Main" class, the one that the AS file is actually made for?Both examples applied here. Are these the right ways to do this?:[code]
3. Since these classes are marked as internal, they should be available to classes which extend the Main class AND classes in the same package without any import statements, correct?
4. Does embedding classes like this affect performance in any way?
5. Will these embedded classes always be compiled even if they are never accessed or referenced, similar to Library items or other classes?
View 3 Replies
Mar 8, 2010
I am attempting to use multiple AS3 timers to run a short animation in flash but I'm having a problem with some of the instances running slowly or not being removed when they are supposed to. I found a way to make things work the way I want but in being new to AS3 I believe my runtime issues are due to jumbled code.
import fl.transitions.Tween;
import fl.transitions.easing.*;
var playerFadeTween:Tween=new Tween(thewebs, "alpha", Strong.easeOut, 0, 1, 2, true);
var playerXTween:Tween=new Tween(thewebs, "x", Strong.easeOut, 292, 10, 2, true);
[Code].....
View 1 Replies
Jan 15, 2011
I'd have thought this to be simple, but nothing works. I have a game I'm working on, and in it, there will be a speed stat. The fast you are going, the faster everything else has to move to make it look like you are moving faster.The problem is, the speed stat (obviously not called speed) is one of the upgradable stats, and needs to be available for the class handling upgrades for it to be changed, and it needs to be read by the class handling moving objects.The second class however, has absolutely no idea the variable even exists. I've tried for weeks to look up a tutorial on it, but there doesn't seem to be any at all that I can find. (I am using public variables, and have tried various ways of trying to point at the class it's from but apparently I must be using the wrong syntax)
View 12 Replies
Jul 16, 2010
I'm creating a class that extends another class.
public class ASClass extends UIComponent{
}
but I'm trying to make it extend multiple classes. Is this somehow possible? I read it may be possible through composition?
View 2 Replies
Mar 31, 2012
I'm adding a TextField with html text. I'm applying a StyleSheet to it.
How do I apply multiple classes on my html element like so
<span class='classOne classTwo'>my text </span>
I tried this and it looks like flash can't handle this, it renders text without any styles.
View 3 Replies
Dec 31, 2009
I have a document class of particles and i'm trying to add multiple instances of the class...
[Code]....
is this the correct way to add multiple instances of the class to the stage?
View 3 Replies
Jan 13, 2012
Say if the structure of my game is set up like this:mainMenu- Classes inside the mainMenu package.instructions- MainMenuButtonClass.- Other classes inside the instructions package.game- MainMenuButtonClass.- Other classes inside the game package.The class MainMenuButtonClass is a button that, when clicked, directs the user to the MaiMenu and is identical in both the instructions package and the game package. Would it make sense just to save the same file in two locations or is there a better way to handle it.I'm not trying to access variables between the two classes. I'm not looking for any code either.
View 2 Replies
Sep 2, 2010
I've been searching the internet for how to use scenes in flash games, and from what I understand it got some problems? MY problem is that i cant really understand what the problem is and I cant find i "clean" explanation.
Some say you dont should use scenes in game development, some say you should?? Im confused.
Another thing that i dont understand quite is the document classes. Should i have one document class for every scene or one for all of them?
If i have 2 scenes with it's own document classes, how do i switch between them?
View 4 Replies