ActionScript 2.0 :: Add Instantiated Class To Stage?

Nov 18, 2008

I know how to do this in as3, it's easy.

var c:myclass = new myclass();
addchild(c);

how the heck do you do this in as2?

View 1 Replies


Similar Posts:


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

ActionScript 3.0 :: Add MC Class To Root (stage) From Another Instantiated?

Feb 13, 2009

h1. I have a Class (let's call it "Button") that is linked to a library item (a movieclip) which I have on the stage

2. Now this Button class, when clicked will produce an alert in the form of another class (let's call it "Alert").

3. There are two critical things in the way I want this to work:

A) I want Alert to be a child of the main stage, not the Button class

B) I want Alert to take care of adding itself to the display list, not have Button add it.

So in a nutshell, I want to call Alert like this:new Alert("Hello, Kirupa Forums!");

The Alert class needs to draw the shape (check), add the text (check), add itself to the display list (how? if I try to access "stage" I get a null reference, though I don't know why), and destroy itself (I'll burn that bridge when I get to it).

View 4 Replies

ActionScript 3.0 :: Declaring Un-instantiated Class Makes Stage=null

May 12, 2011

In my document class I have this

[Code]....

It does not matter where I declare the var __w:Who in the constructor, as a class var or in another function entirely. The whole thing still operates normally but it's irritating not being able to set my stage.align=StageAlign.TOP_LEFT; in the constructor.... I am guessing it is something in my Who class because it does not happen if I declare any other vars the constructor in Who pretty basic:

[Code]....

View 2 Replies

ActionScript 3.0 :: Removing Instantiated Objects - VideoPlayer Class From Main Class

Nov 8, 2009

I have question regarding removing instantiated objects. Let's say i have a main class in which i instantiate a custom video player (or whatever) class:

Code:
...
var videoPlayer = new VideoPlayer(...);
addChild(videoPlayer);
...

And inside VideoPlayer class i have of course dozens of objects (movie clips, sprites representing different parts of VideoPlayer) and dozens of event listeners attached to them. My question is, if i want to remove this VideoPlayer class from my main class is it enough to just do:

[Code]...

View 2 Replies

Actionscript 3 :: Access Variables In Main Application Class From Instantiated Class?

Apr 8, 2010

I have a initApp.as which instantiates a class which needs to access the "currentState" property and the States array as well. However we cannot get this to work as we cannot see how we can access this information.

Within initApp.as currentState is accessed via "this.currentState". This does not work in the class which is instatiated within initApp.as. The following error is thrown:

"Access of undefined property currentState."

View 1 Replies

Actionscript 3 :: Big Performance Difference Between Using Class With Static Functions Vs Instantiated Class?

Mar 22, 2012

I'm wondering if anyone has experience with if there is a big difference in performance in ActionScript 3 between keeping a class with only public static functions, and utilizing those functions often (as in a frame event at 30fps), and in turning the class into a "normal" class of which I instead make an instance and call the functions via the instance instead.

View 1 Replies

ActionScript 3.0 :: Class Has Be Instantiated In Document Class?

Mar 18, 2009

I am making my way with AS3 in little steps and have hit a road block. This is what I have:

I have a document class called "Document Class" I have a custom class called "Game"

I have instantiated an object of "Game" class and I am able to trace a class method which return a simple "HELLO". within my Game class, I have a variable(type Array) called "questions" as instance variable.

I would like to add questions to "questions" array by using "Mutator" method, or count the current elements with the questions array and return the total number of questions. I am unable to add or access elements to the questions array.

View 7 Replies

ActionScript 3.0 :: Dynamic Text Is Placed On The Stage And Instantiated?

Sep 6, 2011

I'm facing problem regarding dynamic texts. My dynamic text is placed on the stage and instantiated. I'm setting the text value in AS by using textname.text = smthing... Initially it was showing the correct result on testing the movie clip.. But after few runs it started showing garbage values... When i traced the value, trace showed the correct result but not displayed properly on the dynamic text..I then deleted and recreated the texts.. After some trials od deleting and reinserting it started working fine.. But soon the problem creeped in.

View 2 Replies

Flash :: Find Out If A Class Has Been Instantiated

Nov 25, 2010

I usually use if(object!=null) but it doesn't work well.

How can I verify if the class is instantiated. I want to get rid of the 'cannot access a property of a null object or reference'.

I mean, the 'var object:Object;' is just a reference to an Object class instance. When i initialize it with 'object = new Object()' it runs the code in the constructor, initializing it. How can I check if it has been initialized or not.

View 3 Replies

ActionScript 2.0 :: Instantiated FLV Playback Class?

Aug 13, 2008

I've been struggling with this for almost a day now and I can't seem to find the problem. I'm making an instantiated FLV playback class in actionscript 2, but it just doesn't play the video

