ActionScript 3.0 :: Refer To The Stage From A Class?

Jun 7, 2010

I have a class that places objects on stage with addChild(obj) it allowes me to position objects using pixels( say obj.x = 10; obj.y= 50; ) just fine but if
I try this:  obj.x = stage.stageWidth / 2;  I get a message that I Cannot access a property or method of a null object reference

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Refer The Main Time Line Or Stage From Inside The Class?

Apr 13, 2009

how to refer the main time line or stage from inside the class.

class sample{
function sample(){
trace(root); // its displaying as null
}
}

in actionscript 2 we use _root for this... in actionscript3 if we use root...why its not working inside the class....?

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

Actionscript 3 :: Refer Objects On The Stage?

Oct 1, 2011

I have an object created visually. How should I refer to it from classes of other objects? MovieClip(this.root).someObj or stage.someObj or MovieClip(this.root).stage.someObj? And moreover, if I want to see which frame is current on the main timeline, why I cannot just check stage.currentFrame? Why there is no such property of the stage, currentFrame? It has timeline, right?

View 1 Replies

ActionScript 3.0 :: Refer To An Instance On The Stage If

Feb 9, 2009

How can I refer to an instance on the stage if:

- I added it to the stage using the GUI
- I wrote its implementation in an external AS file

I can't assign it a instance name otherwise I get this error: Code: ReferenceError: Error #1056: Cannot create property myInstance on MyClassName.

View 4 Replies

ActionScript 3.0 :: Refer To Movieclip On Stage Through .as File?

Jun 25, 2009

I have a movieclip on stage, but I want to move it or animate it with the use of an .as file, how do I refer to a movieclip on stage through a .as file?

Is this even possible or do I have to pass the actual movieclip as a parameter to a function of the class?

To make things more clear, here is my code:

Code on main timeline:

Code:
var myBox:Box = new Box();
myBox.x = 80;
myBox.y = 160;

[Code].....

View 2 Replies

ActionScript 2.0 :: Refer To All Movie Clips On Stage At Once?

Oct 25, 2011

Way of referring to all the movie clips on the stage at once, and of putting that information into a variable for use with hit detection.

View 3 Replies

ActionScript 2.0 :: Using Variable Value To Refer To A Movieclip On Stage

Aug 8, 2006

asically I have a variable in which I store various numbers depending on other aspects of the flash movie and I have a bunch of movieclips that are on the stage all named by number. I want to use the variable value to access and run methods etc of these movieclips.

e.g.
var myVar = "10";
myVar.myFunction();

where the item on stage called '10' will react. I realise this is a confusion between a string and an object/movieclip reference but i'm almost certain ive done this before and ive got a feeling it had something to do with [] brackets on the end of something...

View 5 Replies

ActionScript 3.0 :: Refer A Class From A Nested Movieclip?

Jun 19, 2011

I have the class avanzada.as:

