Flash :: Access Object Property Or Function On Extended Class That Isn't In The Super Class?

Jan 29, 2012

If I have three classes:

public class Example {
public function Example () {
}[code]............

You can see that the two last classes extend the first one, and both have the 'variable' property. In case that I have an instance of Example and I am sure it is also an ExtendedExample OR AnotherExtendedExample instance, is there some way to access the 'variable' property? Something like

function functionThatReceivesAnExtendedExample (ex:Example):void {
if(some condition that I may need) {
ex.func()

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Super.super.someMethod() - Call A Method In The Super Class Of A Super Class?

Dec 15, 2009

Is it possible to call a method in the super class of a super class? I tried the above and it doesn't work, unsurprisingly. Only way I've been able to do it is to store a reference to a super.someMethod in the super Class (eg. var superMethod: Function = super.someMethod) and call that instead. Seems reasonable and it works but wonder if there is an in-built method for doing this?

View 6 Replies

ActionScript 3.0 :: Calling A Function From An Extended Class Inside A Top Level Class

Sep 23, 2009

package{
public class Character{
protected var _hp:uint = 50; //Character Health Points
protected var _power:uint = 5; //Damage dealt

[Code].....

I`m instancing a Character and a Player in the Main Timeline, all in frame 1.
When I use: ""player.attack(character)"" it works fine by itself.

So I added the if (defender._hp <= 0) this.win() which gives me the following error:

1061: Call to a possibly undefined method win through a reference with static type Character.

"defender" is a Character instance, "this" is a Player instance and "win()" is a Player method. I try to call the Player method inside a Character method using the Player instance adding the "." and his method name

Do I really need to define the win() function in the Character class? Is there a bypass to use a subclass method in a parent class method if it`s called from an instance of the subclass?

View 6 Replies

ActionScript 2.0 :: Class Function Tunnel - Access Property Inside Method

Jun 1, 2006

I have a simple quesiton about class, method and functions inside a method and class properties. I created a new class form my custom component.. But upon developing it I found out that you can not access a property inside the function which is also inside a method..

Example
Code:
class myClass{
private var myProperty:Number = 1; //default is 1
//constructor
public function myClass(){
}//Method
[Code] .....

What I want to do is to access the property inside the method.. I also have a work-around still i cannot point a certain variable to a property of my class inside the method's function..

View 2 Replies

ActionScript 2.0 :: Know When A Function In Super Class Is Called?

Mar 9, 2010

i got a class(class1) that extends another class (class2)...when something happens in super class, i need to update the class1, soi need to trigger a function in class1 from class2... I know is bad programming, but is that possible? I'm confused

View 0 Replies

Actionscript 3 :: Access A Public Property From AvEniroments Class Through The Player Class?

Nov 24, 2011

I have the following inheritance structure:

var environment:AvEnvironment = new AvEnvironment(...);
addChild(environment);
environment.addChild(new Terrain());
environment.addChild(new Player());

I am trying to access a public property from AvEniroments class through the Player class, however I'm getting an undefined property error (#119). I've tried the following:

this.x = AvEnvironment.xs // public property in this class
this.x = parent.xs

I've also tried something like this:

var ev:AvEnvironment = AvEnvironment(parent);
this.x = ev.xs

but I get a TypeError. Error #1009: Cannot access a property or method of a null object reference.

View 1 Replies

ActionScript 3.0 :: Access The Stage Property From A Different Class That's Not The Principal Class?

Jul 2, 2009

I was wondering how do you access the stage property from a different class that's not the principal class tied to the fla? Essentially, I have main.as which calls another class menu.as, and I can't seem to be able to use the stage.stageWidth property from menu.as. What's the proper way to be able to use the stage property from any class? Do I have to import it separately each time?

View 2 Replies

Actionscript 3 :: Super Interface And Super Class Having The Same Method Name?

Dec 29, 2011

I am trying to create a spark datagrid item renderer. This item renderer extends a checkbox, and implements IGridItemRenderer public class CellCheckBoxItemRenderer extends CheckBox implements IGridItemRenderer

When I implement IGridItemRenderer, I need to implement the interface methods, I am having a problem with the following methods:

[Code]...

View 2 Replies

Actionscript 3 :: Calling A Function From Another Extended Class?

Mar 29, 2012

I have my main stage, and I have two objects (blocks), these two objects both extend from the "Block" class. The "Block" class is NOT extended from the Main Class.I would LIKE to call a function, in either the "Block" class or in it's subclasses, from the Main Stage Class. The functions will do slightly different things depending which object you are calling the function (Added different things, and different number of things to an array). What is the best way to implement this?

View 2 Replies

ActionScript 3.0 :: A Super Class That's Runtime Shared Independent From The Class That Extends

Nov 4, 2010

I'm not really asking how. What I'm asking is, is it possible? And I ask because I thought it was not - certainly it didn't work in AS2 - and yet that's what I appear to have done. Am I going crazy? Structure: A SWF (#1) with a class NewActivity that extends class AActivity. Another SWF (#2) with a shared library of code in it, including AActivity. A third SWF (#3) which loads the library followed by SWF#1. Here's what happened: I didn't expect AActivity to be able to be shared. I mean, it should be compiled no matter what in SWF#1, as SWF#1 includes a class that extends AActivity. I had added some properties to the AActivity class, ran the project, and when SWF#3 tried to set those properties I was told they couldn't be applied. "Of course", I said, "I need to recompile SWF#1, because the code is now out of date. The version of the class there doesn't include these new properties.".

However, that didn't work. I got the same problem. Maybe, I thought, there's a definition conflict between SWF#1 and the library, so I removed the AActivity class from the shared library in SWF#2 for the time being. Only SWF#1 uses it, and it should already be compiled into SWF#1 as, like I said, it is extended by another class there. But when I ran the project, I was then told that the AActivity class could not be found at all! Looking at SWF#1 in a decompiler, there is in fact no mention of AActivity (I had up to this point assumed it was implied). So this left just one option: I needed to recompile the library in the first place, not SWF#1. I added AActivity back to the library, recompiled, and it worked.

To check I wasn't going crazy: I added a test property to the AActivity class and recompiled the library. The containing project - SWF#3 - then set this property on SWF#1, which had NOT been recompiled, and then read it back out. No errors. I should point out that the getting/setting of this property is done through an IActivity interface - AActivity is not being accidentally compiled into the main project (SWF#3), and the decompiler indicates this also. Am I going nuts? I really didn't think having a runtime shared super class was possible in any way. If it is, that opens up a whole new world of awesome, even though I've created this project on the basis of that being impossible.

View 4 Replies

Actionscript 3 :: Accesing Function On The Maintime Line From A Extended Movieclip Class?

Feb 21, 2010

I have some movieclips on my main timeline with a class to extend these movieclips

[code]...

But the I can't 'reach' the testing function. I get this error: "1061: Call to a possibly undefined method testing through a reference with static type flash.display:DisplayObjectContainer."

View 1 Replies

ActionScript 3.0 :: Sub-class Refer/communicate With Super Class?

Jun 22, 2010

i have recently started a project that would require writing a set of classes and a small API.i know some basics of inheritance and extending classes but i still have some questions.

1) how should sub-class refer/communicate with super class.i think that dispatching events is the way to go but i have no experience on that. i have previously done it by having a parent set up a reference to itself in a subclass e.g

ParentClass.addChild(SubClass);
SubClass.myParent = ParentClass;

//i know that there is already a "parent" keyword in flash objects if i extend one but is that a decent way to communicate with super class

e.g SubClass.myParent.removeChild(this);//sounds a bad call

//but is it better if i dispatched an event that calls the removeChild() in the parent.i have is about dispatching events in a class that is likely going to be extended.

ActionScript Code:
public class Button
{
//add event listeners[code]....

//now if i extend the Button class into another class, let say ControllerButton and want that button to dispatch different event. e.g ControllerEvent, i am forced to override and rewrite all the common stuff in the handler functions.how to avoid having to override allot of common stuff.

View 3 Replies

Flex :: UIComponent Extended Class Isn't Showing UIComponent Extended Class

Aug 18, 2009

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 hights. If I trace I see the width and height is 200 X 200 but there is still nothing visible in my component.

View 1 Replies

Actionscript 3 :: Recasting Member Of A Library Class To New Type In Extended Class?

Oct 14, 2010

I created an flv video player using Flash Builder 4. This "BasicVideoPlayer" project is compiled into a SWC that will be eventually be used to create other video players that extend the functionality. One of the features is a view that appears when the video has finished playing that displays a "Play Again" button. This "Play Again" view has its own class, "BasicPlayAgain", that accepts a graphic asset that is exported from a .fla file that contains all of the graphic/UI assets.

In my new project, "EnhancedVideoPlayer", I'm using the BasicVideoPlayer SWC as a library to create a new video player that will add more functionality to the "Play Again" view; specifically it will add more buttons to that view.The EnhancedVideoPlayer uses a default class that extends the BasicVideoPlayer class. The BasicVideoPlayer class has a member called "playAgainScreen" whose type is BasicPlayAgain. The EnhancedVideoPlayer needs to override the playAgain member and recast it as EnhancedPlayAgain so it can control the new buttons properly.

View 1 Replies

ActionScript 3.0 :: Extended Class Doesn't Inherit Base Class Imports?

Sep 29, 2011

Let's say Class A has the flash.events.Event imported. Now let's say Class B extends Class A. Why in the hell do i need to import flash.events.Event in Class B? It makes no sens at all to me.

View 3 Replies

Actionscript 3 :: Linking Library Class To An Extended Class And Baseclass

Jan 22, 2011

The use of library classes confuses me once again. I have the following situation:

[Code]....

I cannot put in any baseclass when using the class, so I'm forced to remove the baseclass. When using only the class I get a whole bunch of errors don't make any sense at all, and still appear even if I comment out all the code in the Page class. comop_padpagesFavorietenPage.as:7: 1152: A conflict exists with inherited definition com.op_pad.pages:Page.help in namespace public.

[Code]...

View 1 Replies

ActionScript 3.0 :: Dispatch Event From Class That Isn't Extended Class Of MovieClip?

Oct 20, 2009

Is it possible to dispatch event from class that isnt extended class of MovieClip? I created my own class and put import flash.events.Event; import flash.events.*; but when i call dispatchEvent compiler throws error:"1180: Call to a possibly undefined method dispatchEvent."

View 3 Replies

ActionScript 3.0 :: Access Function At Main Class From A Sub Class?

Mar 3, 2011

My first experience is build an aquarium with a lot of fish swimming, and they can be clicked. When one of them is clicked we should receive a trace message saying ("I�m a Fish!"). To do this, I thought that the best way will be:

1- create a document class, named Main.as

2- create a base class, named Clicked.as

2- create a movie clip with a fish.

3- export the movieclip to actionscript. In the mc properties set Class as "fish" and Base Class as "Clicked".

View 6 Replies

ActionScript 3.0 :: Access A Function In The Main Class From Another Class?

Mar 1, 2010

i have a game that i want to put load screen on, which i created a separate class for. first the main class is initialized and in the constructor function, it does an addChild(loadScreen) which places an instance of the loadScreen MC on the stage. within the loadScreen is a "Play Button" that when a user presses this button i want it to continue startGame in the Main class. the way i tried it was Main.startGame from the loadScreen class, but that obviously does not work. is it possible to call a function from a different class.i have three files:

Main.fla
Main.as
loadScreen.as

the Main.as file:

Code:
package
{
import flash.text.*;
import flash.display.*;

[code]....

View 3 Replies

AS3 :: Tracing A Class Extended From The Event Class

Feb 18, 2011

I have created a class (extends the Event class) for use in one of my projects. If I trace the custom event object in the called function I get 'Event' as the type, but if I trace a TimerEvent, or MouseEvent, etc, I get TimerEvent or MouseEvent... Let me demonstrate:

var c:CustomObject = new CustomObject();
c.addEventListener(CustomEvent.ON_SEND_MESSAGE,fnc);
function fnc(e:CustomEvent) {

[Code].....

View 1 Replies

ActionScript 3.0 :: Inheritance / Interface - Override A Function That Return An Object Of Class A And Make It Return An Object Of Class B Which Extends A?

Aug 4, 2009

I'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].....

View 3 Replies

Flash :: Accessing Super Class Variables From Subclass?

Aug 16, 2010

I am hoping someone can explain about subclasses accessing variables from the super class. I found that the subclass can only access variables which are set in the constructor of the super class. Is there any way around this?

[Code]...

View 3 Replies

ActionScript 3.0 :: Flash Access Of Possible Undefined Property Text Through A Reference With Static Type Class

Jan 7, 2011

[Code]...

But the same error keeps showing up, related to the var t1 and var t2 lines: Access of possible undefined property text through a reference with static type class What should I do? I already tried removing the String indication, trade : by =,

[Code]...

View 2 Replies

Flash :: Access Top Level Function When Class Has A Function Of The Same Name

Dec 16, 2011

I have a class Debug with a function called trace inside it which puts a TextField on the stage and outputs the text. Now I am trying to get the Debug.trace() function to do a "normal" debug trace as well from within side itself. of course this causes a recursive loop. I am trying to figure out how I can access the top level separately. I tried using namespaces such as AS3::trace but to no luck.

I know a solution is to rename my function to stop the conflict, but I would like that to be a last resort. It is being used in quite alot of places throughout my entire code so replacing it everywhere is going to be a ballache.

View 1 Replies

ActionScript 3.0 :: Flash Extended Document Class?

Jul 12, 2010

I'm having some trouble with using a Document class in Flash CS3 that is an extension of another class. When I do this, I can no longer make references to MovieClips with instance names on the stage.Here's an example. I have a class called Minigame that extends MovieClip and then a class Shooter that extends Minigame. So the relationship looks like:MovieClip <-- Minigame <-- ShooterI want to use Shooter as my Document class in the Flash file Shooter.FLA. However, when I do this, I am unable to directly access any instance names of MovieClips on the stage of Shooter.FLA from Shooter.as. In other words, if I try to write the line:var mc:MovieClip = this.instanceName;in Shooter.as, I get the error:1120: Access of undefined property instanceName.

View 1 Replies

ActionScript 3.0 :: Flash - URLRequest In An Extended Class

Jan 8, 2011

I'm new to AS3 and I'm having a problem with an extended class that uses a URLRequest. I have a basic class called 'imageLoader' that I use for loading in external images

[Code]...

View 2 Replies

ActionScript 3.0 :: Access MC Property From Class?

Sep 17, 2010

I have one class which is assigned to dropBar MC:

ActionScript Code:
import src.DropDown;
var inheritanceDrop:DropDown = new DropDown(dropBar, 1);

[code].....

View 5 Replies

ActionScript 3.0 :: Access A Class Instance Property?

Jan 15, 2010

I have a problem with the piece of code that's been annoying me for a week. It should be very simple but all my attempts at a solution somehow seem to get thwarted by an invisible hand that wants me to fail.Here is the scenario: I am trying to create an image strip consisting of image thumbnails. When one mousovers each image it should print its information (say a name) in a textfield.I created an image container class that loads the images through a url request, then an image strip class that receives an array with image names and urls and displays them in a row. So far so good.

However when it comes to showing the info I have no clue how to address which image is being pointed at. I put a variable called imageIndex inside my imageContainer object, then put all the created containers in imageStrip's for-loop inside an array called mgContainerArray. I created a for loop in my fla that goes through this array and assigns all those containers a mouseover event listener. What I'm stumped with is that there is no way I can access the imageIndex variable from my function to tell the code which image is currently being mouseovered. It keeps giving me an error.Here is the code:

Code:
for(var i:Number=0; i<myImageStrip.imgContainerArray.length;i++){
myImageStrip.imgContainerArray[i].addEventListener(MouseEvent.MOUSE_OVER,

[code].....

View 3 Replies

Actionscript 3 :: Access A Property/method From Another Class?

Mar 14, 2012

I want to create an array of strings in a text class that I can access with the main document class. Then I'll be able to populate a text field with items in the array. The purpose of this is to avoid having massive lines of text in my main document... but I can't even get my test to work. The compiler is telling me that the array (txt1) is undefined. First here's my code for the array:

//text array class:format5000
package {
import flash.display.MovieClip;
import flash.text.*;

[Code].....

View 2 Replies

ActionScript 3.0 :: Access Of Undefined Property In My Class?

Jan 26, 2010

I have a class that has two variables, and four functions to get and set the values for said variables. The problem is that the variables are always undefined.I'm using the class mainly for holding variables and static functions so I haven't instantiated.

ActionScript Code:
package objects
{

[code]......

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved