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
Similar Posts:
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Jan 9, 2011
can I use the Class datatype to make a class a property, then create new objects from that class? Like so:
class Foo{
private var ExampleClass:Class;
public function Foo(exampleClass:Class){
[Code]....
View 1 Replies
Sep 3, 2009
I have a document class that looks like this:
Code:
package
{
import Map;
[Code]....
Is it possible to access a property of the Map class (though map defined in the Document class) from within the hero class?
View 4 Replies
Feb 28, 2010
The Main.as file will have all of the game logic, such as the mysteryNumber.
The other actionScript files represent rooms that the user may click and depending on the 'mysteryNumber', it will execute the 1 of 6 scenarios.
So for example, if a user clicks the Library page, the LibPage.as will call the 'mysteryNumber' and execute some code to display on the library page.
It will be the same for the other 4 rooms.
The problem I have is that the LibPage.as won't call the 'theNumber' property from Main.as
Here's the Main.as
Code:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
[Code]....
View 3 Replies
Nov 30, 2011
In ActionScript 3, there are some classes that will represent a value rather than the class itself. It's hard to explain properly what I mean, so take this example:
[Code]...
View 2 Replies
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