ActionScript 2.0 :: Can't Access Number Var In Class
Oct 17, 2007
All I want to do is increment a counter every time a movie loads. I have a method (updateMovie) that is passed an MC and the url of the swf to load into it. My loader listener object then triggers another method that should count the number of movies loaded. For some reason I can't access my counter ('loaded').
Here is some of the code from within my class:
[AS]
private var loaded:Number = 0;
//loads passed swf into mc
private function updateMovie(mc:MovieClip, url:String) {
[Code].....
View 2 Replies
Similar Posts:
Nov 14, 2010
I'm building a Flex project with a lot of embedded bitmaps and such. The usual method for getting to the bitmaps in Actionscript seems to be to do something like
[Bindable] [Embed(source = '../lib/WhiteFencePost.png')]
private static var clsObstacleFencePost : Class;
var bitmap : BitmapAsset = new clsObstacleFencePost();
I've already got several dozen of these things, and I can easily see ending up with hundreds of them by the time the project's done. Is there some way that I can avoid creating a Class for every bitmap?
View 2 Replies
Oct 11, 2009
I created the following AS for a particular frame
Code:
cnx.addEventListener(CNXConnection.DIGITAL, onDigital_10);
function onDigital_10(e:DigitalEvent)
{
[code]....
While debugging everything works properly if I'm testing that frame.But, pushing a button in another frame, I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference at "frame number:raw number"
I'm quite sure that the problem is that the variable e.Join changes its corresponding e.Value pushing a particular button in another frame (as must be). Any ideas how to link that information to the frame that create the error?
View 1 Replies
Jan 29, 2012
If I have three classes:
public class Example {
public function Example () {
}[code]............
You can see that the two last classes extend the first one, and both have the 'variable' property. In case that I have an instance of Example and I am sure it is also an ExtendedExample OR AnotherExtendedExample instance, is there some way to access the 'variable' property? Something like
function functionThatReceivesAnExtendedExample (ex:Example):void {
if(some condition that I may need) {
ex.func()
View 3 Replies
Apr 8, 2010
I have a initApp.as which instantiates a class which needs to access the "currentState" property and the States array as well. However we cannot get this to work as we cannot see how we can access this information.
Within initApp.as currentState is accessed via "this.currentState". This does not work in the class which is instatiated within initApp.as. The following error is thrown:
"Access of undefined property currentState."
View 1 Replies
Nov 24, 2011
I have the following inheritance structure:
var environment:AvEnvironment = new AvEnvironment(...);
addChild(environment);
environment.addChild(new Terrain());
environment.addChild(new Player());
I am trying to access a public property from AvEniroments class through the Player class, however I'm getting an undefined property error (#119). I've tried the following:
this.x = AvEnvironment.xs // public property in this class
this.x = parent.xs
I've also tried something like this:
var ev:AvEnvironment = AvEnvironment(parent);
this.x = ev.xs
but I get a TypeError. Error #1009: Cannot access a property or method of a null object reference.
View 1 Replies
Mar 7, 2012
How to access a display object on the stage in a class which is not a document class?
I am looking for a solution that doesn't involve passing the stage as a parameter to the class.
One solution i always come across is using "TopLevel.as". Is it a good method because as far as I have heard using global variables is not recommended because it might cause some problems while working on big projects.
View 1 Replies
Jul 2, 2009
I was wondering how do you access the stage property from a different class that's not the principal class tied to the fla? Essentially, I have main.as which calls another class menu.as, and I can't seem to be able to use the stage.stageWidth property from menu.as. What's the proper way to be able to use the stage property from any class? Do I have to import it separately each time?
View 2 Replies
Aug 17, 2010
I'm just now learning the new object oriented way of scripting. It's been a wild ride, but I've finally learned how to keep script off my frames (very hard coming from as2).Here's my problem:
I have a TextField on the stage in my main .fla file named loadPercent.
I'm loading a jpg with preLoad.as and displaying the bytes loaded in loadPercent.
I can access my loadPercent TextField from my MainClass
but I can't access it from preLoad.as
the document class is MainClass.as
Code:
package
{
import flash.display.MovieClip;[code]....
I get three '#1120 access of undefined propery' errors for each time i try to access loadPercent.
a few basic questions: 1. all my files are in a folder in my documents, not in the flash directory, is this bad? I've seen people using com.whatever etc.
2. my main .fla file does not share the same name as my MainClass.as (it's not named MainClass.fla) Is that a problem?
I'm assuming these are inconsequential because my code seems to work up to a certain point.
View 7 Replies
Mar 3, 2011
Going further on my app, I felt in another problem. Despite having lots of posts on the web regarding this, none of the solutions worked for me In my document class (Main.as) ve two containers. One empty and another with a star that is being imported from the library. Here´s the main class:
package
{
import flash.display.*;
[code]......
View 4 Replies
Mar 3, 2011
My first experience is build an aquarium with a lot of fish swimming, and they can be clicked. When one of them is clicked we should receive a trace message saying ("I�m a Fish!"). To do this, I thought that the best way will be:
1- create a document class, named Main.as
2- create a base class, named Clicked.as
2- create a movie clip with a fish.
3- export the movieclip to actionscript. In the mc properties set Class as "fish" and Base Class as "Clicked".
View 6 Replies
Feb 3, 2010
Say you were importing flash.events.KeyboardEvent and you wanted it to extend the MovieClip class, is this possible? Where you dont have access to the class to just type "extends XXX"
View 14 Replies
Mar 1, 2010
i have a game that i want to put load screen on, which i created a separate class for. first the main class is initialized and in the constructor function, it does an addChild(loadScreen) which places an instance of the loadScreen MC on the stage. within the loadScreen is a "Play Button" that when a user presses this button i want it to continue startGame in the Main class. the way i tried it was Main.startGame from the loadScreen class, but that obviously does not work. is it possible to call a function from a different class.i have three files:
Main.fla
Main.as
loadScreen.as
the Main.as file:
Code:
package
{
import flash.text.*;
import flash.display.*;
[code]....
View 3 Replies
Jan 26, 2010
Is there an event listener that will allow me to access either the frame number or frame label of a playing SWF loaded with the new Loader statement? I need to trigger the play() function of another external SWF, as well as other functions.
View 9 Replies
Sep 13, 2004
This ActionScript is creating reading an XML file, and laying out thumbnail images. I'm stuck though! Each thumbnail is given a value of thumbnail[x], going from 0-5. I wrote some mouse actions and need to access each thumbnail's number, not entire name (where I have it in red below).
[Code]...
View 3 Replies
Dec 24, 2011
I run into this problem today ... take a look on the code :
import com.trick7.effects.TeraFire;
for (var j:uint=0; j<10; j++) {
var fire:TeraFire = new TeraFire();
[code].....
View 6 Replies
Mar 15, 2012
I'm a little new to AS3, but I have a question. I have a variable called "lives". It is a Number. I also have a class. It is called "Enemy". Within the "Enemy" class, there is a function called "collision_detection". How can I change the value of "lives" from "collision_detection"?
I have an Enemy class. I need to communicate from within the class to let the main program know that a collision occurred. How can I send this message to the main program?
[Code]...
View 1 Replies
Oct 28, 2009
I was thinking of making a complex number class but then realized it would be a bit of a pain to have to call functions every time I wanted to perform operations on them. Would there be any way that I could set two complex numbers like so:
Code:
var z:Complex = new Complex(-0.7, 1.4); //where the number is then -0.7 + 1.4i
var c:Complex = new Complex(1, 1.1);
and then store the result in another?
Code:
var x:Complex = z + c;
In other words, is there a way to make the +, -, * and / operators behave in ways other than those they normally would?
View 2 Replies
Jul 8, 2010
I need a way to "extend" or proxy the Number class in ActionScript.Basically I'll overload the toString method of it. But the Numbers should remain comparable with "<" and ">" operators.
View 2 Replies
Oct 12, 2011
Here is my code:
package
{
import flash.display.MovieClip;
public class Derp extends MovieClip
[code]...
What I would like to do somehow assign a number or word variable to display one of the public classes on the screen instead of all of them at once.
View 1 Replies
Jun 22, 2009
test.fla has the document class test.as. This is test.as:
Code: Select all// test.as
package
{
import flash.display.MovieClip;
public class test extends MovieClip
[Code]....
Why is it so? I want to be able to output the value of number through the document class like I showed in the code of test.as above.
View 1 Replies
Jul 30, 2009
i'm having DocmentClass for my FLA..i'm having main movieclip inside that main movieClip i'm having n number of frames..Which is having same name called my_MC.According to the condition i'm giving gotoAndStop(1)or (2) or etc.But my Document class functionality not at all working Except 1st frame..
View 1 Replies
Mar 5, 2011
I know how to pass a value to a class that need to be called, but how to call a class that returns a value?
can someone show me how to call it and how to write the class that returns a number?
View 4 Replies
Oct 14, 2009
I have to admit I pretty much ran away from Flash when AS2 came along and only used it for animation purposes over the last 5 years.So I'm having a major crash course in AS3 in Flash CS3 and I'm not enjoying it one bit. I'm getting maybe 10mins of finished work per hour as I try to figure out the limits and rules of AS3. Quite often it seems that AS3 simply can't do what I want it to. Anyway: Characterchecks.as is the main class and it loads a bunch of XML into four arrays. The file starts like this:[code]If I trace the value of, say, cc._Categories from the main FLA, it's empty. I'm guessing that the next line of AS in the main FLA doesn't wait for the previously called function to complete? (This may tie in to my next problem)My next step is that I want to display various things based on the data in the array. I have another class, Display.as which will hold all the functions to create the items on display. I thought it would be best for these to be a separate object. I wonder if I'm right?
So I declare an instance of Characterchecks in the main FLA and call it cc, and then run the functions to populate the arrays... Now I create an instance of Display and call it cd. How can I get functions in cd to see the values of the variables in cc? And if the main timeline can't tell that the functions aren't finished filling the arrays, how is cd supposed to know?I might be asking dumb questions, or maybe I'm doing things ***-backwards, I don't know. I'd appreciate any help, I really would. This whole thing has me at the end of my tether... being the most technically advanced person in my circle of co-workers and web design friends means I have no-one to explain why things need to be done a certain way or what the best way is.
View 3 Replies
Feb 26, 2009
I have a document class called Main that is defined for my main movie. In the library of that movie there is a MovieClip called HomeBlock for which I have written a custom class called HomeBlock that defines its behavior. This HomeBlock class accepts one parameter in the constructor right now, an XMLDocument, and the Main class sends it to HomeBlock in the constructor call like this [code]...
View 5 Replies
Apr 15, 2010
1) I want to count the number of movieclips(in different class) added. That is, may be I have 10 clicks, how many bigfish and smallfish are created. What function is suitable to call for doing this.
2) I have a problem on the hittest, it comes out "no hit" only but I still can see the movieclips overlap. And if I want to modify that only check whether smallfish is overlap with bigfish, what should I do? Also, there are functions inside the movieclip itself to give motion.[code]
View 1 Replies
Jul 7, 2011
In Java there is a method of the AudioFormat called
getSampleRate
This returns the number of samples per second. I was wondering what the best way to achieve this with the microphone in flash is. I am not sure if I need to add a SamplesDatatEvent and use extract() or ?? I need to know the number of samples per second from the audio coming into the mic.
View 1 Replies
Dec 27, 2011
Can someone point me in the right direction on how to instantiate any class at runtime with any given number of arguments?
As an example and to be more precise, I included an example below. How could I write this example in one line of code - ok, maybe two : )
[Code]...
View 1 Replies
Jul 31, 2009
I am having a strange issue where I have created a MovieClip in the IDE and given it a class name ( MyObject ) and exported for actionscript...this object is created in an external class. This object has a few MovieClip symbols inside, ( MyButton ) and ( MyOtherButton ). After creating a mouse-over event for MyObject and catching the target ( either MyButton or MyOtherButton ), in the listener function, I trace the event.target in hopes that it will output "Object MyButton" or "Object MyOtherButton" but instead, I get "Object MyButton_6" and "Object MyOtherButton_2"...
View 2 Replies
Dec 25, 2005
These two functions are taken out of my as class file, even though the setInterval is never cleared it only calls generateParticles 1 time. Someone please help me figure this out. I have been messing around with it over an hour but still can find why its only called once. emit is a private var Number declared outside the function in the class.
[Code]...
View 3 Replies