ActionScript 3.0 :: Accessing A Sprite In Class
Sep 4, 2009
I am trying to build a flip clock that utilizes filmstrip pngs. I have the main class instantiaing instances of the flipper class to hold the different number postions of the clock and then I want to tell the flipper instances to animate when the timer reaches a certain point in the main class. The problem is when I tell the flipper class to start animating I get a null value error from the flipper class.[code]Ok I guess writing it our helps figured out that the flipper wasn't through loading when I tried to call its properties, duh. Now can someone refresh my memory on how to broadcast an event to the Main class when the flipper class is done animating? I know I have to set bubbling to something but can't remeber exactly what it is. Also its not letting me create a singleton instance of the Main class in the Flipper class, I've done this before in other projects can someone tell me what I am missing on this one?
View 0 Replies
Similar Posts:
Mar 5, 2010
I created a class, extended the sprite class, and now in the constructor I am trying to set the Sprite's width and height properties which are inherited from the DisplayObject. However, after I set this.width and this.height, and print the values, I get 0 for both.
What the heck is going on? When I view the livedocs I see that DisplayObject has width and height listed as public properties. I have been able to instantiate a Sprite directly, and set the width and height after it's been instantiated, so I don't get it.
package {
import flash.display.*;
public class ScrollBar extends Sprite {[code].....
View 1 Replies
Jan 11, 2011
test.fla's document class is Test.as
test.fla's library has two MovieClips ThingMovieClip and Thing2MovieClip
I tried accessing the Thing.as public var thingState's property;
directly,
using something called Casting (??),
assigning an instance name,
but something that seemed so simple doesn't work,I commented the errors I got next to each way I tried,conversely how would I access the MovieClip Thing2MovieClip from Thing.as (which is a child of Test.as because that's where it's instantiated), it just doesn't recognise an object of its parent exists, here are the 2 classes:
package com.hello.test.test
{
import flash.display.Sprite;
import flash.events.Event;[code]........
I think i'm missing some basic but fundemental understanding of ActionScript 3 and I have no other knowledge of other scripting /programming languages either.when I follow tutorials exactly they seem simple enough, but then start applying what I think is logical usage then it throws up errors..
View 2 Replies
Feb 12, 2009
i have a BasicMap.as that takes an Array and populates itself with the MC objects passed to it by a String reference.it inherits from Sprite, and so it just places the objects on its self.then i have a class that inherits from that class, and gives a little more functionality to it, but in order for it to do that, it needs to place the objects not on itself, but instead inside a holder Sprite, so here is my problem:
code:
package Mushroom{
import flash.display.Sprite;
[code]......
View 8 Replies
Feb 19, 2010
I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it
Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function
[code].....
View 6 Replies
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
Mar 14, 2011
I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem to be working for me.[code]
View 1 Replies
Mar 14, 2011
I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem to be working for me
package jab.enemy
{
import flash.display.MovieClip;
[code].....
View 1 Replies
Jun 9, 2011
I have a class, call it MyClass, and there are several variables that I need to be able to access each instance of from within the class.So for instance, I need the object myObject1, a member of MyClass, to store the variable myNumber.From the main timeline, if I trace myObject1.myNumber, I get whatever number I've stored.
However, I need to check the numbers against another parameter, so I need to be able to test if myObject.myNumber == myOtherNumber. But from within the class, if I trace this.myNumber or myNumber I get null.What is the proper syntax for accessing a variable within a class?
View 5 Replies
Jun 12, 2011
I can't find a way to directly access a MC (or textfield, etc) on the timeline from a Class loaded into my Document Class. No problem from the Doc Class, but can't do it directly from the loaded Class. Is there a trick to essentiall extend the Doc Class AS from another external class?
View 7 Replies
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
Mar 11, 2009
I have an array in my doc class that I'd like to access from an external class. Can you do this and if so what's the syntax?
View 6 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
Oct 6, 2010
I'm trying to do this,
Code:
Main.instance.subClassFunction();
instance is a public static variable on the default class, Main. I can do Main.instance.defaultClassFunction() with no problems at all, I use it to access functions and variables from within other classes. Is it possible to use this method to call a function on the subclass, currently I have to do this,
[Code]...
View 4 Replies
Oct 12, 2011
I'm pretty new to fully using class's for my programming (in-frame scripting satisfied me for a while). I am having a problem accessing the properties of a class from another class. The first class (I'll call it controller) receives a reference to an object of another class (I'll call it display). Display have several specialized subclass (I'll call one SequencedDisplay). SequencedDisplay has a timer in it that I need to access:
[Code]...
View 2 Replies
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
May 25, 2010
I have created a movieclip in the library and added a class to it. I want to access a function and set an Array in that class from the document class...Heres what im doing now which is not working... it says startnow function is undefined.
PHP Code:
package comimport flash.display.*; import flash.events.*; import com.NavMC public class Capability extends MovieClip Constants: //
[code].....
View 5 Replies
Jul 21, 2010
would it be possible to access a variable name containing a class from the class itself?
Example:
Code:
var __NAME__ = new TestClass();
package com.Test
{
[Code]...
View 14 Replies
Dec 3, 2009
but is possible to actually see the Sprite class?
Is accessable in any way, or written in C++ and embedded into the Flash player?
View 9 Replies
Nov 30, 2009
I'm tryin to set the global focus to a specific class that already exists on the stage after I remove a popup dialog from the screen. I pass the name of the class that was on the stage before the popup dialog is shown by string to the popup class.So public function PopupMenu(pClass:String)after I remove the popup dialog, I want to restore focus back to the previous class so it can accept key events again.How would I set focus to an instance of an object on stage. Currently I have something like this:
Main.mainStage.focus = (InteractiveObject)(getDefinitionByName(prevClass));
but it returns this error: TypeError: Error #1034: Type Coercion failed: cannot convert com.cox::IdleScreen$ to flash.display.InteractiveObject.
[code]......
View 5 Replies
Dec 26, 2009
I'm wondering (based on scoping rules) how I might do the following: I want to draw to a sprite that exists on the main stage in which I have a class instantiated.
So something like
public function MyClass(reference:String){
this.reference = reference;
}
[Code]...
Would I use super() in this case, or what's the usual methodology?
View 1 Replies
May 24, 2010
write a class for a sprite?
View 1 Replies
Apr 15, 2010
I have a class which subclasses Sprite (Class1). In this class I draw something on the stage. I have another class (Class2) that creates several instances of the first class (Class1) and places them on the stage. As I am creating the instances of Class1, I am adding an event listener for the CLICK event for each instance.When I click on any of the Class1 instances, I would like to execute a public function in Class1. However e.target is Sprite and I cannot conver it to type Class1.
View 2 Replies
Jul 14, 2009
I created a menu from a created .as extended Sprite class.
Except from this menu, I need it to return a String value of the item name the user selected.
View 17 Replies
Sep 24, 2009
I am working with a simple MVC pattern.
But in my model i try to do this:
Main(root).Message(" model done!");
But i cant pass in the root, couse the model classes are Eventdispatchers and no sprirtes.
View 1 Replies
Feb 8, 2009
Say I have an image that I loaded using a file loading class I wrote, but then I want to have another class be able to re-size the image anytime the browser is re-sized... can I do something like:
ActionScript Code:
var _fileLoaded:FileLoaderClass;
//this already contains a loaded image
[code].......
View 1 Replies
Feb 15, 2009
I have a clas that inherits from sprite but i want to know when the x and y is set so i can make changes inside the instance, but i cant figure out how to do that...
i need it so that say if i set the x with the normal x property, it can set another variable or run a function.
View 2 Replies
Feb 5, 2007
So I have a class that extends sprite. When I call an instance of my thumbnail object, I apparently can't use typical transforms on it by accessing .x and .y properties. These are not inherited from the superclass? Do I need to tell it to inherit these traits?
View 4 Replies
Dec 9, 2009
How do I reference MovieClips or Sprites created in the Document class from a custom class?[code]But I have a lot objects I want to reference so using the above method would take to long.I know I can do this to reference a MovieClip on the main stage from a custom class.[code]Would referencing the sprite created in the document class be similar?
View 1 Replies