ActionScript 2.0 :: Passing Variable To Function Inside Function?

Sep 16, 2009

I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).

ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",

[code].....

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Declaring A Variable Inside A Function To Use Outside The Function?

May 5, 2011

I want to create a vector, then call a function that populates that vector with arrays. Fine. The only catch is the function itself will declare new array variables to put into the vector, but are these new array variables private to the function only?e.g. something like this

ActionScript Code:
public var vec:Vector.<Array> = new Vector.<Array>();
private function populateVec():void {

[code]....

Is this "kosher"? a was declared in the private function but added to something outside the function..?

View 4 Replies

ActionScript 3.0 :: Passing A Variable Into A Function?

Mar 19, 2009

I have 3 movieclips in the Libarary, called (both by name and class) section0, section1 and section2.This works for instance to attach a movie clip to the stage:

Code:
var myMovie:MovieClip = new section1;
addChild(myMovie);

[code].....

View 2 Replies

ActionScript 3.0 :: Passing Variable To Function?

Feb 21, 2011

Trying to create a random movement for fish MCs:

//----------------------
var deg2rad:Number = Math.PI / 180;
var speed:Number = 1;// set to speed you want
var numFish:Number = 4;

[Code].....

Problem I have is that they all move to the same angle (the last one created).

How do I pass the different "my_angle" values to the "move_me" function...?

View 7 Replies

ActionScript 3.0 :: Passing Variable From A Function?

May 6, 2009

How do I pass mulitple variables from a function using AS3? Does this have to be done using a Class?
 
example:

var endValue; // variable I want to fill
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, dataLoaded);

[Code].....

View 8 Replies

ActionScript 3.0 :: Passing Variable With Function

Jun 8, 2009

This is a function on the first frame of a .fla updated to AS3 from an old AS2 file:[code]When the function is called it should set "max_messages" to 600 in AS3, right?

View 1 Replies

ActionScript 2.0 :: Passing Variable To Function By Ref?

Feb 23, 2011

If I remember correctly, objects are being passed to functions by reference, so I wrapped my primitive variable into object but did not get the resilt I wanted. I combed this group to see the solution and found only this one:

function changeObjectStatus(obj)
{
return obj.status = true;
}

[Code]....

var v seems to be a new object rather then a reference to the old one. and changing v does not affect the original object.

Does this mean that if I want the function to work with several variables, I need to create a separate object for each variable?

View 2 Replies

ActionScript 2.0 :: Passing A Function Name As A Variable?

Aug 31, 2007

Been looking everywhere to find out if there is a way to do this:

[Code]...

Anyone know Of a way to accomplish this without having to use an if/then statement

View 4 Replies

ActionScript 2.0 :: Passing Variable To A Function?

Jul 28, 2008

I have this script that reads pictures and links of the pictures from the an xml file, display the picture and then put the link for the image, but I can't seem to pass the link to the onRelease function anyone can help me on this, below is the code:


[code]...

View 4 Replies

ActionScript 3.0 :: Passing A Variable To A Function?

Apr 9, 2010

It seems that with as3, the error compiler is just waiting to get you.I have a function that loads in an external swf. Which swf depends on which button they click. So, it could be pic1.swf, pic2.swf, pic3.swf, etc.

