ActionScript 3.0 :: Global Variable Not Accessible From Nested Function?

May 13, 2009

i need to assign a value to a global variable from within a nested function, but my code's not working, any clues? this is within a class definition:
 
// begin code
var numGlobalNumber:Number;
outerFunction();

[code]...
 
i want the text within the dynamic text field to be "1" but it comes up "NaN"

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Variable Of Nested MovieClips Global Coordinates

Apr 24, 2009

I have a MovieClip ("mc3" that moves dynamically) inside of a MovieClip ("mc2" that moves dynamically) that is on the stage ("stage" that is static). I need to find the value of mc3's x in relation to the stage? I need to make it into a variable. I am trying to do the math, can't figure it out. Also tried localToGlobal and failed.

View 5 Replies

ActionScript 3.0 :: Global Variable Within Function?

Aug 24, 2009

I'm having an issue with a global variable. I'm trying to give it a value within a function and it isn't working.The variable is imageList. It's an XML List. I'm making it global so I can use it anywhere in my project. I suppose if someone has a better idea to avoid the global variable, I'm up for that too. But for now, it seems like the way to go.
 
Here's my .as file:
package
{
public class MyGlobal
{

[code]....
 
It's giving me the same same Error #1009 as above. It seems like a scope problem, but why? Shouldn't it work since it's a global variable?

View 6 Replies

ActionScript 3.0 :: Modify A Global Variable Within A Function?

Sep 24, 2009

I've currently got this script (see below). What I'm trying to do is make it so I can load several images from a loop. I've played with a few different things, but I'm not completely understanding how the listener works as it relates to the loader. It seems when I try and add a second image, it only enters the onComplete function 1 time, therefor i only get one Image loaded. As a side note, I've also been trying to dynamically change the x and y position, but I'm not sure how to modify a global variable from within that function, or better yet, pass in the arguements during the eventListener call to onComplete.[code].....

View 2 Replies

ActionScript 3.0 :: Accessing A Global Variable In A Function

Jan 9, 2012

I have a global var

[Code]...

The only problem is it can't "see" myGlobals. I was wondering if someone could tell me why it can't see it! I'm sure it has something to do with scope.

View 3 Replies

ActionScript 2.0 :: Passing A Variable To Global Function In Another Mc?

Sep 17, 2009

After having recently just discovered the delights of actionscript, I am at a loss to work this out. I'll explain:I have a series of buttons which, when each one is clicked, need to grab their instance name (this._name), strip the first three characters from it and send it to a global function in another mc within the swf.Instead of stripping the characters, I am happy to do:

if (this._name == dot1) {
dotVar = 1;
} else {

[code].....

View 1 Replies

Flex :: Increment A Global Variable Inside A Function?

Oct 31, 2010

The variable currentIndex is declared globally and initialized with a certain value say '0'. How do I hold the value of currentIndex which is incremented every time the function is called? In the given code, every time the function is called, the value is reinitialized.

function nextSong(e:Event):void
{
sc.stop();

[code]........

View 2 Replies

ActionScript 3.0 :: Create A Global Variable From Inside Function?

Oct 11, 2011

I have a primary function that calls upon other functions, which call upon other functions, etc, each one creating different objects. I need to delete everything eventually and was thinking the easiest way to do this would be to have a global array to push() each object into. It would be easy to just put garbageArray.push(thisCreatedObject); into the for() loops of every function to grab all the objects so a deleteFunction() could just cycle through garbageArray to remove and null everything cleanly.

What I want to do:I could easily just create a global array to do this (code example 1), but I would prefer to be able to recreate this global array and delete it every time this primary function is called (code example 3) since it will be called upon a lot. It would be cleaner code to have it created from within the function as opposed to outside of it because I will have a lot of primary functions doing similar things that would require a global array like this.

I also know I could create one and simply pass it as an argument to every function (code example 2), but I would have to pass it to every single function. There are a lot of functions and a lot of calls to them, so this would require rewriting a lot of code and would be more work than it's worth. Making a global array outside of the function would be easier than doing this if it came down to it.

ActionScript Code:
//example 1 of global array. No passing as argument from
//primary to secondary functions. Multiple global arrays
//required for multiple primary functions in the future.

[code].....

View 6 Replies

ActionScript 2.0 :: Global Variable - Enable / Disable Function Within Game

Oct 23, 2004

I have a button that I would like to enable and disable a function within my game. The button is called "flashBang". I'm thinking this may need to be done with global variables to make the switch do this procedure. How would I go about scripting this variable? Also I want to be able to target this function during gameplay, if this function is enabled do this line of code - _root.gotoAndPlay("flash");

The code needs to fit somewhere in here i guess.
//hitTest top + bottom wall
if (_root.ball.hitTest(_root.topwall) or _root.ball.hitTest(
_root.bottomwall)) {
_root.yspeed = -_root.yspeed;
_root.audio.gotoAndPlay("flash_bang");

View 3 Replies

ActionScript 3.0 :: Sloppy Global Function By Calling Global Function Class

May 14, 2009

I'm try to calling my sloppy global function by calling my global function class as u can see below.[code]

View 2 Replies

Flex :: Incrementing A Global Variable In A Function Which Is Called Multiple Times?

Oct 31, 2010

I am trying to make a simple mp3 player using flash. The songs are loaded using an XML file which contains the song list. The following code is inserted into a new keyframe.

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.*;
import flash.events.MouseEvent;

[code]...

The problem over here is in the nextSong() function. I am unable to preserve the value of currentIndex. Although I am incrementing currentIndex every time the function is called, but the value remains unchanged.

View 1 Replies

ActionScript 2.0 :: Nested Function - Name Of Variable To Call?

Dec 23, 2008

I need a way to call a function from a function. It's not that hard, I know, but the name of the nested function is a variable passed into the first function. Like in setTimer() and other functions in flash, where you have the name of a variable to call. I'm going to have a lot, so doing some cheap if(funcname == blabla){blabla();} won't work.

View 1 Replies

ActionScript 3.0 :: Avoid Nested Function In Order To Access A Local Variable?

Mar 17, 2010

I want to load an XML file and access one node value. I decided to store it in a variable(var addedNumber).

The problem is I want to access this variable in a new function (loadURL)"outside" of the scope. Is there a clearer way to do this instead of using nested function?

PHP Code:

var XMLLoader:URLLoader;
var XMLPath:URLRequest;
var XMLDoc:XMLDocument = new XMLDocument();

[Code].....

View 3 Replies

ActionScript 2.0 :: CS3 Global Variable Not Being Global

Jul 22, 2009

i defined the global variable in the first frame of my file, and i can access it on other frames, however i am trying to access it within a movieclip, and flash is telling me that it is undefined. does anyone know why this could be?

View 1 Replies

ActionScript 2.0 :: FMX-variable Accessible Outside Of Functions?

Aug 6, 2003

I don't know why the value of my variable my_str is undefined outside of this function:

loadText = new loadVars();
loadText.load("data.txt");
loadText.onLoad = function(success) {

[Code]....

ps: I tried making my_str a global function or even defining it as _root.my_str but I always get the same result..it's undefined outside the function...I need that value for something else so...

View 1 Replies

ActionScript 2.0 :: Dragging A Nested MC Around Global Stage?

Jun 1, 2005

I have a simple popup dialog box which exists in a movieclip within the timeline of a loaded movie. I would like to be able to drag this dialog within the bounds of the parent movie (i.e. global stage) and not be confined to the dialogs parent clip and ultimately parent movie.

Within my dialog_mc I have a clip called drag_mc which the user clicks to drag dialog (the specifics are below)

Path:
_root.site_mc.gallery_mc.dialog_mc
Registration point:
top left

[Code]....

View 1 Replies

Flex :: Variable Accessible For All .mxml Files

Oct 4, 2011

Im using Oracle, BlazeDS, Java & Flex. I have an ArrayCollection containing data from a small database table. This table won't be the subject of much change. I want to use this ArrayCollection accross different mxml files to fill e.g. ComboBoxes etc. The reason for asking, is that doing a database call for each time a fill a ComboBox etc is slow and seems unnecessary. I tried doing this once in the "main" .mxml file, but then the variable wasn't accessible where i needed it. What is the best approach for accomplishing this task? What is the best way of making a variable accesible across .mxml files?

View 5 Replies

ActionScript 3.0 :: Make A Variable Accessible In More Than One Frame

Feb 9, 2010

I noticed that I can not find a way to make a variable accessible in more than one frame. My issue here is that for instance if I have a game and frame 1 has the game and frame 2 has the win screen and I want the win screen to display a score, I don't know how to do it. So the variable from frame 1 which holds the display can't be acessed in frame 2. I understand how to use OOP proggramming and classes, but you need an instance of that class to hold the variable, and It seems I can't cross-frame acess objects either. (I understand I could use a global variable, I don't know how to do this but I know most people don't.

View 4 Replies

ActionScript 3.0 :: Nested Movieclip Global Position (with Scale)

May 18, 2010

Let me try my best to explain this... On the stage I have a master movieclip, for explanation purposes, let's call this movieclip "body". Nested inside of body are several other movieclips (we'll call them anatomy items like: arm, hair, foot, etc) Now let's say we scaled body to 200% (body.scaleX = body.scaleY = 2.0)

When I run localToGlobal on one of the nested anatomy movieclips (e.g. arm), actionscript is returning the x and y values of the initial state, not reflecting the scale of body and how it actually caused the arm's position to shift globally.

View 0 Replies

ActionScript 2.0 :: Determining A Nested Movieclip's Global Rotation?

Feb 25, 2007

Is there a simple way of determining a nested movieclip's global rotation?I have several nested movieclips that need to know what their rotation is to the main stage.

View 1 Replies

ActionScript 3.0 :: Root Variable Not Accessible In Child Layers

Dec 2, 2010

I got a variable "VideoFolder" well defined in my root level. However when I used this variable directly in child layers, my script does not recognize it and I get error 1120: Access of undefined property VideoFolder. I tried changing VideoFolder with _root.VideoFolder in all my child layers scripts, but it changes nothing.

View 2 Replies

ActionScript 3.0 :: Flash Variable Or Method Accessible In All The Package?

Feb 18, 2011

I want to be able to have a variable and/or a method that's available to all the classes inside a package. What would be the best way to achieve that?

View 5 Replies

Flex :: External SWF Variable Updates Global Variable In Main Timeline?

Feb 8, 2010

I have 2 movie clips, one being loaded into a container MC via "loadMovie();"In the main movie there is a variable with no value, in the external movie there are 5 frames, each with a value to update the variable in the main movie.

IE: if on frame 1, global value = 1 / if on frame 2, global value = 2 / etc etc I'm familiar with passing variables INTO an external swf, but am stumped on how to do it the reverse way.

View 1 Replies

Actionscript 3 :: Correct Way Of Making Variable Accessible To A Child Class / Object

Mar 4, 2011

When you initialize a new object, how can that class have access to a variable from the parent?In this case Blob needs to be able to access scale?[code]

View 2 Replies

ActionScript 2.0 :: Scope - XML Data To Be Accessible In The Public Function Strip()

Apr 27, 2010

I'm having some big issues with the scoping problems in my XMLConnect Class. I already found some things about the Delegate class online for setting the scope correctly, but my code still doesn't work the way it should Problem I need the XML data to be accesible in the public function Strip() because the user needs to put in some characters to strip from the strings in the xml file. Does someone known how to fix this scoping problems?

[Code]...

View 0 Replies

ActionScript 3.0 :: Is A Global Function The Same As Plublic Function

Dec 9, 2009

I have a bunch of movie clips which I am adding to my stage using addChild, I need each clip to "fade in" when it is added. I made it work for one movie clip using this function on the movie clip itself

Code:
this.alpha = 0;
function imgAlpha(e:Event):void {

[code].....

View 4 Replies

Define Global Variable In FMS?

Mar 1, 2011

how to define global variable in fms so that it can be accesses by different application instance of same application,

View 2 Replies

AS3 :: Xml : Declare A Global Variable?

Feb 28, 2012

I'm trying to get a value from a function which is a URLLoader COMPLETE event but even with declaring variables outside of the function will not allow me to get the value out. I'm stuck.It seems that the Asynchronous nature of Flash makes it impossible to get a value out: e.g. this works:

// Initialise a URLLoader to get XML data from XML file
var myFPBLoader:URLLoader = new URLLoader();
myFPBLoader.load(new URLRequest("flightPlannerBoard.xml"));

[code]...

View 2 Replies

ActionScript 3.0 :: Passing Value To Global Variable

Aug 11, 2009

I have a movieclip on the stage, and in that clip I have a button that is supposed to turn a global variable from true to false, but the compile tells me:
1119: Access of possibly undefined property root through a reference with static type Class.

When I use this code:
Code:
function closeMSN(event:MouseEvent):void{
this.visible = false
Stage.MSNOpen = false
}

I know how to reference the movieclip itself by this, but how do I change the value of a variable on the main stage, from inside the movie clip?

View 3 Replies

ActionScript 3.0 :: Global Variable And Inner Timeline?

Jun 23, 2009

i've declared global variable in the first frame of the main timeline:var cLabel:String;In the inner timeline of a MC, i use this code:stop();cLabel=this.currentLabel;but flash gave me error 1120: access of undefined property

View 6 Replies







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