ActionScript 3.0 :: Calling A Class Dynamically?

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


Similar Posts:


Actionscript 3 :: Calling A Method, Which Is Defined In Another Class, From Main Class Gives Error 1120?

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

ActionScript 3.0 :: Calling A Function From An Extended Class Inside A Top Level Class

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

ActionScript 3.0 :: Calling A Function Located On The Main Class From A Sub Class?

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

Actionscript 3 :: Flash - Calling A Function From A Class Within A Separate Class?

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

ActionScript 3.0 :: Calling Method In Parent Class From Imported Class?

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

ActionScript 3.0 :: Calling Function In Custom Class From Document Class?

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

ActionScript 3.0 :: Flash - Calling Method On Document Class From Another Class?

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

ActionScript 3.0 :: Calling A Function In The Document Class Form Another Class

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

Actionscript 3.0 :: Calling Document Class Function From Another Class?

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

Actionscript 3.0 :: Calling Method On Document Class From Another Class?

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

ActionScript 3.0 :: Class Calling Function From Another Class?

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

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

ActionScript 3.0 :: Class Calling A Function In Another Class?

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

ActionScript 3.0 :: Calling A Class Function Within Another Class?

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

Creating And Calling Array Dynamically

Jul 1, 2010

I would like to be able to create and call an Array dynamically. So to pass a name through a function and create an array based on that name.Then to store values into sections in the array. I got the creating the array dynamically working, but I can't seem to store into it.

Code:
Sort = function (numOfVars,Name,toSort){
This works
_global[Name] = New Array(New Array (),New Array());
This does not work
_global[Name][i][c]= 3
This does not work
_global[Name + "[i][c]"]= 3
This does not work
_global[[Name][i][c]]= 3
}

View 1 Replies

ActionScript 2.0 :: Calling Clips Dynamically?

Jan 12, 2009

I have done a bit of searching for this and have come up short. I have seen a few others post this question but never seen an answer... So here I am hoping I can find it here!Ok, so my problem is that I need to call MC's from the library dynamically depending on a number of previous user chosen options... and the names are all fairly similar but with a number or word difference...So here is my problem...I need to be able to call a clip such as the following

ActionScript Code:
var1+"mc_name"+var2+"mc_name"

View 6 Replies

ActionScript 2.0 :: Dynamically Calling A Function

Aug 3, 2004

I'd like to be able to call a function dynamically, ideas?I saw an example. It doesn't work, but perhaps it's a starting point:[code]

View 4 Replies

ActionScript 2.0 :: Calling Functions Dynamically?

Oct 13, 2003

i'm trying to call a function on a clip, but i want to use a variable that i'm sending to the clip so that when the one function gets done it knows what to do next. i just have no idea of what the syntax would be. here's a sample.

[code]...

View 3 Replies

ActionScript 2.0 :: Dynamically Calling A Function?

Aug 3, 2004

I'd like to be able to call a function dynamically,?I saw an example. It doesn't work, but perhaps it's a starting point:

myFunctionName = "myFunction";
_root[myFunctionName](myParams);

View 4 Replies

ActionScript 3.0 :: Dynamically Embedded Swf With ExternalInterface Calling

Apr 8, 2012

I have a swf doing some javascript calls. It works fine if the swf object is embeded as part of html. When creating it thru javascript, the code doesn't work. I've tried back &forth for a while, no luck. attached my code snippet below,
 
