ActionScript 2.0 :: Import And Extends (inheritance) / Difference Between Them?
Oct 25, 2005What is the difference between import and extends in AS 2.0?
View 1 RepliesWhat is the difference between import and extends in AS 2.0?
View 1 RepliesI am having trouble using inheritance, I made a class called newchars_2 that extends my class newchars and i get this error (newchars class extends movieclip):
1203: No default constructor found in baseclass newchars.
newchars_2.as:
package {
public class newchars_2 extends newchars {
private var obj_no = 3;
public function newchars_2() {
//contructor class
}}}
And when I want to import this class do I import both the class's or just newchars_2 because it has all the functions inherited?
What's the difference between Extends and Instantiation? It seems like they're both ways of getting content from a class.
View 4 RepliesWhat is the difference Between Extends and Instantiation?
View 1 RepliesI'm having some troubles with the use of interface and inheritance in AS3. I've done lots of OOP in the past and what I'm trying to do seems obvious to me, but doesn't work in AS3. The question is : Is it possible to override a function that return an Object of class A, and make it return an Object of Class B which extends A ? It seems not to be possible, since I'm getting a signature error in Flash, when compiling. For example, the following set of class do not compile (the code in function definition doesn't matter):
[Code].....
I am importing a picture in flash and i found out that there is a difference between importing to the stage, and importing to the library... [URL] I've placed both picture close of each other and if you look closely, you'll notice that one of them is losing some resolution. Both picture come from the same file, a png. The picture imported to the stage is sharper than the one imported to the library. is there a way to import that picture to the library without losing any resolution?
View 5 Repliesi came across this problem and i have no clue why it's happening. basically, consider 2 nested movieclips on the stage, something like stage -> main -> filler. both movieclips have instance names (main and filler).
[Code].....
this throws an error 1119: Access of possibly undefined property filler through a reference with static type A. can anyone give me a hint on that, as it works with class A, but not B extending A? i understand it was meant to work?
I`m using flash cs3 for my works , but i have one problem!when i use File=> Import=> Import to Library... or Import to Stage...the flash environment becomes terminated.I changed my flash version to CS4 and I have this problem again.
View 2 RepliesI have a parent MC (I'll call this mcFrame) on the stage that is essentially a square "picture" frame which I have applied a 'drop shadow' filter to. I have a child MC (I'll call this mcChild) which I have added to the displayList via AS3. This child MC contains a couple of paragraphs of static text.
So here is my problem: The 'drop shadow' filter I applied to the parent MC also appears on the static text (or any other type of content) in the child MC, how do I keep this from happening? To re-word my question? How do I stop the Child MC from inheriting the filters applied to its Parent MC.
I'm having trouble getting my inheritance variables worked out. In 'plain English', this is what I want:
base class enemy:
{variable HP;
if(HP<=0){remove instance}[code].....
But when I try to do this, it just gives me some error either about conflicting namespace or about the variable not being defined. I've done stuff like this before in GM and Python, but I don't understand how it's supposed to be done in AS3.
i made an example so i can explein the prob better.[code]I am making a class and if have another build in object in it. I what to add a callback to it but the inheritance is not right. I know how the set up inheritance
1) subClass.prototype.__proto__ = superClass.prototype;
2) subClass.prototype. = new superClass;
but its all messed up in my head so I was hoping someone could point me in the right direction on how to get the callback to work with out messing up the LoadVars class too much
Is it possible to inherit the objects of a library symbol?Say I have a symbol named Testwith a red rectangle inside of it (defined in the main .fla file) named Member.
Code:
package
{
[code].....
I have three classes (shown below, after the problem description).The first class (InteractiveStrategy) is the main class definition. In there I declare and instantiate two variables, download and upload, both of DataTxRx class.
On instantiation the folowing error pops up>> 1203: No default constructor found in base class strategy:DataTxRx public function Question(){ The second class, DataTxRx does two things only, either to download data or to upload data. As shown in its constructor, if the required parameter 'direction' is equal to DOWNLOAD, it calls the DownloadData() function. Similary, it calls the UploadData() if the required parameter is equal to UPLOAD.
The third class, Question extends the DataTxRx class, but itself has no constructor. However it has other methods(not shown) for adding, modifying and deleting questions anomg others.
package strategy{
import flash.display.Sprite; import flash.events.*;
import strategy.*;
[code]....
if I can do this in as3: I got two "Class"es and I want to know if A:Class is inherited B:Class without instantiat any of them?
View 5 RepliesI'd like to create some kind of component's properties inheritance to create generic behaviors in my component.Imagine I work a lot with textfield based components (counters, animated text... and so on), I'd like my artist to custom these components without being scared by the "update" button. Today, when component's code is updated, my artist has to update every flas using these components, and all of them are re-set to original look (if he had customed font color, or font size by duplicating the component instance, everything is set back to the current look of component).
That's why I'd like to know if there is a way for a component to inherit some of its properties and behaviors from another component class ?
package
{
import flash.display.Sprite;
public class AbstractTarget extends Sprite [codee]................
And then I have a class called "Target" that extends AbstractTarget...how do I access the __movement property? Do I have to write the getter and setter in my Target class also and override both functions/methods?
If you have a method in your base class that is protected, can you override this method in your subclasses?
View 1 RepliesMy data is of mixed types like String, Array Collection, Boolean. I have to populate the data into appropriate UI component - for example Boolean to check box, Array to List. So we have created a factory class which will return 3 different type of component based on the input argument.
CTextfield -> extends mx.controls.Text
CList -> extends mx.controls.List
CCheckBox -> extends custom.MultiLineCheckBox
MultiLineCheckBox which extends mx.controls.CheckBox and few methods are overridden to bring the multiple line label. [URL]. It works perfect.Am using the MultiLineCheckBox in the entire application wherever I want check Box. Now I went into a scenario where I want check Box instead of MultiLineCheckBox. How to rewrite my CCheckBox to handle MultiLineCheckBox and also default CheckBox? Each of the CCheckBox class has lot of methods init.
fact: using my setup, a class that inherits from another class does not inherit the parent class' getter/setter methods.
View 2 RepliesI am looking for an example that will show me how to work around the no-multiple-inheritance problems in AS2. I have a class that extends the UIComponent, but I also want to extend the XMLSocket. I've looked and looekd and see no good example for when I'm writing my class.
View 4 RepliesWithout being able to modify the prototype chain, is it possible to fake multiple inheritance in AS3?
Say I have three Window classes. One is a DraggableWindow, one is a ScalingWindow, and one is a BorderWindow.
I want to mix and match new subclasses at runtime without having to make tons of new permutations of Window subclass possibilities.
Sure, I can implement these behaviors of the Window class as interfaces, but I would still have to account for all the permutations of interface combinations.
I am working on inheritance for the first time. Here is the super class
SetBlank.as
Code:
import flash.text.*;
class SetBlank {
public var _textFieldName:TextField;
public var _defaultName:String;
public function SetBlank(textFieldName:TextField, defaultName:String) {
[Code] .....
I can see the trace function working but the method which sets the text field to blank is now working.
My problem is I wish to find the x and y position of certain child objects. however when i try to display these values I am only shown their position when the child is initially added to the stage.Once the child moves due to the parent object moving, visually the child is moving, however when tracing or displaying the childs x position it remains static.Here is an abstracted version of my problem, it is all code based so it should run fine. The problem area is highlighted using comments and you will notice that the child positions in the trace logs do not change.
package
{
import flash.display.MovieClip;
[code].....
I am trying to pass a value from the Doc class to* subClass1. This part work fine. subClass1 receives the value and sets an internal variable to the value it got from the Doc class. When I set subCl[code]...
View 4 RepliesI am writing a simple application which communicates with web services a lot So I am listening for success and fault events very often. When service returns a fault, I show an alert to a user saying something like: "Sorry there was a problem with a service, we will try to call it later"
But there is a problem. When user didn't notice an alert, and service is still dead before the second call the alert will be shown again, and again and again (so There will be very many alert objects which is bad)
I want to make alert a kind of singleton. So I am trying to produce a class something like
[Code]...
I have an issue when consuming a web service from a Flex app. In the backend I have a hierarchy, let's say I have an abstract class Fruit, and 2 implementations: Apple and Orange. Fruit has a property, name, Apple has a property color, and Orange has a property radius. Then, I have a service wich returns a collection of Fruit. When I consume it from Flex, this collection returns objects wich type are Fruit, with its name property; but I lose all the properties for the implementation classes (color nor radius). So, the question is, does Flex support inheritance mapping when using web services? If not, is there any workarround?
View 1 Replies[Code]....
It is not works! When I see in debugger, child have type "Screen2", but "child is Screen" returns false to me (and "child instanceof Screen" too). When I apply compiler key: "-keep-generated-actionscript" I can see Screen2-generated.as and it's contains public class Screen3 extends screens.Screen
I have a class named Level which inherits MovieClip. Level has a child in the designer with the name gridView and the gridView is used in Level constructor.I have also class named Level1 which inherits Level. when I try something like addChild(new Level1()) I get error in Level constructor saying gridView is null.[code]
View 3 Repliesi've been reading a variety of tutorials on the subject of inheritance, and i felt ready to try creating a chain of a few classes.right now i have two similar classes, Avatar and Enemy, which extend movieclip. What i'm trying to do is move a lot of their common functionality into a parent class which i'm calling Actor. I want to make Actor extend MovieClip, then make Enemy and Avatar extend Actor instead of Movieclip.[code]
What it says is true. I have an object in my library which is a movieclip. It's Exported for Actionscript with it's class as Soldier, and a base class of Avatar. this is the continuation of the chain. However it doesn't seem to want to work.As far as i understand, the above setup is pretty much equivilant to making a .as file for Soldier that extends Avatar.
example:
Code:
class Dot extends Sprite {
public function Dot():void {
ring.scaleX = 1.0;
[Code]...
If I attach the class Dot to the movie clip everything is fine, but if I attach the class Dottle to the movieclip the pre-export complains saying it can't find 'ring'. however, if I use this['ring'] everything works fine. I understand WHY this is, but I don't know what I should do to make it so it works w/out have to put this[''] around everything.