ActionScript 3.0 :: Returning A Function Parameter As Variable?

Sep 21, 2011

ok so i've been stuck on this for a while...What i'm trying to do is create a function that updates a global variable (randomVar) that is itself a parameter in the function e.g

[Code]....

Basically, i thought randomVar and vari were the same so when vari was changed randomVar would too but that's not the case. So how do i make the parameter equal the new value(5). I want to repeat the function using different variables so putting randomVar = vari in the function is not possible.

View 5 Replies


Similar Posts:


ActionScript 3.0 :: Function Returning Array And Declaring A Function With Event And Variable?

Jul 27, 2009

is it possible to declare function this way

ActionScript Code:
function startShake(e:MouseEvent, num1, num2):void

what i mean is it possible to send to the function not only en event but also a variable and a second question how can i access

ActionScript Code:
function stopShake(e:MouseEvent):Array

this array that function return.

View 1 Replies

ActionScript 3.0 :: Function Returning A Variable?

Aug 9, 2009

I have a variable which needs to be updated upon user input. It works inside the function, the trace function returns the correct type, but for a reason it wont pass it on the variable on the main timeline.[code]

View 5 Replies

AS3 :: Flash - Returning A Variable From An Event Listener Function?

Sep 28, 2011

I'm trying to return XML from an event complete back to the main function, but can't figure out how to do it.Here's the functions I'm calling:Main File:

public var mySendAndLoad:SendAndLoad = new SendAndLoad();
mySendAndLoad.sendData(url,variables)
The mySendAndLoad class:

[code]........

View 3 Replies

ActionScript 3.0 :: Returning A Variable To Another Class From A Loading Function?

Aug 5, 2009

However, on a bright note its coming!!!! So far, everything is going well and I am now seeing the light with AS3I do have a question on returning a variable from a function that loads an external CSS. This particular function is located inside a LoadStyleSheet.as class along with another public function that sets text properties to fields when accessed. What I am looking for is accessing the stylesheet after its been loaded in another class. I know in AS2 I could use the Delegate method for something similar to this situation. Not sure what the next step is for AS3. Anyhow, function script is below.