Here's the code, if I uncomment the camera parts and attach _cam instead of _stream it will show the camera feed, it just won't play my movie (and I get no errors whatsoever).

[Code]...

View 2 Replies

ActionScript 3.0 :: Get A Property Value From An Instantiated Class?

Jun 15, 2011

Im trying to get the value of the textWidth property in class Main from a text field created in an instantiated class Label. When I trace the value from within the Label class I have access to the values. I'm trying to use a get function to pass the value to the main class.[code]

View 3 Replies

ActionScript 3.0 :: Replace And Instantiated Class's Method

May 9, 2009

Can you do this in AS3?
 
function onLoadMe(e){
};
 
var pic:Picture = new Picture; // custom dynamic class with a method called onLoadPIc
pic.onLoadPIc = onLoadMe; i'm trying to change the method of my custom class on the fly for this instance...

View 2 Replies

ActionScript 3.0 :: Call A Method From A Instantiated Class?

Feb 25, 2012

I have this class called Main. And inside this Main class I have a method that I'd like to call from a the main timeline.

So on the main timeline I have instatiate the Main class like this:

var mainClass:Class = flash.utils.getDefinitionByName("Main") as Class;
var main:Sprite = new mainClass(this, mc1_mc, mc2_mc);
addChild(main);

Then on the frame after that, I try to access a function inside that Class like this:

main.prepareGame();

But I get this error:

Scene 1, Layer 'Layer 2', Frame 3, Line 61061: Call to a possibly undefined method prepareGame through a reference with static type flash.display:Sprite.

View 7 Replies

ActionScript 2.0 :: Instantiated Class Does Not Revert To Its Defaults?

Oct 13, 2007

I'm very confused. When I instantiate a class, I'm assuming that the object is reset to its default variable values. Not so. Consider this:

Code:
class ClassTest extends MovieClip{
var arr:Array = new Array();
function ClassTest(){

[Code].....

...even if the two objects have different instance names! It's as if it is making my arr variable static by default, and not resetting it to a new array in the second instance. How do I get around this? Do I need to somehow have this code instantiate itself with something like "this = new ClassTest();"

View 3 Replies

ActionScript 3.0 :: Add An Event Listener To A Class Instantiated?

Aug 4, 2010

What I'd like to do is add an event listener to a class instantiated by my document class that listens for different key presses. So far I can't use stage.addeventListener or I get the null object error so my question is:

a: how do i add an event listener to the stage from another class and b: is it even necessary to add it to the stage , can I listen from that class?

View 4 Replies

ActionScript 3.0 :: Class Being Instantiated Twice In ProgressEvent.PROGRESS Handler?

May 25, 2010

I have an XML file which has info about projects for my portfolio, there are 7 of them at the moment. I'm trying to have a preloader animation show up in place of every portfolio image before it's shown on stage. The problem is that there are 14 of those preloaders being instantiated rather than 7!! How could that be possible? Check out my code:

ActionScript Code:
package  {
//import com.prodoubled.XMLLoader;
import flash.display.Loader;

[code]...

View 1 Replies

ActionScript 3.0 :: Instantiated Symbol Not Appearing When Class Path Used?

Mar 3, 2010

I have a mc in my library called SimpleButton and in the class path for that mc I have the path to my class: com.company.ui.buttons.SimpleButton.

But when I try to instantiate the symbol using the following code, it does not appear on the stage.

Code:
var simpleButton = new SimpleButton();
addChild(simpleButton);

The code works fine when the mc class path is just SimpleButton, the symbol is added to the stage. However when I try to use my own class, the base class disappears from the linkage box in the mc properties dialog and the symbol does not appear on the stage.

Here is my SimpleButton class:

Code:
package com.company.ui.buttons
{
import flash.display.DisplayObject;

[Code].....

View 2 Replies

Flex :: Unable To Create A New Instance Of Type 'some Class'. Types Cannot Be Instantiated Without A Public - No Arguments Constructor

Mar 1, 2011

I have a class with constructor and overloaded methods in it. When i try to import that class using blazeds i get an error saying [RPC Fault faultString="Unable to create a new instance of type 'some class'." faultCode="Server.ResourceUnavailable" faultDetail="Types cannot be instantiated without a public, no arguments constructor."] How to import class having overloaded methods using blazeds

View 1 Replies

ActionScript 3.0 :: "Move" Stage-instantiated Movieclip To A Child Container?

Nov 3, 2011

I have some movieclips that are instantiated on the stage. Is there any way to "copy and remove" those movieclips to a child class?[code]...

View 2 Replies

ActionScript 3.0 :: Instantiated As "menu", And Inside "menu" There Are MCs Instantiated

Feb 15, 2011

I have an MC instantiated as "menu", and inside "menu" there are MCs instantiated with the names of their pages. I'm trying to define a function for each of these MCs on the main timeline and what I did was as follows (party is the name of one of those MCs that are inside the MC menu):

[Code]...

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







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