/* javascript */
<script language="javascript">var g31=false,g32=false,g33=-1,g1=-1;function f31(p){ alert(p)}
function f34() { g31=true; g33>=0&&(window.clearTimeout(g33),g33=-1);

[Code].....

View 1 Replies

ActionScript 2.0 :: Dynamically Changing Variable Calling?

Jan 27, 2011

Beginner question here. Basically I have the following code:

if (_root.obj1 == 1) {
n = _root.invArray.length;
_root.obje1._y = _root.inve(n)._y;

[code].....

View 1 Replies

Actionscript 3.0 :: Calling A Dynamically Generated, Nested Mc

Jul 19, 2009

So basically my file is a photo gallery. There are two ways to click through the photos - the previous/next buttons or the camera icons on the floor plan diagram. The cameras are dynamically generated from XML, into a cameraHolder mc.

I have the controls working independently, but I need to have them working together (ie: if you click the previous/next buttons, the camera icons would change state) I don't have all the over/selected/visited states working yet, but I don't really need help with that.

What I really need to be able to do is figure out how to call the camera icon clips. See line 138 for where I tried to trace one: trace(cameraHolder.camera0); It returns as undefined.?

Also is is possible to call a mc where part of the name is a variable? For example, you'd call something like "camera" + whoIsOn instead of camera0?

FYI: this file is definitely a work in progress. I kind of slapped together two examples to get what I currently have...

View 2 Replies

ActionScript 2.0 :: Calling A Function In A Dynamically Attached MC?

Mar 27, 2008

I am having problems with this and I can't quite figure out what I am doing wrong.I have the following AS inside a function in my movieclip.

this.attachMovie("team_" + whichProfile, "team_" + whichProfile, this.getNextHighestDepth());
var teamProfile = ["team_" + whichProfile];

[code]......

View 3 Replies

ActionScript 3.0 :: Calling A Loader's Data Dynamically Using Variables?

Oct 25, 2011

I am calling some data from php, which simply retrieves some data from MySQL.  The tables retrieved are called dynamically and so I have a list of those tables sent to actionscript below and called by event.target.data.its and event.target.data.ces.  These will have a list of the tables called.  I then send the name/value pairs to actionscript from php by using those table names (all inside of php here) dynamically.
 
$sql3 = "SELECT * FROM `specialties`";
$getit = mysql_query($sql3);
while($row2 = mysql_fetch_array($getit)){
for($i=0;$i<sizeof($itlist);$i++){

[Code]....

View 2 Replies

ActionScript 2.0 :: SetInterval Parameters - Dynamically Calling Function

Jun 27, 2007

I have a function gameTimerInterval() set to run every half second. Every x of those intervals (the value of x varies in this situation), it creates another interval that calls the function birdTimerInterval() every y of these new intervals. Basically, gameTimerInterval() determines when a new flock of birds will enter, and then birdTimerInterval() controls how each individual bird in the flock comes in (one at a time). The thing is, there can be multiple flocks coming on the stage at the same time, so birdTimerInterval() will need to receive a parameter so it knows which group of birds to control. The only way I could see achieving this is doing something like dynamically passing the name of the interval that's calling the function, as I don't know how I could use global variables or arrays to distinguish which flock should be moving.

View 4 Replies

ActionScript 2.0 :: Calling A Numbered Function From Dynamically Created Buttons

Jan 28, 2011

Im having a problem where I have a set of numbered functions and I need to call them from the dynamically created buttons but I need to make sure the numbered functions are relative to each button..so button 1 will call function 1.

Code:
info1 = function () {
var1 = "blablabla"
var2 = "blablabla"

[Code]....

View 3 Replies

ActionScript 3.0 :: Calling A Class From A XML?

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

ActionScript 3.0 :: Dynamically Create Class Inside A Class?

Apr 19, 2010

This is what i'm trying to do :

I have 1 class that extends movieclip, let's call it Class0. I have 1 class that extends movieclip, let's call it Class1.

I create an instance of Class0 on stage like : var myClip0:Class0 = new Class0(this, "Class1");

The class Class0 when initializing, will create a new movieclip (myClip1) and add it as child, as an instance of Class1, like myClip0.myClip1. But it's when i create that clip, i want to tell it, it's an instance of Class1, like :

private var myClip1:Class1 = new Class1(this);

Where Class1 could be any class.

How do i pass Class1 to Class0 so it can create it dynamically?? Do i have to use the apply function??

inside Class0, i have a function that does :

Code:
if(subClass){
initSubclass(subClass);
}

[Code].....

View 8 Replies

ActionScript 3.0 :: Calling Argument And Use It As Class Name?

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







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