ActionScript 3.0 :: Keeping A Static Variable Within A Loop?

Feb 7, 2011

I need to keep my "grid" + [o] value from 1-9 but add to the to the gridArray number (hence currentNo) within this double loop.

[Code].....

View 10 Replies


Similar Posts:


ActionScript 3.0 :: Create A Scrolling Background Whilst Keeping The Car Static In The Centre Of The Screen?

Aug 17, 2011

Ok i have been looking at a racing game and have used the tutorial from this link here:[URL]...What i am having trouble with is trying to create a scrolling background whilst keeping the car static in the centre of the screen. Ane example of what im trying to do is here:[URL]...So i have tried incorporating the code from that scrolling background example, into the car racing game itself but i am having trouble doing so. Is there any way that the code used from the scrolling background can be input into the racing game example to create this scrolling background effect?

View 1 Replies

ActionScript 2.0 :: Keeping The Data Parameter Of The Object Created With A While Loop

Mar 7, 2004

i've been struggling with the following:

i am creating a list of buttons with an attachMovie. the AS is :

//as
var i = -1;
while(++i<userlist.length){
var user = userlist[i];

[Code].....

okay the problem is this: then i assign an on click function to every button right in the while loop that uses the data parameter of the "ob" object and when i play the movie the data parameter is always the parameter of the last object created for all the buttons. I know why this is happening- it overWrites the old "ob" with the new with every itteration of the loop.

But how would i go differently about creating an individual "ob" for each button created and still be able to have a function with a data parameter like this.onRelease.userClicked(data)?

View 9 Replies

ActionScript 3.0 :: Make Application Variable Or Static Variable?

Oct 16, 2010

The Idea is i want to make avariable that stores his value after i close the swf and open ti again,

an example:

i make acounter

var i:int = 0;
var timer:Timer = new Timer(1000);
timer.start();

[Code]....

the value of i will increase but after i close the application and open it again the value will return to 0 , keep the variable stores his value after closing the application ?

View 3 Replies

ActionScript 3.0 :: Button Class Instantiation Keeping Old Variable?

Jun 21, 2010

I am trying to create a Button class in Actionscript that contains a URL variable. The URL for both buttons is changing to the URL parameter of its latest instantiation. So in this case, both buttons trace This is my Button class:

ActionScript Code:
public class NavButton extends MovieClip {
private static var URL_str:String;

[code].....

View 1 Replies

IDE :: Keeping A Variable Unique For A Dynamically Created Function?

May 23, 2009

What I'm trying to do is setup a function that shoots through a set of buttons within a subset and creates click code for these buttons.

THe three variables are the identifiers for the actual keyframe i wish to jump to, the movieclip in which i want to perform the action and the actual button to go to the right frame.

Presently the problem I'm having is that the variables aren't stored when the onRelease functions are created, so they all are just calling the LAST variables declared.

Here's a sample of the code I currently have

Code:
//function to load canvas/acrylic
function setSwatches(mySwatchCount:Number, myContainer:String)
{

[Code].....

View 1 Replies

ActionScript 3.0 :: What Is Static Variable

Apr 13, 2011

What is static variable. what is difference between  static variable and public variable?

View 2 Replies

Actionscript 3 :: Declaring Variable In Loop Or Before Loop?

Nov 9, 2010

Should I declare the _mcContainer var before the loop or no? (performance increase?)

for(var i:uint = _startIndex; i <= _endIndex; ++i){
var _mcContainer:MovieClip = _mcParent["i_" + _position];
}

[Code]....

View 1 Replies

ActionScript 2.0 :: Pass The X Variable From One Loop To Within Another Loop?

Mar 2, 2007

I have some code that seems to have a problem. I can't seem to pass the x variable from one loop to within another loop.

Code:
var myLv = new LoadVars();
var myNv = new LoadVars();[code]....

View 2 Replies

Actionscript 3 :: Variable That Refers To A Static Class?

Nov 10, 2011

How can I replace

public function Mainclass()
{
Calculations.getDistance(5,9,4,2);
}

[Code]....

I'm not lazy (lying? :p), but I use the class more than 20 times, and it looks better if I replace al these long classnames.

View 1 Replies

Flash :: Static Variable Showing As Null

Feb 13, 2012

I have a class named Locator that I use to GeoLocate a user. There's a static method in that class called "locate()". This method then calls another method which sets a static variable called "loc" to an instance of a LngLat class.The issue I'm having is, when I call the locate method at Frame 1 on the scene, and then try to access the loc variable it shows as null... but when I trace the loc variable after it's set in the Locator class it shows as an object.[code]and then trace the variable at the end of the static method in the Locator class it shows as a object and the city is traced as expected.

View 1 Replies

ActionScript 3.0 :: Using A String To Call A STATIC Variable?

Sep 26, 2010

It is possible to call variables using this[ "stringname" ] for instance, to refer to a variable called "stringname".

However, when referencing a static variable by the name "stringname", the "this" attribute no longer works if applied.

Is it possible to use this technique with statics?

View 5 Replies

ActionScript 2.0 :: Current Time As Static Variable?

Oct 7, 2008

I've been trying to create a script that pulls the current time and turns it into a variable, the problem is the variable keeps updating as the time changes, where as I need it to remain static as the time that is was when the variable was first created...it's just a simple:

Code:

var theTime = today.getTime();

View 2 Replies

ActionScript 3.0 :: Accessing A Static XML Variable From Within A Switch Statement

Jun 1, 2009

In the following class

Code:
package
{
public class Factory
{

[Code]]....

A break point on the "Okay" line shows that x1 is null but x2 is equal to "<entity id="DRONE" points="100"/>".

If I take the whole block out of the switch statement, both x1 and x2 are equal to the expected xml.

View 6 Replies

Flash :: Access Of Undefined Property (Static Variable)?

Jul 12, 2011

I'm trying to change a static variable in the class's constructor. At the start I have:

public static var mainReference:Main;
public static var timerReference:Timer;
public var timer:Timer = new Timer(1000);

This is so my static functions can access main and timer. At Main's constructor I have:

mainReference = this;
timerReference = timer;

The problem is, the first gives no error when I compile it, but the second tells me Access of undefined property (timerReference).

View 1 Replies

Flash :: Dynamic Variable Names In Static Function?

Dec 14, 2011

Is there any way that you can have dynamic variables inside of a static function considering that you can't use "this" inside a dynamic function.

What I am trying to do:

public static function convertToDynamicString(pString:String):String
{
if(pString == "" || pString == null) return "";

[Code]....

View 3 Replies

ActionScript 3.0 :: Using Static Variable To Create External Classes?

Feb 25, 2011

I've rarely used static variables or methods when creating external classes, but I have on occasion, and it's very useful when I need global access to a value. I've seen negative criticism on the use of the "static" keyword, but never understood why. Is there a right and wrong way of using it, or is this not true? I'd like to use it in a context similar to classes such as MouseEvent or TextFieldAutoSize, where there is a list of values globally accessible for identification purposes.

It allows better code readability, and also allows for easy customization in the future. The value of TextFieldAutoSize.NONE is "none", but as long as a programmer used the reference TextFieldAutoSize.NONE and not the string literal "none", Adobe could change the value of TextFieldAutoSize.NONE to be "hahahahaha" and everything would still work just dandy because (TextFieldAutoSize.NONE == TextFieldAutoSize.NONE) is still true even though ("none" == "hahahahaha") is not.

Is there any kind of negative impact on using static variables this way? Or even functions for that matter? I'd just like to clarify this before I go and build a large project around the idea this is perfectly okay.

View 0 Replies

Professional :: Access Timeline Variable From Static Class / Singleton?

Nov 3, 2010

How can I access a timeline variable from a static class / singleton?

View 14 Replies

Actionscript 3 :: Why Is Static Class Member Variable Not The Same When Accessed From Different Parts Of App

Apr 5, 2010

I have an actionscript class with a static member variable defined.

public class A
{
public static var x:int;
}

When I try to access it from different parts in my code I don't get the same value in each spot.

A.x

I am accessing the variable in different modules that are loaded, so they are all in their own separate .swf file.

View 1 Replies

ActionScript 3 :: Cashier Game - Matching Updated Variable With Static One

Oct 28, 2011

I am attempting to create cash register simulation game and am running into a problem with a conditional statement that I am using to check whether the correct change is being provided to the customer and if a button is being pressed or not. In this game, the user can see the amount of the sale as well as the amount the customer pays. With this information they have to click on the cash drawer slots which will increase a variable called changeCount by the value of the monetary unit they have selected.

I am using an if statement to take them to the next frame if the changeCount = payment-sale and the confirm button has been pressed. To check for the button I am using a boolean to see if it is being pressed or not. For some reason, it is not registering the updated value of the changeCount for the if statement to work. If I trace the value with trace(changeCount); it will return the value I want.

The source code is pasted below:
package {
public class CashierMain extends MovieClip {
private var confirmBtn:ConfirmButton;
private var pennyBtn:PennyButton;
private var dimeBtn:DimeButton;
[Code] .....

View 1 Replies

ActionScript 3.0 :: Error - Null Object Reference When Creating A Static Variable

Feb 5, 2010

Basically I have 2 classes, A and B. B derives from A. Inside A, I declare a static variable/constant to the class of B. When I run the program, I get a null object reference error, with the line pointing to the class declaration of B, i.e.

Code:
public class B extends A

For reference, these are the 2 classes:

Code:
package
{
public class A
{

[code]...

Also, this error only occurs when the variable is static. If it's just a normal variable it works fine, i.e.

Code:
private var OTHER:Class = B;

If I change the static variable to point to a different class, it's also fine, i.e.

Code:
private static var OTHER:Class = Main;

I can probably work around this, but it's a bit of a pain in the ass. Anybody know what's causing it, or is this a Flash bug?

View 5 Replies

Actionscript 3 :: Unexpected Variable Assignment Inside Static Class Method

Feb 23, 2012

In the following code (thoroughly debugged) the first case (1) in the switch is met and a new instance of BannerSingle is assigned to retVal (the return value). Unfortunately, while the second case (2) is never met, the assignment therein to retVal takes place and I can't compile. When I comment out the assignment to retVal for "case 2:" everything works fine.

I've tried using an if/else instead and I still get the same odd behavior. Also tried a number of solutions involving separate variables, etc.

package fl {
import fl.IBanner;
import fl.Banner;

[Code].....

View 1 Replies

ActionScript 3.0 :: Static Variable Of Class Gets Reset When Depth Of Caller Is Increased

Jul 22, 2010

I have 3 swfs, and let's label them MovieA, MovieB, and MovieC. MovieB is a child of MovieA, and MovieC is a child of MovieB. So the hierarchy goes like this: MovieA -> MovieB -> MovieC. Each of these movies have their own document class, so they are each essentially a class extending MovieClip.

Now I have this other external class which contains only static variables. Let's call this class "TestClass" and let's say one of its static variables is called "testVar". So in MovieB's document class, I imported TestClass and set testVar = "hello world". In MovieC's document class, I imported TestClass and traced TestClass.testVar. When I publish and run MovieB, testVar is successfully traced as "hello world". Now when I publish and run MovieA, testVar is traced as undefined.

View 10 Replies

ActionScript 3.0 :: Static Variable - Access Buffer Array From The Particlecontainer Class

Dec 19, 2010

I'm currently working on a particle system for a game that I recently started development on, but I've hit a snag: I have a class particlecontainer that tells each particle what to do on enterframe, and which contains each particle as a child. I also have a class (mischandler) which has a static array that contains all current particles, as well as another static array that is a buffer to remove particles from the particlecontainer. Whenever a particle "dies", it calls a function which adds it to the buffer array in mischandler. However, when I try to access this buffer array from the particlecontainer class it does not recognize it as having any elements. If this is unclear here's a simpler explanation:

particlecontainer tells a particle to do it's enterframe function particle calls die() and adds itself to the removebuffer inside mischandler particle container tries to access mischandler.removebuffer but removebuffer has no elements Strangely, the particle can access the removebuffer perfectly fine and sees all the elements in it.

View 1 Replies

ActionScript 3.0 :: Loop A F4v Error "1119: Access Of Possibly Undefined Property COMPLETE Through A Reference With Static Type Class"

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

ActionScript 3.0 :: Private Static Properties With Public Static Getters/setters

Oct 22, 2009

how bad is this practice? I am having trouble getting to some stuff so i am taking the easy way out

Code:
private static var _interrupted:Boolean;
public static function setInterrupted(value:Boolean):void{
_interrupted = value;
}

View 1 Replies

Flex :: Event Metadata: Using Static Variable For "name" Attribute?

Jun 24, 2011

I want to use the Event metadata tags to show what types of event my control will dispatch. The syntax looks like:

<fx:Metadata>
[Event(name="eventName", type="MyEvent")]
</fx:Metadata>

It seems like a best practice in Flex/Actionscript to define static variables that define event names like so:

public class MyEvent extends Event
{
public static const EVENT_NAME:String = "eventName";
// Other stuff..
}

It's a great practice since the event name can change easily and not have to be modified throughout the code. So my question is: Is there any way to use this static const in my metadata event tag? I can't seem to do something like this:

<fx:Metadata>
[Event(name="{MyEvent.EVENT_NAME}", type="MyEvent")]
</fx:Metadata>

Am I just ignorant of the proper syntax to do this, or is it impossible? Seems like it's just asking for hard to find bugs if someone decides to change the const since it is not strongly typed here.

View 2 Replies

ActionScript 3.0 :: Accessing A Class's Static Functions From A Variable Of Type Class?

Feb 19, 2010

I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it

Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function

[code].....

View 6 Replies

ActionScript 3.0 :: Altering A Reference To A Static Var Alters The Static Var Itself?

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

ActionScript 3.0 :: Static Function Can't Find Non-static Functions

Jan 6, 2010

Ok, so I have a bit of a mess here (Which I'm probably not doing right anyway, which could be my problem...). I have a document class, I'll call it as Body.as, that creates an object from another class known as Headgear.as. There are also other objects created from other classes, or will be in the future. Now, amoung all this, Headgear.as and all of the other classes Body.as will use to make objects require the use of dragging functions (starting and stopping dragging). On stopping drags, position checks are then made to compare a particular hidden movieclip with the dragged MC.

To try and save myself some hassle (from making the same functions over and over to ensuring that when the objects are created I don't need to send a complete crapload of variables just to ensure the position checking function would work), I had the functions for the event listeners (Which are set-up on the draggable MCs in Headgear.as) just direct to functions in Body.as

[Code]...

View 6 Replies







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