Actionscript 3 :: Class Implementation With Interface?
Sep 11, 2011
I have created the following classes for sharing images. They implement an interface, but I need a way of switching between them with user interaction. I've done it the following way:As you can see, service 1 and service 2 implement iSharingServices, and inherit from PolimorphSharing.PolimorphSharing is simply and an abstract class that implements the methods I want public from Service 1 and Service 2. Those methods will then be overridden on the Service 1 and Service 2. Because I need a way to switch the service in runtime, I've created a gateway class that inherits from PolimorphSharing. I can then call it the following way:
private var sharingService:PolimorphSharing = new SharingServicesGW('svc1').createService();
This all works flawlessly, and I can now switch between services with no problem whatsoever. However, I feel there's something wrong about it, so I would like to ask you guys for some advice on how to better implement this.
UPDATE:
Just adding some more insight to this. Basically the idea here is for my client to be able to upload images with various different public sharing services such as imageshack, imgur etc. I want my client to be able to select the service in which the image is to be published to (hence the "switching between them with user interaction" bit of the question.
The method that does the uploading bit, is requestShareImage(), processResults() simply turns whatever gets returned to a unique format, so my client can read off it always the same way. getObject() is my accessor, and onIOError will handle exceptions with any of the public API's
View 1 Replies
Similar Posts:
Jun 14, 2010
I am working on a project were I'd like to implement a sort of MVC. The idea is the following: have a Viewer app that connects to a database and reads the object to be displayed (based on some ID); have a Setter app that connects to the database and sets the object to be displayed for a particular ID.
What i am trying to do is have an interface that declares common methods for the Object class (like draw, etc.) and have implementations of that interface be loaded dynamically from the database in the Viewer.
View 0 Replies
Aug 14, 2009
Is something like this possible in Actionscript?
Java:
URLFetcherFactory.setCreator(
new IURLFetcherCreator() {
public IURLFetcher create() {
return new URLFetcher();
[code].....
View 2 Replies
Sep 28, 2011
In C#, it's possible implementing interface methods without making implementing method as public. For example,
void ITest.SomeMethod()
{
// ...
}
Is there equivalent for ActionScript3?
View 2 Replies
Dec 14, 2005
how to include in a class the implementation of the onLoad function of the XML class. I have something like:
[Code]...
View 2 Replies
Sep 8, 2009
I'm trying to implement class ImageViewer in AS2 (Actionscript 2).Here is the full source attached:
[URL]
I receive an error.I'm not sure if container_mc is the instance name of the image that is converted in movieclip symbol.
View 1 Replies
Feb 17, 2011
Is there a way to generate an instance of a class that implements an interface based on the name of the class?
I am trying:
var ClassReference:Object = getDefinitionByName("movement.OuterSpaceMovement") as IMovement;
var m:IMovement = new ClassReference as IMovement;
trace("startup..." + m);
-But I am getting an error message ReferenceError: Error #1065 (OuterSpaceMovement) not defined.
I have several classes that implement the same interface (IMovement) but I need to be able to generate new instances of these classes and then pass these instances as a datatype (IMovement datatype) to other classes...
So then I tried:
var ClassReference:Class = getDefinitionByName("OuterSpaceMovement") as Class;
var m:IMovement = new ClassReference() as IMovement;
and this doesn't seem to work...but the following
var m:IMovement = new OuterSpaceMovement();
View 1 Replies
Mar 13, 2011
I'm trying to load a RSL library into a flash animation developed with Flash CS5 IDE, that extends a custom class and implements an interface. I have reduced the problem to the simplest setup and find that I can have my main class extend another class or implement an interface, but not do both at the same time if I want to load an RSL.I have a very simple class to extend:
import flash.display.Sprite;
public class MySprite extends Sprite
{[ code]...........
but if I want both I get the VerifyError: Error #1014 with MySprite not found and ReferenceError: Error #1065.
View 2 Replies
Sep 7, 2007
i am working on a project where i have some common code which i import in different movie clips and different files the code is in actionscript 2 in an external .as file. this is not a class its just a bucnh of functions and temporary variables.Problem is when i use the check syntax button or auto format button i get the following error."ActionScript 2.0 class scripts may only define class or interface constructs."this used to work fine in flash 8 but it always gives this error since i started using flash 9.the code works fine too. its just that my auto format button and the check syntax doesn't work.
View 5 Replies
Mar 25, 2010
With this code
function someFunction(classParam:Class):Boolean
{
// how to know if classParam implements some interface?
}
i.e. Comparing classParam with IEventDispatcher interface
[Code]...
There is a way that DOES NOT USE describeType or creates a new operator?
View 2 Replies
Aug 13, 2006
i have incuded an AS file in my fla. But is gives an error ball.as: Line 73: ActionScript 2.0 class scripts may only define class or interface constructs.
[Code]...
View 1 Replies
Apr 20, 2009
I'm trying to publish a swf with Flash CS3.
I have one .fla file and two .as files. I think my problem is I don't know how to set the path for the action scripts. All three files are in the same directory
The files:
dtd.fla
TransformItem.as
TransformManager.as
The error: The class or interface 'gs.TransformManager' could not be loaded.
dtd.fla code appears to have an appropriate import: import gs.TransformManager; var manager_obj = new TransformManager([], onTransformEvent, true, false, false, false, false, true, true);
TransformManager.as code appears to have an appropriate import: import gs.TransformItem;
View 2 Replies
Nov 30, 2009
I'm doing a simple link code. I've tried many diferrent ways to do this but this error keeps comming up saying The class or interface could not be loaded...
home_btn.addEventListener(MouseEvent.CLICK, gotoURL);
function gotoURL(event:MouseEvent):Void{
navigateToURL(new URLRequest("my site"));}
This is the most recent method I've tried in doing this. I've tried changing the publishing settings of the document to and from Action Script 3.0- using an import command. But thats too complicated.
Attachments: Flashfla.fla.zip (767.8 K)
View 11 Replies
Feb 3, 2012
Can I implement more than one interface to the same class?One option is to make interface A extend interface B and than have my class inplementing interface A. Is there any other way that I can implement two or more interfaces directly to the same class?
View 3 Replies
Dec 30, 2009
Quick question. Does a class have to implement a interface directly to be accepted, or can it be a child of a parent class that implements it. so If I pass a child object into a method that only accepts IOBJECT, but the child class parent implements IOBJECT. will child object be accepted ?
View 1 Replies
Jul 30, 2010
I got the error message below when I try to put them onto my own flash file, The source codes work well by themselves.The class or interface 'URLLoader' could not be loaded.The class or interface 'URLRequest' could not be loaded.
View 1 Replies
Jun 11, 2011
I am getting an error with RegExp class at my flash document. I am using an Action Script 2.0 at my document. Is RegExp class is not supported in AS1/AS2 ?
My code is as follows
function validateEmailAddress(emailString:String):Boolean {
var myRegEx:RegExp = /(w|[_.-])+@((w|-)+.)+w{2,4}+/;
var myResult:Object = myRegEx.exec(emailString);
if(myResult == null) {return false;}return true;
} if(validateEmailAddress(email) == false) {
contacterror = "Error ! Please Enter Valid Email Address";}
If RegExp not supported in ActionScript 2.0 then how to validate email address at ActionScript 2.0 ?
View 1 Replies
Dec 30, 2009
I am creating objects for a game, they are all sprites. but I also want them to implement an interface. Is it possible to do both ? If not, how can i have an object have the capabilities of a sprite and also have it implement an interface. I am wanting to create another class that checks all my objects to see what datatype they are and evaluate them accordingly
View 1 Replies
Jun 16, 2011
I have an older site that is coded in AS2(I can't get it to AS3 sorry) I found this script online that allows for mouse scrolling. It is in AS3 and I can't figure out what Event replaced in AS2. I'm sure there are much better AS programmers than me that could tell me off the bat. I'm just trying to get this converted to AS2.
var verticalCenter:Number = stage.stageHeight / 2;
var limit:Number = stage.stageHeight - content_mc.height;
var speed:Number = 0.1;
[Code]....
View 1 Replies
Oct 10, 2011
As in Java I want to know if my reference is declared as Interface.
function foo(classRef:Class){
if(classRef.isInterface(){
//something
[code].....
View 2 Replies
Feb 2, 2009
whats the purpose of having to have an extra class such as abstract class in Flash where the methods has no implementation,but the subclasses declare those implementations.The advantage of having the methods declared in subclass than the superclass is that it would not affect the other subclasses when there are certain changes.That makes me wonder, isn't it better not to extend(inherit) empty methods but directly create a class as its own? unless there is something that the child could use from parent.Anyone could give me examples of how applicable using abstract classes/interfaces?
View 3 Replies
Jan 30, 2012
I am currently doing this gallery with prev and next button.But i got this error message.."The class or interface of MouseEvent could not be loaded." [code]
View 1 Replies
Sep 3, 2011
I think I understand how to make a interface but the problem is im unsure as to how to add it to my existing code! To make a interface (as far as i know) You can create classes such as mainScreen, intructions and so on. Ok i get that, make the classes then add ther buttons from the library i these classes. But i followed a tutorial bu Emmanuel Feronto, and adapted that to the needs of my game.
So im unsure as how to add these 'Screens' to my current class, the I currently only have 1 class, Main which currently has 300 lines of code, and i dont know how to break it up into smaller classes. Thats the problem i think, The main is quite large, normally i have heard people keep this clear... But then say i made a bland main, and added the screens into that then how do i make the main that makes the game play on the play button?
View 14 Replies
Jan 18, 2011
How can I test if a class reference implements an interface? Note that the is and instanceof operators do not work with Class references.
Example:
public function set someClassref(value:Class):void
{
if(value is IMyInterface)[code]........
View 1 Replies
Apr 29, 2011
Not sure if this is possible but I would like to reflect a swf or swc file selected by the user at runtime to find any classes that implement a certain interface. Can this be done or do you actually need a reference to the class you want to reflect using describeType();
Note - this would be done in actionscript.
View 1 Replies
Sep 7, 2011
In ActionScript 3.0, there are a few ways to check a class's extension. For example, if I want to know of a custom class extends Sprite I could use the is operator:
trace(MyClass is Sprite);
Or I could use flash.utils.getQualifiedSuperclassName:
trace(getQualifiedSuperclassName(MyClass));
I would like to accept a class as an argument and check to see if the passed class implements an certain interface. Is there an equally simple or common way to check if my custom class adheres to an interface? Perhaps something like:
trace(MyClass implements IMyInterface);
View 2 Replies
Aug 17, 2009
The class or interface 'it.sephiroth.XML2Object' could not be loaded?? I did the installation of extension and adobe extension manager confirmed installation to be successful and yet I cant
[Code]...
View 0 Replies
Jun 19, 2010
I keep getting this error when I try to implement an interface:"Interface method bar in namespace Foo not implemented by class Test".As far as I know, I've correctly added all methods from the interface.[code]I'm using mxmlc.exe to compile in the flex sdk.
View 2 Replies
Aug 5, 2006
Is there any way of extending a class which is extending the movieClip class? Or generally a way to add extra methods to an allready existing class without having to add them in the actual class declaration. I was thinking of using Interfaces but how can I implement an Interface to a class which is extending a movieclip?
Code:
import interfaceName
class className implements interfaceName{
//stuff
}
But where do I put the code which extends the MovieClip?
Code:
class className extends MovieClip{
//
}
View 4 Replies
Feb 11, 2008
Not sure if this is possible but it has been annoying me for the least few days. Basically im aware i can do this to instantiate a class
[Code]...
However, if i pass in a string for the SOME_VARIABLE , is there anyway i can get the above to work? If i pass a string in i either get no error, or the fact that the datatype is incorrect. Im using an xml file to build up an interface. but the value of SOME_VARIABLE is passed in from the xml file as a string. I want to be able to detrmine which class to create from this string.
View 5 Replies