ActionScript 3.0 :: Calling An Array In One Class From Another Class?
Oct 13, 2010
I'm trying to call a function in one class from another class and I'm using an array in the function of the class that I am calling from the other class. The array is declared and instantiated in the one class but when the other class calls the function with the array in it I get an error #1010: A term is undefined and has no properties. because the class that is calling the function that contains the array doesn't know that it is already declared. Anyway here is the code.
//CLASS THAT CALLS THE FUNCTION OF THE OTHER CLASS WITH THE ARRAY:
public class SpaceWolf extends MovieClip
{
private var _playerMissiles:PlayerMissiles;
[Code].....
View 7 Replies
Similar Posts:
Aug 16, 2010
I have two classes. The Main class calls a function, which is defined in a Second class.I'm getting the following error:Error 1120: Access of undefined property myFunctionBasically, I am creating buttons in the Main class that will add a corresponding Child to an Object in the Second class (if you click one button, child x1 will be added, if you click another button, child x2 will be added, and so forth).Here's the relevant code for the Main.as file:
package
{
import flash.display.MovieClip;
[code].....
View 3 Replies
Sep 23, 2009
package{
public class Character{
protected var _hp:uint = 50; //Character Health Points
protected var _power:uint = 5; //Damage dealt
[Code].....
I`m instancing a Character and a Player in the Main Timeline, all in frame 1.
When I use: ""player.attack(character)"" it works fine by itself.
So I added the if (defender._hp <= 0) this.win() which gives me the following error:
1061: Call to a possibly undefined method win through a reference with static type Character.
"defender" is a Character instance, "this" is a Player instance and "win()" is a Player method. I try to call the Player method inside a Character method using the Player instance adding the "." and his method name
Do I really need to define the win() function in the Character class? Is there a bypass to use a subclass method in a parent class method if it`s called from an instance of the subclass?
View 6 Replies
Nov 21, 2009
I'm not sure that I'm on the right track here. I've got what is essentially a 'gateway' movieclip and depending on the CLICK a corresponding movieclip (form) is loaded -- these all being in their own AS file. There are multiple corresponding pages that will all load/close in their own fashion but the 'gateway' will reload in it's own function-- consequently, I have this function on the main_AS. Can I trigger this function from the sub class or do I need to move the 'reload' function to a 'reload' class.
View 2 Replies
Feb 4, 2012
I've been searching around trying to work this out for a while now. There's been various ideas popping up, like dispatchEvent etc but nothing that seems to be a clear, simple way of doing this.What I'm trying to do is call a function from a class seperate (but in the same folder as) my document class.Specifically, I want to 'spawn' an object and run a function within that object's class from my Main.as.The snippet I have at the moment is as follows;
In Main.as:
var object:class_Object = new class_Object();
object.spawn();
[code].....
View 2 Replies
Jul 15, 2011
I have the following parent class that I'm working with:
Code:
package {
import com.poptent.SubClassOne;
import com.poptent.SubClassTwo;
[Code].....
I am trying to set it up so that a parent method called by subClassOneInstance can affect subClassTwoInstance.
View 4 Replies
Feb 24, 2009
I keep getting an "undefined property" error when I try to call an external function from within the Doc class. I added the error message to the Doc Class below so you can see where it occurs.
If I take the code from the Tooltip.as below and place it on the FLA's main timeline I can get things working fine, but I would like to move all script to classes. The document class structure looks like this:
Drag_and_Drop.as
Code:
package {
import Tooltip;// Import custom class
public class Drag_and_Drop extends MovieClip {
[Code]....
I realize that I could just combine all the code in the Doc class to get it working, but it would be nice to separate out this particular code which has only one use.
View 4 Replies
Jul 5, 2010
I have a rather silly question but as3's document class always gets me confused.I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).
View 6 Replies
Mar 9, 2011
I'm trying to have a class reference a variable within the document class and have scoured the web but can't seem to find a solution. It seems relatively simple, but is a major stumbling block for me.
I want the variable in the doc class to increment each time a draggable object is within bounds and snapped to a box in the subclass. By tracking successful snaps, the objects will be placed one under the other each time.
View 4 Replies
Jun 12, 2009
I want to call a function that is inside in a document class from another class how can i do this ??
View 1 Replies
Jul 6, 2010
I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).
I have tried everything and nothing seems to work. How do I do this?
View 8 Replies
May 27, 2010
I have a two classes. One is linked to a menu and controls that. The other is linked to a 'viewer' movieclip. At the start (in the contructor function of the classes that relates to that mc) the 'viewer' mc feeds off an XML document, and an image is loaded into itself. When I click on a menu tab I want the image to change.
Both the viewer mc and the menu mc are on stage already. I tried to import the viewer classes into the menu class...
[code].....
View 6 Replies
Oct 19, 2010
I;m converting some of my as2 classes to as3 and have run into a problem where my ships class cannot seem to call my vectorGraphics class. They are in the same folder (sprites).
The basic flow is this: On the main timeline I instantiate Ships and vGX.
ActionScript Code:
import sprites.ships;
import sprites.vectorGraphics;
[Code].....
View 2 Replies
May 8, 2010
I've been searching around the forums to find a solution of this problem. I have two classes: Monster and Player. Constructors are defined and the classes by themselves apparently works. My problem is that I want to get player.x inside the Monster class.
[Code]...
View 5 Replies
Mar 7, 2011
I am creating a dynamic training module in which I create a navigation on run time using XML. The one question that I have is that when I click on the navigation button I want to change the alpha of the movie clip that it corresponds to. I know that I can put the movie clips on the stage and do a "find" command to find the instance names, but I find that to be unreliable and not very dynamic.So what I want to do is in the XML have the name of the exported class of the movie clip I want to call. So fro instance for my landing I will have a movie clip in my library with the exported class Landing(). But the xml reads this as a string.So a line of code like:Code:private var landing:xml.navButton.name= new :xml.navButton.name();Would not work.
View 1 Replies
Aug 4, 2010
My question is, can a function bring in an argument and then use that argument as a class name? Here is an example:
Actionscript Code:
package {
import flash.text.Font;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
public class embedTest extends Sprite {
[Code] .....
Basically, if I have a swf with:
Actionscript Code:
var example:embedTest = new embedTest(Font1);addChild(example);
Can the class file bring in Font1 and use it as the class name.
View 8 Replies
Sep 26, 2010
I want to call a function on the "Driver" class which is the main document class, from another class.
but i always get this error. 1061: Call to a possibly undefined method Test through a reference with static type Class. here is the main document.
[Code]...
View 5 Replies
Mar 17, 2011
randomize the calling of different classes / functions.How would I go about invoking a new class using dynamic input? here is what i would like to do in my best code explaination
Code:
function addEnemy(screenType,enemyType)
{
//in this senario screenType = "H";
//& enemyType = "1";
[code]....
View 1 Replies
Jan 10, 2011
I have two classes, in one (the Start class) I want to run a function I created in another (the Brown class). I commented in Start where I want to call the "addBrownListen" method. I tried doing it with the line:
Brown.addBrownListen();
But that didnt work.
Here are the two classes:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Brown extends Rebounders {
[Code] ......
View 2 Replies
Jul 27, 2009
package asas
{
public class main extends EventDispatcher[code].....
I have this class and a MXML file... how will i call the function doCheck in button. When i call like this, it throws me an error.
<mx:Button
styleName="LoginButton"
id="loginButton" [code]...
View 2 Replies
Oct 27, 2011
I'm trying to call a function to another class after an event.
Here's my code:
From the doucment class:
public static function redrawMap():void {
removeChild(global.world);
var world:WorldHandler = new WorldHandler(40,30);
[Code]....
I can't get it to work correctly, I get weird messages like "Call to undefined method removeChild" and it pointing to the redrawMap function. Which means it found the function, but I can't seem to do anything with it.
View 3 Replies
Jan 11, 2012
I have two classes. One called Sledge and one called Sock, there is also the document class called Main. My issues are as follows: Inside of Sledge, I call a function that is defined inside of the Main document class. How would I go about telling the class to go to the document class and run that function? Would this also be the same for other classes or just for the document class? Inside Sledge, I have the following statement: if(hitTestObject(sock.myHitArea)) { /* somecode*/ }
sock is an instance of another seperate class, and by this point has already been created. However when I try and run this I am told it is not defined. How would i go about solving this?
View 1 Replies
Sep 29, 2008
I have done this type of thing a million times before, but I cannot for the life of me figure out why it isn't working this time. As of now I have three classes: Main, UI, and Bear.
Main creates an instance of UI and puts it on the stage. UI has, among other stuff, 7 instances of the Bear class sitting on the stage. The Bear class has a public function:
[Code]...
View 3 Replies
Oct 7, 2008
Basically, I want to call a function that is in an external class: So I have my main class which is good, but then I want to call a function in another class, in as2 you'd do it like this foldername.foldername.asfile.functionname, but it doesn't seem to want to work in as3.
View 4 Replies
Jul 1, 2009
Im calling from my document class two istances of another class:
Code:
public function loadImages():void
{
var full_loader:ImageLoader = new ImageLoader(this,pathsFull_array
[Code].....
since when i call just one of those at time everything is working fine and images get loaded,im asking if its wrong calling them together??
View 1 Replies
Jun 25, 2007
I'm having some problems importing a class, the message that Flash gives me is this; The class being compiled, 'ImageLoader', does not match the class that was imported, '[URL]'. The only line of code in my flash movie is this: import com.martijndevisser.*; And yes, the class is in that folder The class is from here: [URL] I've used the class before and it works fine, I just dont know what to do?
View 4 Replies
Jun 11, 2009
i am making a simple slideshow in AS2 (Flash CS3). I got all the core logic working fine in a FLA frame action - now trying to externalize it into a class. The first snag I hit was in trying to setTimeout -- when I passed a class method as the setTimeout function, it no longer could talk to the class variables/methods. I fixed this by passing along an instance of the class to the class method called by setTimeout something like this:
setTimeout(myMethod,delay,classInstance);
Now I've got a similar problem with my Tween.onMotionFinished() handler -- i want it to call another method in my class but it doesn't know what the class is or how to access it.How should this be accomplished? I've tried a similar trick in which I try to stash a class instance inside the tween (through bracket syntax eg. myTween["classInstance"] = this; but this doesn't seem to work.
Is this a case where I basicallyneed to create an event listener in my class & then just send an event out when the tween finishes? Or is there a simpler way to let the tween know about the class (without relying on instance names of the class itself)?I'm still new to OOP so not completely got my head around what can/can't access my class methods/variables especially when I'm creating objects like Tweens inside my class.
here's my current SlideShow.as class:
Code:
/*
imports
*/
import mx.transitions.Tween;
import mx.transitions.easing.*;
[code]...
and then I just create a slideshow from an existing framesequence MC (who has stop() on frame 1) in the FLA thusly:
Code:
import com.pixelfarminteractive.slides.SlideShow;
//SlideShow(slideMC:MovieClip,easeTimeSec:Number,holdTimeSec:Number,numSlides:Number)
var ss = new SlideShow(slideshow_mc,2,2,4);
ss.start();
View 17 Replies
Dec 4, 2009
I have a MC1 with a class that controls it on my timeline. Within this MC there is a second MC2 which contains a short animation. During that animation i need a trigger that will call a method from the class attached to the main MC. MC1 is linked to CLASSMC1 contains MC2(short animation)MC2 calls a function in CLASS
Code:
package {
public class CLASS {
[code].....
View 1 Replies
Sep 9, 2009
I have the following two classes and can't seem to figure to figure out how to call a function in the top one from the bottom one. The top one get instantiated on the root timeline. The bottom one gets instantiated from the top one. How do I call functions between the classes. Also, what if I had another call instantiated in top one and wanted to call a function in the bottom class from the second class?
package
{
import flash.display.MovieClip;
[code]......
View 12 Replies
Mar 13, 2010
I'm new to writing several different class files.. and trying to make a set of boxes that expand/collapse by mouse click and timer..
I have 4 class files, Box, BoxGroup, BoxTimer, and Main.
I can call the functions in Box class from BoxGroup class, but not the functions in the BoxTimer class. it keeps throwing this error. I don't understand why since i'm using the same method between the other 2 class files...
ReferenceError: Error #1069: Property timer_start not found on
CollapsingBox and there is no default value. at
CollapsingBoxGroup/on_click()
[Code].....
View 4 Replies