function loadMovie(){
my_mc.addChild(my_Loader);
addChild(my_mc);[code].....

When i test, I get "error: access to undefined property myVariable.

View 3 Replies

ActionScript 2.0 :: Passing Instance Name To Function As A Variable?

Apr 24, 2006

k the idea is that this movie keeps tracks of whatever page it's on using the variable current. when the button evolution is clicked it should jump to frame 2 of the movie whose instance name is contained in the variable current and also pass this variable to a function called alpha which fade that movie's instance when moving to another page - then that page's name will be assigned to current.

this is the code that i have now..

#include "alpha.as"
evolution.onRelease = function() {
this[current].gotoAndPlay(2);
this[current].alpha(5, 0);
};

all these buttons and movie instances are contained in the same movie clip and the variable current is declared in it too.

View 1 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 :: Converting Variable Types For Passing In A Function?

Mar 17, 2009

I'm trying to write a robust "eventMaker" function that I can run with arguments that will then create an event listener based on the arguments.

However, I can't seem to get it to pass the arguments. Functions are impossible to pass; it can't convert string versions back to functions, and passing the function as type :function just yields "function() function{}".

The same is true with strings and class definitions - if I want it to refer to an object in my other .AS file called "helloWorld", I can't make it think of helloWorld as anything other than a string or an object, and when I write commands based on it I get errors.

So how do I contain classes, functions, et al in variables that I can then reference again, in code, as those functions/classes? How can I convert a string value to something that the code will know is a reference?

View 3 Replies

Actionscript 3 :: Passing A Variable To A Javascript Function Using ExternalInterface?

Jan 18, 2010

How would I go about passing a variable to a javascript function using ExternalInterface?

View 1 Replies

Actionscript 3 :: Passing Local Variable To Loader Anonymous Handler Function

Oct 22, 2011

Why isn't this working as I am thinking it would:

var i:int=-1;
for each(obj in myData)
{
i++;

[Code]....

If I add i to an array (like myArr.push(i)) it will have 3 elements, 0, 1 and 2.

View 2 Replies

ActionScript 3.0 :: Passing Parameters To Function And Avoiding Duplicate Variable Definitions

Jun 18, 2009

I have shortened this example to keep it simple, otherwise I wouldnt be doint this

I need to pass different variables to function inForLoop each time.

Code:
function someFunction():void {
for (var i:int = 0; i < columns; i++) {
for (var j:int = 0; j < rows; j++) {

[Code]....

View 3 Replies

ActionScript 3.0 :: Execute Callback Functions Dynamically By Passing A Function In As An Argument To Another Function?

Apr 21, 2010

How do I execute callback functions dynamically by passing a function in as an argument to another function?

Look at this example:

Code:
package {
public class myClass extends MovieClip {
public function myClass(callback) {

[code]....

View 2 Replies

ActionScript 3.0 :: Passing A Variable To A Function - Get "error: Access To Undefined Property MyVariable?

Apr 9, 2010

It seems that with as3, the error compiler is just waiting to get you.I have a function that loads in an external swf. Which swf depends on which button they click. So, it could be pic1.swf, pic2.swf, pic3.swf, etc.

function loadMovie(){
my_mc.addChild(my_Loader);
addChild(my_mc);[code].........

When i test, I get "error: access to undefined property myVariable.

View 2 Replies

ActionScript 2.0 :: Load A Variable From The .fla Inside A Function?

Jun 2, 2011

I have some buttons in the scene (inside the .fla) that change a variable "counter" after being clicked. In a separate class there is a function "showPage" that loads a xml-file according to the value of the variable "counter". My problem is, that I dont get the variable "counter" from the fla-file into the function of the .as-class.

Here is my code:

Inside mcMain.as

Code:
class mcMain extends MovieClip
{
//public var counter:Number = 1; //Das hier soll durch den Button getan werden :(

[code]....

View 1 Replies

ActionScript 3.0 :: Getting Variable Value From Inside Of Event Function

Feb 29, 2012

How to get variable value from inside event function. Variable was declared outside event function.
var StringVar="sample";
myButton.addEventListener(MouseEvent.CLICK, myClickReaction);
function myClickReaction (e:MouseEvent):void{
StringVar="other sample";
} trace(StringVar); /*

It gives me "sample" value and I would get "other sample" value */. That strange because if that would be normal function trace would give me good result.
var StringVar="sample";
function myClickReaction():void{
StringVar="other sample";
} myClickReaction();
trace(StringVar); /* it gives me result as I wanted to have - "other sample" value */

I know also method of passing arguments into event fuction but it not works for me as I would like to
var StringVar="sample";
myButton.addEventListener(MouseEvent.CLICK, function(e:MouseEvent){ myClickReaction(e, StringVar) },false, 0, true);
function myClickReaction (e:MouseEvent, StrVar:String):void{
StrVar="other sample";
} trace(StringVar); /* it also gives me "sample" value and I would get "other sample" value */
How to do that correctly?

View 11 Replies

Flash :: Call Variable Inside A Function ?

Sep 25, 2011

I'm trying to pass a variable through a function, but I'm getting it's value 0. Here's my code:

thumbLoader.addEventListener(MouseEvent.CLICK, goToCategory);
function goToCategory(e:MouseEvent) {
trace(c);[code]....

this trace gives me value of 0. Normally I would do goToCategory(c) and inside that category I would get it's value, but in this case I'm calling this function with an event, how can that be done?

var c is declared globally, so I'm using it above this code in different place... is there smth like global $c like in PHP.. or there's some other way to do it?!

View 2 Replies

ActionScript 3.0 :: Access A Variable From Inside A Function?

Dec 8, 2009

i am trying to access a variable from inside a function like this:

ActionScript Code:
var X:Number=1;
function hello(event:event){
trace(X)
}

or something like that... does anyone know why i don't get "1" in the output panel when i run the code?

View 3 Replies

ActionScript 3.0 :: Changing Variable From Inside Of Function?

Jan 9, 2010

I have a code, it is below. And i have two vars: coordx and coordy they both are 0 but when up button is pressed, coordx should change into 1 x remain 0 just like map scrolling and if pressed down it should return to default position, but instead of that variables keeps reseting and it starts from beggining. Here is the code:

ActionScript Code:
var coordx:Number = 0;
var coordy:Number = 0;[code].......

View 3 Replies

ActionScript 3.0 :: Change Variable Inside A Function?

Oct 19, 2010

How can you change a variabele in as3 that you have declared OUTSIDE a function and change it inside the function.My function seems not be able to change the variabele?

ActionScript Code:
function Filter2switch(event:MouseEvent) {
if(filter2 == false){

[code]......

View 1 Replies

ActionScript 2.0 :: Variable To Be Available Inside The OnLoadInit Function?

May 20, 2007

How do I get the for-loop's i variable to be available inside the onLoadInit function????

Code:
for (var i = 0; i<nTotalPics; i++) {
main.createEmptyMovieClip("container"+i,i);
var container:MovieClip = main["container"+i];[code]....

This has been bugging me for about 2 months now. Maybe I'm looking at it the wrong way, but I need to create more things in the onLoadInit function using a for-loop.

View 5 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 :: Use Data In Variable Inside Function In Ouside?

Jul 22, 2009

how can i use data in variable inside function in ouside

var m:Number=0;
function bClick(e:MouseEvent):void
{

[code]....

when i trcae (m); out side this function said 0

View 1 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 3.0 :: Memory Leaks - Variable Reference Inside A Function Or Outside It?

Mar 11, 2009

I wonder what the most common reasons for memory leaks in AS3 are.First thing what I am not sure about is: is it better to have a variable reference inside a function or outside it. Will the variable be null-d automaticly inside a function or when do I have to null it and when not?I have massive problems with my game with memory leaks. I noticed I reference some of the clips of the timeline even inside my debugging clip to display propertys and this was causing collecting huge amount of memory.But even before I go into the game with bigger objects the System.memory is slowly growing and growing.I just have a socket connection and some interval loops and enter_frame events.

View 5 Replies

ActionScript 3.0 :: Convert The Watch Function - Cannot Use This Variable Inside Any Other Class

May 20, 2010

I have been trying to convert the watch function code into AS 3. I am totally new to AS 3 and could not find the solution yet. Here is my code -

[Code]...

The variable 'buttons' must be in the root timeline. And, I cannot use this variable inside any other class.

View 2 Replies







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