package
{
import flash.display.MovieClip;

[code]........

View 2 Replies

ActionScript 3.0 :: Refer A Class From A Nested Movieclip

Jun 15, 2011

I have this class:

package {
import flash.display.MovieClip;
import flash.filters.BitmapFilter;

[Code]....

Appears this error message:

"1137: Incorrect number of arguments. Expected no more than 0."

I try with:

new MovieClip(this.root).cambiaBlur(gift);

but also fails.

View 1 Replies

Flash :: Refer To Text Field By Class Instance Name?

Jun 17, 2011

I need to populate the text field tField (defined on stage) that resides inside ParentClass (MovieClip with same class name). I want to be able to set tField.text to whatever I want from AnotherClass. How do I do it?

View 2 Replies

Actionscript 3 :: Refer To Multiple Instances Of A Single Class?

Jan 23, 2012

So I know how to target a specific instance using MovieClip(root).objectName which I think is nasty way of referring to it anyways, but right now I'm trying to make a fighting stick-figure game and I can only refer my code to one NPC right now using an "enemy" class but I would like it if I could spawn multiple NPC's at once using the enemy class and instead target the enemy class instead of the instance itself while still having the NPC instances being unique so when I hit one they don't all get hit.

View 1 Replies

ActionScript 2.0 :: Refer To A Variable In A Class File Separate From The Other One?

Feb 24, 2010

Is it possible to refer to a variable in a class file separate from the one you are working in? Say Class1.as had a variable named "exampleVar", and in Class2.as you wanted to put something like "exampleVar++;". Is this possible and if so how would it be achieved?

View 1 Replies

ActionScript 3.0 :: Refer Back To The Movieclip In Main Stage From Other Movie Clip?

Jun 25, 2009

I had attach a few movieclip in the main stage by using addChild() method. If I going to refer back to them inside other movieclip, How can i do so..

For example,
//attaching at the main stage
var earth1:MovieClip = new earth()
addChild(earth1);

[Code].....

How can I refer back this Movieclip from other movieclip's timeline?

View 1 Replies

ActionScript 2.0 :: Refer To The Button Inside The Movieclip After Attach It Onto The Stage Using AttachMovie?

Nov 17, 2003

I had a movieclip which contained a button in it exported as "mc". Then I attach this movie clip onto the stage using: _root.attachMovie("mc", "link1", 1); But i couldn't find it with AS. I mean, how can i refer to the button inside the movieclip after I attach it onto the stage using attachMovie?

View 2 Replies

ActionScript 3.0 :: Refer To A Class Linkage Set In Library From External Code?

Jan 12, 2011

If one uses [Embed] to refer to external graphic assets its easy to instantiate and use them.However, I've got a png in an Fla, with the Class identifier set to "Symbols", Base class is BitmapData.I need to instantiate it like this:

var symbols:BitmapData = new Symbols(1, 1);
addChild(new Bitmap(symbols));
 
Of course the compiler complains about a call to a possibly undefined method Symbols.For a temporary fix I guess i'll put the graphic external to the swf, but for this project it needs to be in the library along with everything else.

View 9 Replies

ActionScript 3.0 :: Main Class Path Without Carring Around Instance Refer?

Jan 6, 2007

I spent my holyday in studing new Flash 9, very good, powerfull but I doesn't find anymore my root, in teory is transformed in stage.root but it doesn't work.I want to understand if I make a mistake in my code or in my approach.I make a simple example with a few object containers.In the firsts lines of the constructor of the mail class I create the style class named tf and then the interface class called interf.Here is my class

Code:
package test {
import flash.display.Sprite;
import test.tf;[code]....

how to get the tf1 Object that as to be in stage.root.mytf.tf1 as some documentation say? If you doesn't comment that line you have an error. Obviously you can carry with you the object because is a small object with a few nidification but It seems to me very very bad for performance and code.

View 2 Replies

As3 :: Professional - Adobe Flash - Refer A Button That In Main Stage While In An Another Clip's Substage

Jan 25, 2010

I just wonder that how can i write this code that means if the "specific" button is clicked(i mean if the homebutton is clicked=true) like this.. and how can i refer a button that in main stage while in an another clip's substage..

View 1 Replies

ActionScript 3.0 :: Adobe Flash Cs4 - Refer A Button That In Main Stage While In An Another Clip's Substage?

Jan 25, 2010

I just wonder that how can i write this code that means if the "specific" button is clicked(i mean if the homebutton is clicked=true) like this..and how can i refer a button that in main stage while in an another clip's substage..

View 3 Replies

ActionScript 3.0 :: Class Can Add The Rectangle To The Root Stage Without Requireing The Instantiated Class To Be Added To The Stage?

May 3, 2010

I have a class called shapeC that only creates a rectangle and then addChild(rectangle);.  That class is instantiated on the main timeline.  Currently, the only way you can see that rectangle is to add the instantiated class to the stage via addChild(shapeC);.  My question is, is there a way that the shapeC class can add the rectangle to the root stage without requireing the instantiated class to be added to the stage?

View 4 Replies

Flash :: Get Stage.stageHeight Or Stage.stageWidth From Imported Class?

Jul 1, 2010

can you tell me a simple and clean way to pass the dimension of the stage to another class, imported in my documentclass?

View 2 Replies

IDE :: Acesssing Derived Class Children (stage Instances) From Base Class?

Jul 16, 2009

I'm slightly new to Flash CS3 + AS3 combo, so its more of a lack of practice question. My question stems from the problem described here http:[url].... . Note, its not the same problem, its a new one.The Problem ,So I have multiple library assets (which are on teh stage) and I want to assign similar functionality to all of them.

Attempt 1: So I create the n assets, create a custom class in AS3, link them to Flash CS3 and obviously enough it gives me the error that multiple assets can't be linked to the same class.Obvious enough to understand (well not completely, because from a programmers background it doesn't make sense).

Attempt 2: Same as attempt 1, but instead of linking all the assets to the same class I make the base class the same class, and let the derived class be dynamically created by Flash on compile time.So the linking works, but the problem is, in my base class I have a method which does something (say an tween) on a child of the library asset. So if the assets on the stage/library are called asset1, asset2, asset3 (same name for asset name, class name, id name), each of them has a sub-movieclip called ... say 'foo'. now if I manually wrote a class for each asset, I could do 'this.foo' to play with the sub-movieclip. However since this functionality is in the parent class, I'm unable to do it.

P.S. If you're form a programming/OOP background, its basically a abstract class problem. My Base class knows how to doSomething(), but it needs aSomething, which is defined in the Derived classes. However I found out that AS3 classes don't support virtual(C++ )/abstract (Java) in the true sense of the word (unless I missed some obvious documentation).

View 3 Replies

ActionScript 3.0 :: Reference Movieclip On Stage From Custom Class Of Document Class

Dec 7, 2009

Is there a way I can reference a Movie clip I have on the main stage from a custom class of a document class?[code]

View 1 Replies

Actionscript 3 :: Stage Properties In Custom Class, Not Document Class?

Oct 14, 2011

I need to use stage.width/height in my CustomClass so I found some topics about it.

if (stage)
{
init(ar,firma,kontakt,oferta,naglowek,tekst,dane);

[code]......

View 1 Replies

Actionscript 3 :: Access A Displayobject On Stage In A Class That Is Not A Document Class?

Mar 7, 2012

How to access a display object on the stage in a class which is not a document class?

I am looking for a solution that doesn't involve passing the stage as a parameter to the class.

One solution i always come across is using "TopLevel.as". Is it a good method because as far as I have heard using global variables is not recommended because it might cause some problems while working on big projects.

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.0 :: Reference Movieclip On The Stage From A Class Of The Document Class?

Dec 8, 2009

Is there a way to refer to a Movieclip on the stage from a class file of the document class

Lets say I have 3 MovieClips on the stage(a Circle, a Square and a Triangle)

I have the document class which calls another class that controls the MC on the stage

Example

ActionScript Code:
package {
public class Example extends Sprite {
//Create the instance of the class being called

[Code]....

View 1 Replies

ActionScript 3.0 :: Accessing An Object Drawn On The Stage In One Class From Another Class

Jan 6, 2011

I have created a class, call it Class1, that has various objects drawn on the stage (drawn in the IDE). It also has a function, called setColour, for changing the colour of those objects. The function works fine if I call it from within Class1.

Now I have another class, call it testClass1, that imports Class1 and calls the setColour function. First of all, none of the stage objects from Class1 are visible. Secondly, when setColour tries to modify the colour of an object, I get the error:

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

This is the code for testClass1:

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

[Code].....

So, what is the problem? Is it possible to change objects that are drawn on the stage of an imported class?

View 3 Replies

ActionScript 3.0 :: Accessing The Stage From A Class Which Isn't The Document Class?

Jul 3, 2009

I'm being really dumb today and I know this should be simple.....How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width? So I've written.....

ActionScript Code:
var myTweenX:Tween = new Tween(this, "x", Regular.easeOut, this.x, stage.stageWidth, 60, true);

[code].....

View 4 Replies

Accessing Stage From A Class Which Isn't The Document Class?

Jul 3, 2009

How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width?[code]

View 8 Replies







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