ActionScript 3.0 :: Variables Outside Of A Function?

Jan 14, 2010

I need to be able to use a function to change a variable outside of it, and it seems like global scope and the like went out with 2.0 and I need to use 3.0.I would just have the function return a value, but I'm using an 'addEventListener' which has the event and then the function inside.

Example:

Code:
var finished = false;
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
function done(evt:Event) {

[code]....

How can variables be changed through a function when you can't set the scope or return a value through it?

View 8 Replies


Similar Posts:


ActionScript 3.0 :: Getting Variables Out Of A Function?

Apr 5, 2011

i have got a php file (exemple.php) that give a data call MyDataPhp (ex : echo "MyDataPhp=something";)

In my actionscript i try to retrieve MyData with URLLoader with this script

var request:URLRequest = new URLRequest("example.php");
// Build the varLoader variablevar varLoader:URLLoader = new URLLoader();varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;varLoader.addEventListener(Event.COMPLETE,

[Code].....

View 1 Replies

ActionScript 3.0 :: Accessing Variables From Outside A Function

Jul 25, 2011

[Code]....

I want to use the variable var_page3_title for dynamic text boxes in movie clips further on down the timeline. Of course I don't want to repeat this code for every textbox so my question is, how to I access the variables from the function loading();

View 2 Replies

ActionScript 3.0 :: Using Variables In A Button Function?

Dec 26, 2008

I am new to AS3 and building a simple flash banner. There will be four movie clips consisting of just one word each (in the sample below I'm just using rectangle for now). When moused over each word will show a rectangle with a message in it, like a large tool tip. I have a rudimentary version working fine, see code below.

Question 1: Is there a way to just write on function which will work with all four buttons changing the message, say using variables like AS2?

Question 2: Does the code below look relatively efficient? I'm sure there are better ways to write it.Here's a link to the rudimentary version, http:[url]....

View 2 Replies

ActionScript 3.0 :: Pass Variables In A Function From Swf To Swf?

Sep 26, 2008

How do i pass variables in a function from swf to another swf?

View 4 Replies

ActionScript 3.0 :: Accessing Variables Outside Function

Jun 23, 2010

I need to access the contents of a variable that is filled inside a function, but is declared outside the function.. [URL] says that if you declare the variable outside of the function the variable should be accessible even when its content is filled by a function. I have declared the imgs variable at the start, outside the function, as an array. After that the function retrieves a string from the URLLoader and splits that string into to the imgs array/variable.

[Code]....

View 2 Replies

ActionScript 2.0 :: Passing Variables Through A Function

Aug 5, 2010

Hello, I'm trying to minimize code, so I am trying to use functions, and need to pass some strings through them in order for it to work.I believe I may be doing this incorrectly, so could someone please take a look and tell me what I'm doing wrong? On one of my movieclips:

[code]...

What that previous code should do is loop through all movieclips in the game and if it's not named player, move it in accordance to what "Direction" is.If the player is pressing the arrow down key, it will change "Direction" to "DOWN" and hopefully pass it.

View 4 Replies

ActionScript 3.0 :: Accessing Variables From Outside A Function?

Jul 25, 2011

I have this code on the main timeline:
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, loading);

[Code].....

I want to use the variable var_page3_title for dynamic text boxes in movie clips further on down the timeline. Of course I don't want to repeat this code for every textbox so my question is, how to I access the variables from the function loading();

View 5 Replies

ActionScript 2.0 :: Using Switch Function For Two Variables

Sep 6, 2011

How one would go about switching 2 variables around. For example if I have
Code:
a = 5; b = 3;
Then use the switch function and get:
Code:
a = 3; b = 5;
Is there any such thing?

View 4 Replies

ActionScript 2.0 :: Define Variables In A Function?

Apr 19, 2005

Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this [code]...

View 1 Replies

ActionScript 2.0 :: Declare Variables Only ONCE In Function?

Apr 10, 2007

I have a problem with functions and variables.. how to get functions that i use every onEnterFrame. et c: A MC is using this:

[Code]...

As you can see it gets new variables onEnterFrame... How do i get around this?

View 11 Replies

ActionScript 2.0 :: Getting Variables Value From Inside Function

Sep 20, 2003

I'm pretty new to AS, I understand that whatever variables you have inside a function will be discarded once the function finishes? I need the value of a variable that's inside a function, I've tried declaring it outside the function, and also give it an initial value, but it seems that when the function finishes the variable goes back to it's original value.

View 5 Replies

ActionScript 3.0 :: Can Variables Be Used As Function Argument

Dec 31, 2010

I have an extended MovieClip class that has 10 Boolean properties. There are 6 instances of the clip on the stage. Any of the properties of each instance can be set independent of the same property in other instances, so...

[Code]...

View 2 Replies

ActionScript 3.0 :: Set Function That Will Work For ALL Variables

May 5, 2011

By chance does anyone know if there is a way to make a set function for my class that will run regardless of what variable is being set? like if someone does..anInstanceOfMyClass.anyVariable="whatever";it will always run function X.I want my code to have a function that runs every time someone tries to set the value of a variable in my class, or create a new variable that does not even exist yet in the class.

View 8 Replies

ActionScript 2.0 :: Defining Variables In A Function?

Apr 19, 2005

Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this code:

Code:
//define the function
function attachVid(nc, ns, curVid, vidFile) {

[Code].....

I am trying to make the net Connection and net Stream object unique each time the function is called because I am trying to play like 5 flv's on stage simultaneously. As far as I know, each video stream needs a unique net Connection and a unique net Stream object. But it doesn't seem to be working.

View 1 Replies

ActionScript 2.0 :: Properly Reset Variables In Function?

Jul 16, 2010

I have 3 input fields, min:sec:frame (mval,sval,fval)

when it is triggered, it works fine the first time. I clear out the variables in the script below but it doesnt work properly. It comes back as not a number (NaN)

here is my function:

[Code].....

View 4 Replies

ActionScript 3.0 :: Setting Variables For Timer Function

Jan 1, 2011

I'm making an animation of calculating a projectile motion with air resistance based on Python code from [URL]. I include the relevant portions of codes as follow. I'm not familiar of the vector object in AS3 so I translate them into variables as follow:

Actionscript Code:
//timer related variablesvar
fps:uint = stage.frameRate;var interval:Number = 1/fps;
var myTimerYes:Timer = new Timer(1000/fps);
//air resistance timermyTimerYes.addEventListener(TimerEvent.TIMER, startSimYes);
function startSimYes(e:TimerEvent):void{
[Code] .....

The timer activates when the user clicks the start button. The start buttons set the variables for the timer function. The variables are created at the start of the actionscript file. The code of the start button is:

Actionscript Code:
start_btn.addEventListener(MouseEvent.CLICK, goTimer);
function goTimer(e:MouseEvent):void{m = int(airText_mc.mass_txt.text);
A = int(airText_mc.refA_txt.text);
Cd = int(airText_mc.Cd_txt.text);
rho = int(airText_mc.density_txt.text);
[Code] .....

The result I get is the aX = 0 all the time, even after the update I specified in the timer codes. I can't understand what's wrong with the code, it's supposed to be updating every time the timer goes on.

View 1 Replies

ActionScript 1/2 :: Xml.onLoad Variables Undefined Outside Function?

Aug 25, 2009

I've been searching this problem for a while and have tried a number of solutions found on google but nothing has worked so far. I'm sure this is a common problem, but due to my lack of flash knowledge I can't logically work through it as I'm used to windows form development, it makes sense to me that the function could access the variables I have defined but they dissapear after the .onLoad event. Does anyone know the common solution to this problem? I want to be able to pass the xml details into the local variables so I can pass on the details into a dynamic text field when movies are hovered over etc

var myXML:XML = new XML();
myXML.ignoreWhite=true;
var nav1Text:String;

[code].....

View 3 Replies

ActionScript 1/2 :: Function With Two Variables To Load SWF File

Jan 11, 2010

I'm working on a function that checks for 2 things to pull up the correct .swf file. I have to check for 2 things
·_global.theYear
·_global.theDate

Is there a different way I could write this function to say something like:
checkAll(_global.theYear, _global.theDate) = function(){
loadMovie(_global.theYear,_global.theDate".swf", 1);
}

So when a button is pressed, it runs the function above and fills in the variable. Names in the .swf name, does that make any sense, am I on the right track? Because all the .swf file names are all consistent such as 2009_18.swf, 2007_5.swf., etc. The only problem I see is there are 2 sets of buttons, one when you press it sets the _global.theYear variable and the other sets the _global.theDate variable.

So would one button look like this:
mybtn.onPress=function(){
checkAll(2008,_global.theDate);
}
And the _global.theDate would be set with what the current var is set at as?

View 17 Replies

ActionScript 3.0 :: Declaring Variables Inside Function And Use Outside?

Feb 25, 2010

I know that as long as a I declare variables inside a function I can only call them as long as the scope of the function is active. Outside of that function the variables don't exist. Is there any way I can create those variables inside a function and use them outside of it?

View 1 Replies

ActionScript 3.0 :: Return Multiple Variables From A Function?

Jul 21, 2011

As seen below, I tried to return more then one variable from a function but , I think I have some syntax problem..
 
function hesapla3(parametre1,parametre2):(Number&&Boolean) // PROBLEM IS HERE, I NEED TWO VARIABLES TO RETURN{var yenideger2:Number=new Number();var bol2:Boolean=new Boolean();yenideger2=parametre1+parametre2;if(yenideger2>80){bol2=false;}return yenideger2;return bol2;trace(yenideger2);trace(bol2);}

View 3 Replies

Actionscript 3 :: Function Running Before Variables Are Defined?

Jun 15, 2010

I am trying to add an init() function to a MovieClip, but when I run the function from scene1 the variables that were set in the MovieClip are not defined yet... The MovieClip was dragged to the stage from the library.scene1:

mc.init(null);
MovieClip:
var _default = 5;

[code].....

View 1 Replies

AS3 :: Flash - Passing Variables To A Function Not Working?

Oct 8, 2011

I had written this code out using Adobe CS3 and have recently upgraded to CS5. I haven't touched this site in forever and the last time that I did it worked great. The problem is as follows.type of page: galleryproblem: passing variablesthis is the original code that worked last time I checked it but has since stopped working.

function onClick(e:MouseEvent):void
{
trace(e.currentTarget.name);

[code].....

View 3 Replies

ActionScript 2.0 :: Creating Global Variables In A Function?

Jul 15, 2009

I have a function in which I declare a bunch of variables that I need to be globally accessible from outside the function.[code]I need numVals to be accessible from outside the function.I tried changing the name to _global.numVals and it didn't work

View 4 Replies

ActionScript 3.0 :: Accessing Variables Defined In A Function?

Aug 10, 2009

I have been playing around with combining flash and PHP/Mysql for some time now, mainly sending one flash variable to a PHP file and then retrieving a result and turning it back into a different flash variable. My problem is i've got to the stage where I need to access these variables from other functions. Now I think I need to find some way of defining them outside of the function, maybe using global vars? Well i'm not gonna pretend I know anything about it. The two functions from which I access my PHP variables is as follows:

ActionScript Code:
function btnDown(event:MouseEvent):void {
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("http://localhost/test.php");

[Code]....

So I need a way to access the phpVar1 variable in a totally seperate function

View 6 Replies

ActionScript 2.0 :: Print Function, Clearing Variables?

Oct 2, 2009

I'm using this code

Code:
on (click) {
var x = 1;
print(x,"bmovie");
}

To print out the current page as displayed on the screen. The command works great, but when the button is pressed all of my variables seem to be reset, along with various combo boxes.The print function works as intended except clearing all my values .Is there a way around this?

Edit: I just ran a small test on a blank .fla with 3 buttons 1 - set variable = 1, 2 - trace variable, 3 - my print code

This does not clear the variables like it does in my application.What exactly goes on during the print function? If I can isolate and trace the problem, I could find a fix for it, but I have no idea whats going on.

View 1 Replies

ActionScript 3.0 :: Call Function Based On Variables?

Nov 4, 2009

ActionScript [code]...

how to make it run a function based on var's value?[code]...

View 1 Replies

ActionScript 3.0 :: Accessing Variables From A For Loop In A Function?

Dec 30, 2009

Is there a way to make the variables generated from a for loop within a function accessible to other functions? because at the moment other functions are firing errors because the variables refferenced are from a different function.

You may of seen this code from other threads

ActionScript Code:
function nodePoints():void {   
//VarName,     mcName,          XPos, YPos
var row1:Array = ["clientComp", new clientComp(), 100, 200];

[Code]....

View 5 Replies

ActionScript 3.0 :: Mouse Event Function Variables

Jul 7, 2010

I have a mouse event listener that calls a function...how do I parse variables through the function? [code]

View 9 Replies

Actionscript 2.0 :: Properly Reset Variables In This Function?

Jul 16, 2010

I have 3 input fields, min:sec:frame (mval,sval,fval) when it is triggered, it works fine the first time. I clear out the variables in the script below but it doesnt work properly. It comes back as not a number (NaN)

here is my function:

Code: Select allgotoFrame.onRelease = function()
{
if (mval == null)
{

[code]....

View 1 Replies







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