ActionScript 2.0 :: Class Instance Name Property?

Aug 28, 2007

is there any way, within a class definition, to access the instance name of the class?as in, say you have a class "playerObject", and you instantiate an instance of it like usualplayer:playerObject = new playerObject();is there an inbuilt property or variable i can access within the playerObject class code to return "player"?if, in the constructor, i trace(this) it returns [object Object], i tried things like this.name, this._name etc, of course they didnt work...

View 4 Replies


Similar Posts:


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.0 :: Access Property Only By Instance Of Same Class?

Jul 23, 2009

What should I do to make a non static variable accessible to only instances of the same class?

View 10 Replies

ActionScript 3.0 :: How To Access Instance Property Through Child In Main Class

Jan 23, 2011

I have make 3 classes objecthandler, box and nav. Nav is child class of objecthandler, I have make an instance of box into objecthandler and now I wanna access property of box through nav.
See the code:
Objecthandler class
package code{
import flash.display.MovieClip
import code.box
import code.nav
[Code] .....

View 1 Replies

ActionScript 3.0 :: Flex - Construct A Derived Class Instance From An Existing Base Class Instance?

Jan 22, 2010

I have a base class which is being created via remote_object [RemoteClass alias] from the server.I have other specialized classes that are derived from this baseclass, but serialization with the server always happens with the base class.The base class has meta data that defines what the derived class is, for example

[RemoteClass (alias="com.myco...')]
public Class Base
{

[code]....

View 2 Replies

Flash :: Unable To Convert An Instance Of A Class To An Instance Of The Class's Subclass?

Sep 15, 2011

I'm using a library that has a function that returns an instance of some class Engine.

I'd like to tack on some interfaces to Engine, so I subclass it class InterfacedEngine extends Engine implements AwesomeInterface. but when I change the code that uses the classes from this:

var engine:Engine = generateEngine();

to this: var interfacedEngine:InterfacedEngine = generateEngine();

It gives me a runtime error (elision mine):

TypeError: Error #1034: Type Coercion failed: cannot convert ...::Engine@1bc2bf11 to ....InterfacedEngine.

What about AS3 classes am I misunderstanding?

View 2 Replies

ActionScript 3.0 :: Access Values Held By A Class Instance From Another Class Instance?

Oct 14, 2009

I have to admit I pretty much ran away from Flash when AS2 came along and only used it for animation purposes over the last 5 years.So I'm having a major crash course in AS3 in Flash CS3 and I'm not enjoying it one bit. I'm getting maybe 10mins of finished work per hour as I try to figure out the limits and rules of AS3. Quite often it seems that AS3 simply can't do what I want it to. Anyway: Characterchecks.as is the main class and it loads a bunch of XML into four arrays. The file starts like this:[code]If I trace the value of, say, cc._Categories from the main FLA, it's empty. I'm guessing that the next line of AS in the main FLA doesn't wait for the previously called function to complete? (This may tie in to my next problem)My next step is that I want to display various things based on the data in the array. I have another class, Display.as which will hold all the functions to create the items on display. I thought it would be best for these to be a separate object. I wonder if I'm right?

So I declare an instance of Characterchecks in the main FLA and call it cc, and then run the functions to populate the arrays... Now I create an instance of Display and call it cd. How can I get functions in cd to see the values of the variables in cc? And if the main timeline can't tell that the functions aren't finished filling the arrays, how is cd supposed to know?I might be asking dumb questions, or maybe I'm doing things ***-backwards, I don't know. I'd appreciate any help, I really would. This whole thing has me at the end of my tether... being the most technically advanced person in my circle of co-workers and web design friends means I have no-one to explain why things need to be done a certain way or what the best way is.

View 3 Replies

ActionScript 3.0 :: Sending A Class Instance Reference To A Different Class Instance?

Apr 14, 2011

I'm creating a little game - The player controls a character that follows the mouse. Pigs run away from the player, and the player has to get them all into a pen. To make the game a little more difficult I'm trying to add an enemy - wolves, that attempt to perform a 'hunt' method every x seconds. This method sends a reference of the wolf instance to Main (my document class) and Main then loops through the pigs on stage to see if there's any nearby. Now as far as I know this works - my problem is I'm unsure how to send the pig instance reference back to the wolf that called the hunt method, so it can then 'target' the pig, and then attempt to pounce on it.

This is my Wolf class:

Code:
package
{
import flash.display.MovieClip;
import flash.events.Event;

[Code].....

View 7 Replies

ActionScript 3.0 :: Static Methods - Error "1119: Access Of Possibly Undefined Property Instance Through A Reference With Static Type Class"

May 4, 2009

I'm kind off oblivious as to what I'm doing wrong here... I have two classes: - Alley - AlleyCat

[Code]...

View 8 Replies

Actionscript 3 :: Reference A Class Instance From Another Class Instance?

Dec 10, 2010

Quick question. I have been Googling this all morning, but it's either not there, or else written in a way that doesn't register. I am inclined to believe the latter, as this seems like it should be something completely trivial to me. I made a small Flash file using AS 3.0, and this is the first time I've really been able to stick to the OOP way of doing things and not hack together a mix of stuff from the timeline to get around not having everything work in the classes.

So I'd like to keep it that way, but one thing is eluding me: I can't call a method of an instance of another class (than the one I'm calling from) without resorting to "DocumentClass(root).instanceName.method." Intuition tells me there has to be a better way of doing this (like, without having to reference the document class every time I call another class instance's function; and CERTAINLY without having to use the word "root" - that just seems so Flash 5 to me. Does anybody have a better way of doing this that they can share?

[Code]....

View 1 Replies

ActionScript 3.0 :: Instance Or No Instance - Call A Function From Another Class?

Jan 26, 2009

I have a general / somewhat newbie question. Is it better practice to call a function from another class like so:

[Code]...

Does one way free up more memory or enhance performance?

View 5 Replies

Flex :: Binding - Bind Property Of View To Property Of Class Using MATE?

Jan 9, 2011

Lately i discovered MATE (for Flex development) and was wondering: how do i bind a property in a view (actually a navigatorcontent component) to another property in a class so that they stay in synchronization (meaning that whenever the property in the class changes the property in the view also changes).

So if we have a view called Target.mxml and a property targertProp how do we bind it to the class called SourceClass with property SourceProp?

View 3 Replies

Flash :: Creating An Instance Of A Class That Implements An Interface Based On The Class Name?

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

ActionScript 3.0 :: Creating A New Instance Fails When Base Class Is Assigned To An External Class File?

Jul 22, 2009

I'm trying to create a new instance of a MovieClip when the original one has been used. Would sound easy enough. Just use: var

instanceName:ClassName = new ClassName();

the class name/mc in the library im trying to duplicate is MCg1 so

var instanceName:MCg1 = new MCg1(); right?

However, the particular object in the library i'm trying to duplicate has a base class that is an external class file (just to control it's drag drop functionality)... i.e baseclass is not set to the standard flash.display.MovieClip, or whatever the case maybe. So i end out with a: TypeError: Error #1009: Cannot access a property or method of a null object reference.

View 6 Replies

ActionScript 2.0 :: Eating A Global Listener On The Class And Receive Dispatched Event For Any Instance Of The Class?

May 11, 2006

I've done a class to be able to listen to the event for a CLASS not on an instance.

Code:
class net.webbymx.events.XClassEventListener {[code]....

why did I do this.It cames with my rugby game.I have player in two teams. When a player throw the ball I want the other teammate to act like "wait for ball" and the opponent like "seek for ball". Plus I'm lazy (and I don't want to register the listener for each instance of the player I'm creating). So this class is made to be able to handle as many instance of a class I want without adding a listener on each of them. I'm just creating a global listener on the class and then I will be able to receive dispatched event for any instance of this class .so in my team I can do

Code:
XClassListener.initialize(this);
this.addEventListener("throw", "net.webbymx.game.Player", "wait");

and in my opponent team I can do

Code:
XClassListener.initialize(this);
this.addEventListener("throw", "net.webbymx.game.Player", "seek");

View 4 Replies

ActionScript 2.0 :: Checking To See If One Instance Of Class Hits Other Instances Of The Same Class?

Dec 23, 2006

Let's say i have a bunch of balls/cells. I'm having trouble figuring out how to make it so that every other ball bounces off of every other ball.

so in short, it's really one instance being able to check all other instances of the same ball class?

View 7 Replies

ActionScript 3.0 :: Reassign Class Variable To A Blank Instance Of Its Class?

Aug 31, 2011

When I declare a class variable
 
private var myVar:MyClass = new MyClass(); 

It creates a new instance of that class that will trace as [Object MyClass].
However, as soon as I assign it to something
 
myVar = thisOtherVar; 
It will now trace as [Object thisOtherVar].
 
I need to get it back to where it's just an "empty" blank class instance, if that makes any sense at all.

View 14 Replies

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

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

Flex :: Unable To Bind To Property 'xmlnode' On Class 'XML' (class Is Not An IEventDispatcher)

Mar 14, 2012

i am using xmllistcollection for displaying data in list. whenever i run my application data is display in list control, but this warning has displayed in console. How can i remove this warning warning: unable to bind to property 'xmlnode' on class 'XML' (class is not an IEventDispatcher)

View 1 Replies

Flash :: Add A Custom Property To An Instance Of Image?

Dec 30, 2010

I have made a webpage, i want to show a flash video for 40 seconds when the page is opened. Then the Flash video should dissapear and the web page shall open. [code]...

View 5 Replies

Flex :: Add A Custom Property To An Instance Of Image?

Sep 24, 2010

[code]...

How can I do that? Or I need to extends the Image class?

View 3 Replies

ActionScript 3.0 :: Defining A Property Without The Instance Being In The Movie?

Dec 16, 2009

I'm a bit on the novice side of AS3 and am struggling away. I have one major issue which I cannot fathom.I have two swf's which I am loading into a flip book. They will both on the stage at the same time one on each side of the book. I want one to control the other. The issue is when I try to set up functions in one to control objects in the other I get and error about undefined properties. I assume this is because the objects I am referencing are not in the movie where the function lies. And vice versa, when I set up the functions in the movies when the objects are I get an error as the buttons are not defined as they are in the other swf.

View 4 Replies

ActionScript 3.0 :: Getting A Property From An Instance Name Stored In An Array?

Feb 23, 2011

I've got this code -

Code:
var enemyArrayOneA:Array = new Array();
for (var i = 1; i <= 84; i++) {
/*

[code]...

I try to use race("mc.main1.a_0" + i + ".x = " + enemyArrayOne[i].x); and it doesn't work...I'm trying to find out if I can store instance names of movie clips inside an array and retrieve the movie clip's x and y positions.

View 3 Replies

Flex :: Binding To A Base Class Property With Class Inheritance?

Feb 9, 2010

say that i have a base class called Base, that is Bindable and has a String property like this:

[Bindable]
public class Base
{
public var msg:String;

[Code]......

where msg is some textInput field. I am getting a message from the compiler that....

Data binding will not be able to detect assignments to "msg"

is there a limitation with data binding to a base class?

View 1 Replies

ActionScript 2.0 :: Referring To A Class Property - Get The Id Form The Piece Class

Jan 9, 2009

I have a class that looks like this:

[Code]....

now when i try to get the id form the Piece class like this it doesn't work, i've been looking at this for the better part of the past hour! what am i doing wrong?

ActionScript Code:
var player1:Player = new Player("eddie");
player1.setPieces();
trace(player1.pieces[0].id);///why is this not working! getting undefined!
// i tried datacasting i get null
trace(Piece(player1.pieces[0].id));

View 6 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

Flex :: Difference Between Class Reference And Class Instance?

Jun 28, 2010

Given that both of these calls to getQualifiedClassName return the same thing (mx:Label), how would one go about programatically differentiating between an instance of a class and a reference to the class...

var lab1:Label=new Label();
var lab2:Class=Label;
var qcn1:String=getQualifiedClassName(lab1);
var qcn2:String=getQualifiedClassName(lab2);

In other words, how could I know that lab1 is of type Label, while lab2 is type "Class". typeof() simply returns "object" for both... getQualifiedClassName returns "mx.controls::Label" for both...

View 3 Replies

ActionScript 2.0 :: Delete Instance Of Class From Class' Method?

Dec 28, 2005

I have a class called Unit. When I use this class in a .fla file, I create it by saying:

var unit00:Unit = new Unit(...);

So then it creates a gfx representation of the screen for me. I would like to have a method like this:

PHP Code:

[code]....

So how do I get this to work? I know that delete this will not work when defined inside the class. How do I target the .fla's instance name when I don't know what it will be called?

View 10 Replies

ActionScript 3.0 :: Document Class Vs Manual Instance Of The Same Class?

Apr 6, 2010

I mean a have a class called Login and when I make an instance of this class

PHP Code: var log:Login = new Login(); 

doesn't give me the wanted results.

- When it is declared Document class it adds a child on stage

- When the same class is called manually (via the above code) although I get no errors nothing is added on stage.

View 3 Replies







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