ActionScript Code:
public function loadStyleSheetItem(loadStyleSheet_str:String):void {
var styleSheet_css = new StyleSheet;

[code]......

View 8 Replies

ActionScript 2.0 :: Function Won't Accept A Variable Parameter?

Oct 22, 2009

For the record I am running Flash CS4, but am using actionscript 2.0 (its just what I know, and I don't feel like learning 3.0)-So I'm making a contact list, and each of the names will be clickable to bring up more information. There's going to be a lot of names, so I'm trying to keep the actionscript concise. The code is shown below in a simplified form, but essentially I have created a variable for the hexadecimal color, and I have created a function which will change the text color of each of the name buttons. This works, I have tested it. But, I don't want to have to tell the function to run for every single name button

(eg. changeColor (option1 , testColor);
changeColor (option2 , testColor);
changeColor (option3 , testColor);
etc..)

SO - I tried to create a for loop that would run the changeColor function for each button without typing it a million times. The one below should run from "option1" to "option5" for instance. I originally tried entering the equation "option" + i as a parameter, but it did not work. So I tried the code below where the for loop creates a variable which is assigned the value option1, option2, etc. as it runs through the loop. I added the trace code, and it is showing me that MCname is holding the correct value. However, the changeColor function still refuses to insert the MCname variable as a parameter. The testColor parameter is a variable, and that will work, so why not the MCname one? I also tried replacing the MCname variable with the name of a button (option1) and it runs fine. I just don't want to type in every single option name for the entire list.Sorry for rambling, but I'm trying to fully explain the situation.. If the code is all correct, why won't the changeColor function accept a variable for the first parameter? Is there a way I can get this to work without having to copy and paste the changeColor(option, Color) code for every button (there could be over 100 options)

CODE:
var testColor:Number = 0x33ff00;
function changeColor(buttonName , myColor:Number){

[code].....

View 5 Replies

Actionscript 3 :: Run Function Only When Parameter Variable Has Been Assigned?

Feb 27, 2011

I need a way to wait running the parseCSV command until the readFile event has updated the content of importData. I have seen a few things about custom event dispatchers but cannot quite figure out how to use them in my situation.

private var importData : String;
public function importFile(event:MouseEvent):void {
var data:String = chooseFile();
parseCSV(importData);

[Code]....

View 2 Replies

AS3 :: Flash - Declare Variable With Name Of Function Parameter?

Aug 7, 2011

I have a function in my flash AS3 file. I'd like to pass a parameter when calling this function and have that parameter become the name of a new FLV playback component I'm declaring;

function newVideo(myVideoName){
var [myVideoName]:FLVPlayback = new FLVPlayback();
}

[code]........

View 1 Replies

ActionScript 2.0 :: Function Won't Recognize A Variable Parameter?

Oct 22, 2009

For the record I am running Flash CS4, but am using actionscript 2.0 (its just what I know, and I don't feel like learning 3.0)-So I'm making a contact list, and each of the names will be clickable to bring up more information. There's going to be a lot of names, so I'm trying to keep the actionscript concise. The code is shown below in a simplified form, but essentially I have created a variable for the hexadecimal color, and I have created a function which will change the text color of each of the name buttons. This works, I have tested it. But, I don't want to have to tell the function to run for every single name button

(eg. changeColor (option1 , testColor);
changeColor (option2 , testColor);
changeColor (option3 , testColor);
etc..)

[code]........

View 5 Replies

ActionScript 2.0 :: Variable As A Function Parameter Not Working?

Jan 28, 2010

I have a function with three parameters, that works fine when I type in the parameter values. The function is tweens(MCname, targX, targY) and it runs properly when I use tweens(btn1, 150, 200) for instance. I need the function to move 6 different movie clips, one at a time, and I am using a variable (Counter) and an if statement to tell the function to run again after one of my tween classes finishes. The code all works, and it will run six times with the same clip if I just type in one of the movie clip's instance names as the MCname parameter. BUT, if I try to use a variable (BTNname) to serve as the MCname parameter, it will not work, making it so I cannot apply the function to my 6 different movie clips. I put a trace on the MCname parameter, and it returns the correct value (btn1, btn2, btn3, etc) but it is not moving the corresponding movieclips. I've tried a number of different methods, but nothing will work..[code]

View 4 Replies

Call A Function With Event Parameter When Have No Event Parameter To Pass?

Aug 14, 2009

Forgive me for this stupid noob question but I want to call a function (loadList) that originally gets triggered after a mouseevent from another function (addToXML) that does not have an event.

The loadList function takes info from a XML var, sticks it into an array which then gets loaded into a tile list and that is working fine.

The addToXML function when called adds elements to the XML var after which I want to call the first function with the event parameter so it refreshes the items in the tile list.

I know it can do this by creating a new array and loading that into the tile list in the addToXML function, but it be much simpler to just recall the function.

I have tried things like

Code:
addToXML.addEventListener(Event.COMPLETE, loadList);

but all the event constants I have tried give me error messges like "1061: Call to a possibly undefined method addEventListener through a reference with static type Function."

View 3 Replies

Flex :: Require A Function Parameter To Be A Static Constant Of The Function's Class?

May 22, 2009

Let's say I have a Custom Event Class, and it has several Event types stored in static Constant:

[Code]...

Is there an easy way to validate that the type passed to the Constructor is one of the Static Constants of the Class, without having to check it against each value?

View 5 Replies

Php :: Calling A Page With MySQL Query From Javascript Function Then Returning Results To Another Javascript Function

Jul 8, 2010

I am refactoring some code. I have a PHP page that contains a MySQL query and stores the result in a PHP variable $my_result. This result is then echoed to a Flash SWF during embedding with SWFObject. I now want to call this PHP page that makes the query from a javascript function like so - one change I have made to the PHP is that instead of storing the result in a variable $my_result I am echoing the result. Javascript function to call the PHP page and make the database query

[Code]....

View 2 Replies

ActionScript 3.0 :: Returning A Value From A Function

Apr 6, 2010

I have an external function that needs to return a customerID value. However, it seems to be returning the initial value instead of the value that I believe is being set within the function.[code]

View 2 Replies

ActionScript 2.0 :: Returning A Value From A Function?

Nov 2, 2005

well I have a function in my index.swf that goes like this

Code:
function getLanguage(language):String {
var sLang:String = language;

[Code].....

View 5 Replies

ActionScript 2.0 :: Returning Value From Function?

Dec 14, 2007

I have the following function defined in a class:

Code:
vidNetStream.onMetaData = function(myMeta){
_root.totalDuration = myMeta.duration;
//trace(_root.totalDuration + "!");
}

totalDuration is a private variable defined in my class.... how can I get that function to effectively save totalDuration?

View 2 Replies

ActionScript 3.0 :: Sorting An Array Of Objects And Returning Another Variable

Aug 29, 2011

I have an object array into which I've pushed a number of objects with different variables :- myArray.push({myRef: 1, myValue: "W"}); I can sort the array in numerical order using :-myArray.sortOn("myRef", Array.NUMERIC);but after sorting I would like to collapse the array using something along the lines of :-myArray.join("");to join the OTHER variable (myValue)...Is it possible to do this without pushing every instance of 'myValue' to another array and then joining that?

View 4 Replies

ActionScript 2.0 :: Sorting Variables And Returning The Variable Name And Data

Apr 12, 2011

There are 12 color variables, and each answer adds a number to each variable.At the end of the quiz, all the variables are put into an array, and sorted. Then the 3 highest variables are displayed. I have gotten this far. My problem is that I need to link the variable name (color) with the number it returns.[code]

View 2 Replies

ActionScript 1/2 :: Pass Parameters Along With A Function That Is A Parameter To Another Function?

Sep 3, 2010

I'm having some trouble passing parameters with a function that is itself being passed as a parameter.In my application code I'm instancing that class five times:they are buttons in a menu.In that class, I've got an onRelease handler that does a number of things when a button is released, one of which is to invoke a function that is defined in the application level of the code.My problem is that I don't know how to send the function parameters.In my StandardButton class I have:

class StandardButton extends MovieClip
{
/* define properties */[code]..........

The function is successfully being "sent" to the StandardButton class, but without any parameters.How can I send parameters to the class instance with the way I've got this architected.

View 7 Replies

Actionscript 3 :: Default Function Parameter As An Empty Function?

Dec 23, 2009

i have a function that receives a function as a parameter. example:

function foo(bar:Function):void() {};

how can i set a default value for the function to be an empty function so the user will not have to paste a function as a parameter ?

View 1 Replies

ActionScript 3.0 :: MovieClip Not Returning From Function

Jun 30, 2009

I am trying to return a movieClip to a project variable, so it can be retrieved outside of a function. However it fails.

I tried to simply set up a variable so when the function returns, it has a storage variable.

Then i tried for a function to retrieve the variable content

However when i call the trace(mc) it fails as undefined [code]...

View 1 Replies

Flex :: Returning Different Sub-classes From A Function?

Dec 21, 2009

Say I have four sub-classes of 'Car'. One for each color. I want to have one function that can build and return a 'color-car' sub-class based on the passed value. This is a dumb example, I know, but it is precisely what I am trying to do only on a smaller scale.

public class Car
{
}
public class BlueCar extends Car

[code]....

Ok. You get it. This doesn't work for a reason unknown to me. I get 1118 errors which complain about conversion of BlueCar into Car, etc...

View 4 Replies

ActionScript 3.0 :: Class - Returning From Function?

Jun 28, 2010

I want to make class which will import picture into UILoader and then will show it. It looks like that:

ActionScript Code:
package mob.kopertownik
{
import fl.containers.UILoader;

[code]....

And into the *.fla file I have got something like this:

ActionScript Code:
var myPicture:Picture = new Picture();
myPicture.CreatePicture(fileRef.name);

When I have got everything ready and the all requirements are fulfilled there is nothing happening.

View 9 Replies

ActionScript 2.0 :: Returning Values From A Function?

Oct 12, 2005

I need to load data from a database, so I created the following function and placed it in frame 2 on the main timeline.

Code:
getQuestionSet = function (category:String, subject:String, level:Number, count:Number):Array {
var questionSet:Array = new Array();
var writeV:LoadVars = new LoadVars();

[Code]...

Whenever I try to call the function, it fails to set the value of the questions array. It always appears empty(questions[0]-questions[10] have the value undefined). But, if I check the values from within the function after I have set them, it works, so I know that it is receiving the values. What am I doing wrong?

Code:
questions = getQuestionSet("Art and Music", "Art", 1, 10);

Here is an example of how I have would call the function.

View 7 Replies

ActionScript 3.0 :: Classes Returning Value From Other Function

Sep 3, 2009

I have a question regarding classes.[code]What i want is that clue() should return me the value of NetStatus which is generated in returnResult() when this function is invoked.Now in this case var "f" will become undefined because Clue() is not returning anything, so how can i find a way that value of NetStatusEvent.NET_STATUS (in this case) will be returned from Clue().Although i can use ENTER FRAME EVENT to check when it has generated a status but i'm sure that there must be a better way.

View 1 Replies

ActionScript 3.0 :: Returning Object From A Function?

May 30, 2010

I am new to AS3 and need to gather data from an XML file, parse it and then return all the vars to be used globally. How do I return an object like in the code below?

Code:
var dSession:Object = new Object();
function parseXMLData(incomingData:XML):Object

[code].....

View 7 Replies

Professional :: LoadVars Returning Escaped String - Variable Access Not Possible

Aug 21, 2010

I am fetching some variables from a URL and get the result. While I can iterate through it via e.g.:

[Code]...

View 7 Replies

Flash :: Set Return Variable For Returning From Paypal To Merchant Site?

Feb 12, 2010

I am trying to implement paypal payment in as3. But the return variable conflicts with an as3 keyword. So how to set return variable for returning from paypal to merchant site.

View 2 Replies

Javascript :: Returning A Variable From An ExternalInterface.call Back Into Flash

Feb 17, 2010

I'm calling a JS function with ExternalInterface.call and trying to get a return value inside Flash. When I trace out the op variable I get 0 instead of 500. Is there something wrong with my embed code?[code]

View 4 Replies

Flex Alchemy - Returning A ByteArray From C Function?

Oct 28, 2009

I am using Flex's Alchemy library to generate SWC's out of C files. I have a byte array (unsigned char buffer[size]) in the c-layer that I'd like to return to the ActionScript layer as a ByteArray. Do I have to iterate through the array and explicitly call AS3_Set on each element or is there a way to just return the entire C array at once?

View 2 Replies







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