| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Aug 2009
Posts: 11
|
I've got a document class for Main.. and I have another document class called MyClass that extends Sprite.. I've created an Array for dynamically creating objects, and I add the "MyClass" objects to this Array .. theres about 4 items in there currently. So I currently have array[0] array[1] array[2] and array[3]..
Anyway, when I want to access array[0].x and array[0].y (for example) from inside array[1] when it receives an event, how do I read the other array[] objects ?? "root." seems to be the root of the currently read object, I cant seem to access the stage from the Main document class... I'm very new to this, go easy on me guys! Thanks ![]() Last edited by jahc; 08-28-2009 at 01:10 PM.. Reason: wrong description |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Jan 2007
Posts: 274
|
from inside a class, you can only reference objects that are created inside that class, or have been passed in as a parameter.
Your specific situation is a little confusing. If you could you post your code or a link to your project files it would help. |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Nov 2009
Posts: 8
|
I have the same problem, I have a movieclip already placed on the stage with an document class called "player" linked to it.
Whenever I try to acces the movieclip I get the follow error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at KeyObject/construct() at KeyObject() at player() Whenever I try the code on the timeline, everything works fine. ActionScript Code:
Any idea's? |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Jan 2007
Posts: 274
|
Reading the error message, I can tell that the error is occuring in the function "construct" (maybe the constructor if you don't have a function named that?) in the KeyObject class. Something in that function is null when it shouldn't be.
From what I can see of your code, it's occuring at this line: ActionScript Code:
What is stageRef? It looks to me like it hasn't been declared which means it's null. I imagine your trying to use it inside the KeyObject constructor, (because your passing it in). This would cause the error your getting. |
|
|
|
|
|
#5 | |
|
Registered User
Join Date: Nov 2009
Posts: 8
|
Quote:
The problem is that the character movieclip just isnt recognized for some reason. |
|
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jan 2007
Posts: 274
|
A little confused by your last post, but looking more closely I see the problem.
ActionScript Code:
I remember having problems with stage references before. Try passing it in to the constructor, and don't instantiate the KeyObject until then. ActionScript Code:
then use ActionScript Code:
|
|
|
|
|
|
#7 | |
|
Registered User
Join Date: Nov 2009
Posts: 1
|
Quote:
__________________ Simulateur de pret immobilier simulation credit | Simulateur pret immobilier simulation de credit | Simulateur de pret immo |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|