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


Similar Posts:


ActionScript 2.0 :: Accessing Global Variable In External SWF

Mar 19, 2010

I'm trying to access a global variable in an external swf. I'm loading the external swf like this.
myLoader.loadClip(game, 2);

I'm running a main loop that repeatedly checks certain variables. The variables that are not global I am able to access in the following fashion:
_level2._root.variable;

But I can't seem to access the global variables in the external swf. Things I've tried:
_level2._global.var;
_level2._root.var;
_global._level2.var;
_global.var;

View 7 Replies

ActionScript 2.0 :: Accessing Movieclip Parameters - Set A Global Variable To A New Value When Clicked

Nov 4, 2003

I have a button in a movie that I want to set a global variable to a new value when clicked. I want it to access a parameter of a movie clip that this same button loads onto the movie for the new global variable value. I have the final line under this button's onrelease script with something like this:

globalvariable1 = movieclip.parameter;

Everything is on level 0 and I've tried prefixing everything with _root. but it didn't make a difference, the global variable still wasn't changed. I'm a newbie so don't laugh if this is a really dumb question!

BriCar77
brian_carey77@ou.edu

View 2 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 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

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

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 3.0 :: Accessing Variable Outside Of Its Parent Function?

Sep 30, 2009

ActionScript Code:
function createMaskBox():void {
var maskBox:MovieClip = new MovieClip();
galleryContainer.addChild(maskBox);
}

creates maskBox under the function therefore not accessible form outside of this function from what i understand. Is there a way to create a var WITHIN a function which would exist as if defined outside of it, directly in code?

View 3 Replies

ActionScript 2.0 :: Accessing Variable In Parent Function?

Jan 30, 2008

I'm also relatively new to programming with actionscript, so my code might look quite messy to you Here is my function. It loads the contents of an .xml file and creates a playlist for a video player. Now my problem is that i want to set the "onRelease" function dynamicaly for each playlist item. but inside the onRelease-function i cannot access the variable i. do you have a hint / workaround for me?

[Code]...

View 2 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

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.0 :: Accessing Global Variables In Functions/Methods?

Jun 2, 2011

Which of the following is better in terms of performance/effectiveness?

public var a:int = 0;
public function Addition():void {
a += 5;

[code].....

View 7 Replies

Flash :: Accessing Uza's Global Object From A Loaded External Swf?

Mar 4, 2010

I am using the 1.2 version of Uza's Global singleton (http://www.uza.lt/codex/as3-global-object/). The container swf stores some data and a link to a function in the "global" object.

Then another swf is loaded inside the container, it gets it's global instance with Global.getInstance();, and i suppose i can access the data and function stored in global by the container swf.

This works perfectly on localhost served by a webserver, but when i put the files on my external production server the loaded swf's global appears to not have anything stored by the container.

View 1 Replies

ActionScript 3.0 :: Accessing Stage/global Functions Inside A Class?

Apr 16, 2010

I have a .as file with a load of functions that i include using : include "myFunctions.as".They can be accessed alright.I have a custom class that extends movieclip, and i want to use a function inside that class that is located in my "myFunctions.as" file.How do i do that? Seems like the class loads before the myFunctions.as file so the functions are unavailable at this time. I get that error message :

View 7 Replies

ActionScript 3.0 :: MovieClip Accessing A Variable That Is In A Function Outside Of The Movieclip

Dec 8, 2010

I am trying to access the variable myParentVariable within the function myParentFunction() from the MovieClip's myMovieClip_mc function myMovieClipFunction().
 
I know that It works if I declare the variable myParentVariable outside of the myParentFunction() but I don't really want to do that

main timeline
//-------------------------------------------------------------------- ---
myParentFunction();
function myParentFunction():void

[Code]....

View 1 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

ActionScript 1/2 :: Global Variable Not Targeting?

Jan 8, 2010

I am trying to set up a global variable. On the root of my timeline, I have this;

_global.floorVar = "0";
trace(floorVar);
 
which seems to trace fine to say 0.
 
Then, inside of a movie clip on the main timeline, I have a button function:
 
floor1.onRelease = function() { _global.floorVar = "1"; trace(_global.floorVar) _root.gotoAndStop(2);};
if (_global.floorVar == 1) { trace("it works");
}
 
It traces as 1 once I press the button, but the if statement doesn't trace "it works" is my global variable set up wrong?

View 7 Replies

Actionscript 3 :: Define Global Variable ?

Jan 21, 2011

var frName = fruit_txt.text;

disp_btn.addEventListener(MouseEvent.CLICK, disp_fruit);

function disp_fruit(Event:MouseEvent)[code]....

defining the variable i:e frName.... outside the function it does not display anything..same time if I define same variable inside function i:e disp_fruit...it displays the name ]why?

and how can i use variable i:e frName as global var so that it can be used in any function?

View 2 Replies

Flash :: Have A Global Variable In A Stackview?

Feb 1, 2011

I have a stackview of textfields and when I type into the text field I want it to update on each stackview "page", kind of like a global variable, maybe even using a global variable.

View 1 Replies

ActionScript 2.0 :: LoadVars Global Variable?

Jul 21, 2009

Can I bring in a variable (saved in a text file) using LoadVars and then make that variable accessible from anywhere in the script (i.e. make the variable a global)?

View 1 Replies

ActionScript 3.0 :: How To Make Global Variable

Jan 10, 2010

how do I make a global variable that can be recognized in all frames?

View 1 Replies







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