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


Similar Posts:


ActionScript 2.0 :: Calling Function With A Argument In The ContextMenuItem Class

Jan 21, 2006

im tryng to call a function with a argument in the ContextMenuItem class.[code]It seems that when ever I try to send an argument with the down function, it simpley dont work and without it, it does work

View 1 Replies

Actionscript 3 :: Flash Cs4 - Throwing Error #1009 When Calling AddChild With A TileList As The Argument?

Mar 23, 2011

To be exact this is the error.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.containers::BaseScrollPane/drawBackground()
at fl.controls::TileList/draw()
at fl.core::UIComponent/callLaterDispatcher()

Now I've tried several of Adobe's own examples from this page, http:/[url]....., and they all throw this error as well.The error is triggered by the TileList instance being the argument of the addChild function.Here's my package, which works fine when I change the displayComponent is be a List.

package com.pennstate {
import fl.data.DataProvider;
import flash.display.MovieClip;[code]........

View 2 Replies

Actionscript 3 :: Pass Class As Constructor's Argument?

Oct 26, 2011

I'm trying to pass my object class as constructor argument. I have something like this:

package myclass {
import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.display.Bitmap;

[code]....

Now, when I try to create my Example:

import myclass.Example;
var example:Example = new Example(myObjClass);

I get message, that I'm not passing any variable (Error #1063). Why is that? What is wrong with it?

View 1 Replies

ActionScript 3.0 :: Pass Name Of A Class As Argument In Function

Mar 14, 2009

I have recently moved from AS2 to AS3 and I am finding the transition fairly easy, however I do have a few questions, some of which may not have been possible with AS2 but I would like to achieve them in AS3

1. Is it possible to pass the name of a class as an argument in a function and then use it to create a new instance. e.g [code]

2. Carrying on from the previous question, if a class can infact be passed, can I specifying a variable type for the argument so that only classes and not instances will be accepted?

3. I have three class files that all inherit some functions and variable from another class called Ship. Is it possible to specifying a variable type so that the variable can only hold instances of classes that are inherited from the Ship class?

View 6 Replies

ActionScript 3.0 :: Passing Argument From A When Using One Class For Multiple Assets?

Aug 7, 2009

I had a class that I was passing a simple argument to like so:
 
var quiz_1_2:CaseStudyQuiz = new CaseStudyQuiz(2);
addChild(quiz_1_2);
 
I now would like to use this class for multiple MCs in my library. I thought I could let Flash create a class for each of them and specifying the CaseStudyQuiz class as the Base class. When I do that, I get the following error:
 
1136: Incorrect number of arguments.  Expected 0.

View 12 Replies

ActionScript 3.0 :: Passing Entire Doc Class As Function Argument - Good Or Bad?

Sep 8, 2009

I saw a post that touched on this, but I thought it deserved a thread of its own for explicit verification. It seemed that some of the resident geniuses here had given the thumbs-up to passing your whole doc or app class to a function. Please correct me if I'm wrong, as this sounds convenient but I assumed it would cause heart attacks and CPU meltdowns.

EXAMPLE: Say I have an app class that controls my entire game (or slideshow), and it has an ENTER_FRAME scrolling function that's 50 lines long with tons of conditionals so I want to take it out and make it an external file. I pop it into a new .as file but now all my variables are out of scope. I could pass them each individually, but there are so many it's impractical. So my question is: good or bad practice to pass the entire class?

[Code]...

View 4 Replies

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

Flash :: Static Class Keeps Throwing "Error #1063: Argument Count Mismatch"

Aug 17, 2010

I've created a static class in Flash which works as the inventory delegate for this game. Flash though keeps giving me this error:

ArgumentError: Error #1063: Argument count mismatch on Inventory(). Expected 1, got 0.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()

[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 :: Calling A Function From A Class?

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

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

ActionScript 3.0 :: Calling Method From Another Class

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

Flex :: Calling A Function From A Class?

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

Flash :: Calling A Function In Another Class

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

Actionscript 3 :: Calling A Function From One Class From Another

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

ActionScript 2.0 :: Calling Function Of A Class?

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







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