ActionScript 1/2 :: Reference Static Class Vars Via A String?
Feb 5, 2010
I am trying to set the value of some static vars but I need to reference the class with a string rather than a proper constructor. In AS3 I can do this with:
var ref:Class = getDefinitionByName(classDefinitionAsString) as Class;
ref[varNameAsString] = newValue;
I can't find an equivelant approach that will work in AS2 though. I have tried:
var ref:Object = new [classDefinitionAsString];
ref[varNameAsString] = newValue;
This seems to just create an Object and as the vars that I am trying to access are static I don't really want to be using 'new' I just want to reference the vars.
View 1 Replies
Similar Posts:
Jan 27, 2010
If I only instantiate a class once should I make its vars static? I understand how this is of benefit if I make multiple classes, clearly you use less memory as it creates a reference to the same place for each class. Are there any other benefits for creating static vars or functions ?
For example I have my class 'MainMenu' which I create once (might even be my document class). In it I create a
Code:
private var someHolderForStuff:Sprite = new Sprite();
Should I rather create
Code:
private static var someHolderForStuff:Sprite = new Sprite();
View 2 Replies
May 4, 2009
I'm kind off oblivious as to what I'm doing wrong here... I have two classes: - Alley - AlleyCat
[Code]...
View 8 Replies
Nov 30, 2010
I have the following code:
var myPercStr = myStr.text;
myPercStr= myPercStr.toString();
var myPerc = Number(myPercStr);
I am trying to get the value of a text field which is created by the user pushing a pin-pad. This text field is a string which is joined() from an Array of the sequence of pin-pad entries. Now my problem is that Flash will not convert the .text text field into a string with which I can use the value to convert to a Number and perform math on it.
View 1 Replies
Feb 17, 2009
I have a static utility class that must have a reference to the stage, and I'm not sure what is the best option for me to get the stage inside my class...
I've thought of these options:Pass in as a parameter of the function Have a static variable I can set to the stage I don't like either of these because they are ugly.
What methods can you suggest for me to get a reference to the stage in my static class?
View 8 Replies
Jun 8, 2010
I'm trying to make methods available like so:
ActionScript Code:
MyClass.myFunc();
Instead of
ActionScript Code:
var myVar:MyClass = new MyClass();
myVar.myFunc();
I know that to do so I need to declare the functions/variables/constants as static:
ActionScript Code:
package MyPackage {
public class MyClass extends Object {
public static function myFunc():void {
} public function MyClass() {
[Code] .....
When I try to access the static function through the full reference (i.e trace(MyPackage.MyClass.myFunc);), it works, while trace(MyClass.myFunc); returns undefined. This contradicts what I've read in tutorials and posts on the Internet. They all use the short syntax, not the full path.
View 9 Replies
May 3, 2010
What I'm looking for is a way to reference the document class instance, to be able to access functions and variables that other classes need. I'm currently doing it with this little piece of code I found on some blog or forum.
Code: Select all// This is in the document class
private static var _instance:DocClass; // I have tried setting this to public and accessing it directly as well
public static function get instance():DocClass { return _instance; }
[code]....
This seems to work as it should in Flash CS4, but when I try to run the same code in CS5 I get the following error message:
Code: Select allC:UsersImpenDocumentsMy DropboxFlash Project\_SPELTankGameMenuShop.as, Line 238 1195: Attempted access of inaccessible method globalFunction through a reference with static type DocClass.
View 2 Replies
Oct 13, 2009
Error: Access of undefined method getStatus through reference with a static type Class.
Here's what's happening in the code. I'm trying to create a User class that is instantiated at the start of my app. I want the User class to have properties like mainStatus, with helper methods like setStatus etc. Pretty simple.
so on my HardDisk I have my flash_working folder with all my flash projects. I created my class file/package under the directory com.mypackage
[Code]....
That's all the code I have.
If I try to access the public var mainStatus through user.mainStatus that gives a similar error saying:
Error: Access of undefined property mainStatus through reference with a static type Class.
View 2 Replies
Aug 1, 2011
I wrote a singleton class to keep track of some variables across my application.
I am getting a syntax error that I can't figure out, I am sure that I am missing something simple but it's been one of those days. Anyone see something wrong with my code?
The error is 1061: Call to a possibly undefined method setResult through a reference with static type Class.
My function in my singleton class
public function setResult(resultNumber:int, value:int): void
{
switch(resultNumber)
{
[Code].....
View 2 Replies
Jan 7, 2011
button.addEventListener(MouseEvent.CLICK, produce);
function produce(Event:MouseEvent):void
{
[code]......
View 9 Replies
Apr 3, 2012
I have the actionscript code here for a bubble popping game. When the game starts, bubbles fall down from the top of the game to the bottom and score is kept for the most bubbles clicked or popped in 30 seconds.The size of the bubble is defined by the initialize method in the code, and uses ToString() to calculate the score. ToString gives me a 1061: Call to a possibly undefined method Random through a reference with static type uint. This error which I cannot figure out where it comes from.[code]
View 4 Replies
Sep 25, 2010
So I have a movieclip named runman_mc and I'm just trying to make it so when I press the up arrow, his y will decrease. I keep getting an error code 1119 If there's anymore info you need, I'd be more than glad to post it. EDIT: I just had to name the class runman_mc and everything worked
[Code]...
View 0 Replies
Jan 7, 2011
[Code]...
But the same error keeps showing up, related to the var t1 and var t2 lines: Access of possible undefined property text through a reference with static type class What should I do? I already tried removing the String indication, trade : by =,
[Code]...
View 2 Replies
Jan 2, 2010
Error 1061 Call to a possible undefined method addEventListener through reference with static type Class
source:buttonsMenu.addEventListener(Event.ENTER_FRAME, moveMenu);
View 3 Replies
Jul 25, 2010
I'm trying to create a timer event to delay the instantiation of my movie clip on the stage but I keep getting the error: 1119: Access of possibly undefined property Timer through a reference with static type Class I'm confused with how to proceed. I thought Timer was a term already in the AS3 library, so how can it be undefined?
[Code]....
View 1 Replies
Aug 11, 2011
I get the above error. I did actually change a little code because I put it in it's own class.I call the below ShuffleArray class in my main doc class as follows:
ShuffleArray.shuffleKnuth(definitionsArray); [code].....
View 3 Replies
Dec 11, 2010
I've been using Adobe Flash CS4 for a couple of days. I've drawn a worm, with eyes and a mouth and these pieces are all MovieClip symbols. I have exported them to actionscript with the class name being the same as what they are (ie. the mouth MovieClip is exported as mouth). The mouth has 2 frames, one smiling and one frowning. I need to mouth to stay smiling at first, so in Frame 1 actions I wrote:
View 2 Replies
Mar 30, 2011
I see where i was going wrong however when i change the instance name like you said i 1120: Access of undefined property snakePart. all of this code btw is at document class level and the movieclips are in the library not on stage
View 3 Replies
Aug 21, 2011
i am making an edutainment game using flash cs5, im really new at using flash, in fact we never yet tackle it at school, but i insist on learning about it.it my codes, i encountered this error
C:UsersacerDesktopJikanLibraryMain.as, Line 16 1119: Access of possibly undefined property Click through a reference with static type Class.
this is the code i used in my program
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;[code].....
since im really new at flash, i really dont know what went wrong with my codes, it was working a while ago before i put the mouse event.
View 1 Replies
Aug 2, 2009
I can not get the Preloader.PreloaderBar.scaleX=loaded; to work. I get the error 1119: Access of possibly undefined property PreloaderBar through a reference with static type Class.
package BowerPower.Startup{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
public class Initialize extends MovieClip {
[Code]...
View 1 Replies
Jul 13, 2010
I got this Error : 1061: Call to a possibly undefined method addChild through a reference with static type Class.
what I'm trying to do :I have create a new class called Graph and make it extends Sprite and add a scroolpane to my stage and make an empty movie clip called content_mc and make the source of the scrollpane equals to content_mc
in the first frame i wrote this code
import Graph;
var graph:Graph = new Graph();content_mc.addChild(graph);
View 4 Replies
May 12, 2009
I have two custom classes in the same package - sGallery and vChange - within sGallery how can I call a function thats inside vChange?
[Code]...
but gave me error: 1119: Access of possibly undefined property doWork through a reference with static type Class.
[Code]...
View 15 Replies
Jun 29, 2009
I have a site with ScrollPanes, that are calling a Class on what to display. (so the movieclip that I want displayed in the ScrollPane has a Class name.) Within that movieclip (webScroll) that is being displayed in the scrollpane, I have 2 other movieclips (web1 & web2), with unique instance names and eventlisteners targeting those instances. when I preview my site, i get this error: 1119: Access of possibly undefined property web2 through a reference with static type Class.
View 1 Replies
May 30, 2009
I'm trying to make a flash animation but I'm getting these two errors: 1119: Access of possibly undefined property enabled through a reference with static type Class. (line 4) 1061: Call to a possibly undefined method addEventListener through a reference with static type Class. (line 5) This is the code I'm using:
Code: Select allimport flash.display.*;
import flash.events.*;
stop();
buti.enabled;
buti.addEventListener(MouseEvent.CLICK,pla);
function pla(e:MouseEvent):void {
gotoAndPlay(2);
}
My animation is a initial photo that turns around and becomes a black backgroud (were I'll add some text), now what I want is that the photo won't animate until I do a click in it. I used a Layer with a transparent image and converted it to a button and the export name is buti. The other to layers were converted to movie clips named preto and foto.
View 10 Replies
Aug 25, 2009
Let's say you have the following situation:
1. Static var(an Array) stored in a class.
2. You create a variable reference to the static class in a separate class.
3. Splice some items from the reference variable in the separate class.
4. Trace the static class and the items have been removed from that too.
5. Verify several times.
6. Get confused.
7. Post on Kirupa.
View 3 Replies
Jun 14, 2010
I have a custom class called RichButton. It throws a custom event, featuring the line
[Code]....
so far so simple right? But now i get the 1119 error Access of undefined property BUTTON_CLICKED though a refernece with static type Class. Here's the odd part- I can use the class as normal, and access any of its public methods/properties. If i move the RichButton.as from my shared code folder into my project folder (alonside my swf and flashDevelop project files) it works fine. I have exactly the same (as fr as i can tell) structure running in another project and it works perfectly. I've tried cutting and pasting across and trying to find what i;ve done differently but no luck.
View 4 Replies
Jan 16, 2012
I have downloaded Box2d ([URL]) and created a project that looks like this: [URL]. catalyst is the green cube and it has the base class "shapes.box", it is inside "world" which has the base class "wck.World". What i want to do is to add another "catalyst" from the library inside "world" when i click on add_btn. I tried to accomplish this by this code:
[Code]...
Symbol 'buttons', Layer 'Actions', Frame 1, Line 41061: Call to a possibly undefined method addChild through a reference with static type Class.
View 9 Replies
Sep 12, 2011
I am using AS 3 Flash CS4, WIndows XP SP3. I am unable to use the Mouse.hide(); method in many of my scripts. If I add Mouse.hide() to a preexisting script, I get the following error; line1 1061: Call to a possibly undefined method hide through a reference with static type Class. If I add Mouse.hide():void; to a preexisting script, I get the following error: line1 Label must be a simple identifier Once this has happened, if I then remove ALL lines of script from the file...but leave the Mouse.hide(); [or Mouse.hide():void;], and also remove all objects from the stage, when I run the file, I still get those same errors.
[CODE]...
View 3 Replies
May 20, 2011
I'm trying to loop a f4v but I keep getting an error. I have imported a f4v into my library and I now have a FLVPlayback in my library. I have added this to the stage and named it "video_test". I have added the below actionscript to my timeline:
[Code]...
View 3 Replies
Jan 24, 2011
I have written a code that shows no errors when checked however I get an error when the movie is tested: message:
[Code]...
View 2 Replies