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


Similar Posts:


ActionScript 3.0 :: Function Passed As Parameter Not Working?

Apr 11, 2010

I've got this code:

Code:
function func2(options:Object)
{
...
}

[code].....

-which doesn't seem to work.

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

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

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

Parameter Variable With $ In The Name?

Dec 1, 2009

I recently took over an AS3 project someone else programmed. It's quite well done and nicely object oriented. However, I have come across something I have not seen before.

protected function addedToStage ($event:Event) : void {}

The parameter in the function above uses the prefix $ before the parameter name "event". What does this do - if anything?

View 1 Replies

ActionScript 2.0 :: CS3 Passing Parameter/variable From Url To Swf?

Oct 23, 2009

i am trying to define a parameter/variable in my html file and pass it through to the embedded swf file:

Code:
<param name="movie" value="index.swf?wmode=transparent&index=XXX">
...
<embed src="index.swf?wmode=transparent&index=XXX" width="200" height="910" quality="high" pluginspage="http://www.adobe.com/shockwave/download

[Code].....

View 2 Replies

Actionscript :: Use For Variable As Parameter And Keep It Different For Each Iteration

Mar 25, 2010

I have a basic for loop to loop through buttons and set some stuff and onPress handlers:[code]However, as I noticed, all buttonsthen link to one and same frame - all point to last i + 1 - Is there any possibility to call gotoAndStop with "static" Number, so in next iteration, it won't change?[code]

View 1 Replies

ActionScript 3.0 :: Pass A Parameter Into A Variable?

Jul 20, 2009

I have a hangup on very basic issue...I am trying to pass a parameter into a variable that gets passed into a function.

Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
var myBtn:String = myFunction();

[Code]....

View 2 Replies

PHP :: Multiple File Upload With Parameter Passing Not Working

Apr 7, 2010

I have created my own file upload flash app that has been working great for me up until this point. It uses PHP to upload the files and sends back a status message which gets displayed in a status box to the user. Now I have run into a situation where I need the HTML to pass a parameter to the Actionscript, and then to the PHP file using POST. I have tried to set this up just like adobe has it on [URL] without success.

Here is my Actionscript code:
import fl.controls.TextArea;
//Set filters
var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
var textTypes:FileFilter = new FileFilter("Documents (*.txt, *.rtf, *.pdf, *.doc)", "*.txt; *.rtf; *.pdf; *.doc");
var allTypes:Array = new Array(textTypes, imageTypes);
[Code] .....

The flashVars variable is the one that should contain the values from the HTML file. But whenever I run the program and output the variables in the PHP file I receive the following.
//Using this command on the PHP page
print_r($_POST);
//I get this for output
Array (
[Filename] => testfile.txt
[Upload] => Submit Query
)
Its almost like the parameters are getting over written or are just not working at all.

View 3 Replies

Actionscript 3 :: Flash Cs5: Set A Variable Using A Function, Then Read That Variable From A Different Function

Jan 29, 2012

I have a public variable and I am trying to set it, then read it from a different function:

public var str:String;
public function DailyVerse()
{
function create() {

[Code]....

My trace results says null. Why does it not give me "hello"?

View 1 Replies

Actionscript 3 :: Pass Unevaluated Variable As Parameter?

Apr 9, 2012

How do I use an unevaluated (and/or possibly undefined) variable as a parameter for a function? For example:

function myFun(a:int):void {
a = 5;
}

[code].....

View 2 Replies

ActionScript 3.0 :: Loader Not Working - Error #2007: Parameter Url Must Be Non-null

Dec 5, 2009

I am trying to load an image. The image paths are stored in an xml file called "setup.xml". I'm getting the strangest error. Never seen it before.

[Code]...

View 3 Replies

ActionScript 3.0 :: Parameter Child Must Be Non Null - Variable Scope?

May 5, 2009

I'm working on a sliding gallery like Hulu. Setting it up and the sliding slides in and out is working fine. However, I need to add and then remove a button to each slide as it comes in and goes out. (I initially tried including the button on each slide, a mc, but this proved problematic for the event listeners). So when the file loads up, I add a mc to the first slide of the group like so (features[] is an array of movie clips - my slides):
Code:
var goBtn:MovieClip = new FeatureButton();
features[0].addChild(goBtn);
goBtn.x = 350;
goBtn.y = 230;
So I add the button/mc to the first slide - works just fine.

So there are two handlers, next and previous. So I started with the next handler. The first thing I have to do is kill the button on the panel that is sliding out, so I do that like so:
Code:
features[featureCount].removeChild(goBtn);
goBtn = null;
(featureCount is a counter keeping track of the slides). This works fine. I click the next button, and the button on the slide disappears and we move to the next slide - perfect.

So then I add the following next - exactly like I did in the beginning:
Code:
var goBtn:MovieClip = new FeatureButton();
features[featureCount].addChild(goBtn);
goBtn.x = 350;
goBtn.y = 230;

This time adding it to the current slide coming in - but this generates the following error:
Code:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at featuregallery_fla::MainTimeline/nextFeature()
How I'm getting an error on the removeChild() when that is already gone. I assume "parameter child" means goBtn - yes it is null because it's been removed. But I'm not trying to do something with that. I can only guess this is a variable scoping issue with goBtn - but I'm not seeing how to resolve it. Flash file attached.

View 8 Replies

ActionScript 2.0 :: Creating Custom Components With Variable / Parameter

May 7, 2003

I want to create a component with a variable/parameter that is a method it calls when (clicked on for example). In "Flash UI Components.fla" the they do this and I studied the code but cant get it to work. The Push Button one has a click handler, but the way it is actually called in the script is like this:
this.handlerObj[this.clickHandler](this);
That bracket/parenthesis thing is not working.

View 4 Replies

Actionscript 3 :: Get Pixel Bender Shader 'inputSize' Parameter Working In Flash?

Jun 20, 2011

Here's a snippet of a pixel bender shader that I'm using in Flash:

parameter float2 srcSize
<
parameterType: "inputSize";
inputSizeName: "src";
>;
input image4 src;

The width and height of the source image are filled in correctly in the Pixel Bender Toolkit, but when I run this shader as a filter in Flash Player 10, the srcSize value is not automatically filled in.

View 2 Replies

ActionScript 2.0 :: Multiple Parameter Link Load In Flash Variable?

Oct 13, 2009

I want to load variable with multiple parameter link so i will load it in flash Like i have text file like it :

link1=mylink/youlink/ghe&ghik?dfds.blabla.html
link2=mylink/youlink/ghe&ghik?dfds.blabla.html

so how i can load it in flash?

View 0 Replies

ActionScript 3.0 :: Getting 4 Parameter Arguments Into A Function From XML?

Jan 1, 2010

I'm designing a game that uses this function;

function moveBars(Bl:Number,Gr:Number,Or:Number,Ye:Number)
{
blueBar_mc.scaleX += Bl;
greenBar_mc.scaleX += Gr;
orangeBar_mc.scaleX += Or;
yellowBar_mc.scaleX += Ye;
}

When moveBars is called, the length of the 4 colored bars change to indicate how the player is doing in different areas of the game, like so; moveBars(.1,-.2,.3,-.1)

My problem; I need to store the moveBars parameter arguments in XML like so;

<myArgs> .1,-.2,.3,-.1 </myArgs>

But I can't find the way to get those 4 numbers into the moveBars parameters from the XML doc. Is there a way to do this?

View 5 Replies

ActionScript 2.0 :: Function Won't Accept A Parameter

Jan 28, 2010

Essentially, 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 2 Replies

ActionScript 3.0 :: Class Name As Function Parameter?

Sep 10, 2009

I wanna pass a class name as a function parameter.In that function I wanna make instances of that class, any1 know how?

View 1 Replies

ActionScript 3.0 :: Pass Function Parameter 'evt'?

Feb 24, 2012

I'm just looking for clarification on the passing of a parameter and why/how it works.

In this example, it looks like you create a parameter to be passed in called 'evt', but I don't see it used anywhere in the function. [code]...

View 9 Replies

ActionScript 3.0 :: Function Gets Null When Put It On A Parameter?

Mar 26, 2012

I'm trying to program a race timer with OOP, and I've been adding more and morefunctionality to its class. Everything had been running well, until I had the idea to put a countdown() function, to make a cool countdown effect. Things got worse when I wanted to make the countdown function to call another function when the countdown effect has finished.The code runs well when I first pass a function parameter from the Main class to the Timer'scountdown() function. The problem begins when I want that function to be past again on other private function of the same class, because this time, the function becomes nullOn the Main class constructor, I 've written the following line:

ActionScript Code:
timer.countdown(5, false, myFunc);
ActionScript Code:

[code].....

View 3 Replies

ActionScript 2.0 :: Set Optional Parameter For A Function?

Jul 17, 2005

lets say i define a function...

function myFunc(para1, para2, para3){
blah.. blah..
}

but i want para3 to be an optional parameter... can i do it..?

example..i will either use myFunc(var1, var2); or myFunc(var1, var2, var3); when calling myFunc function...

View 1 Replies

ActionScript 2.0 :: Sending Function Name Via Parameter

Dec 16, 2006

I am sending a name of a function via parameters to another function. This allows more usage of a single function. However, the button commands work every-so-often. The message appears everytime with no problem.

Code:
_root.msgReveal("This is just a random message. Click the ok button to close.", false, true, false, false, _level0.msgHide(), false);

Code:
function msgReveal(msgString:String, btn1B:Boolean, btn2B:Boolean, btn3B:Boolean, command1:Function, command2:Function, command3:Function) {
msg.messageBox._visible = true;
msg.messageBox.textF.htmlText = msgString;
msg.messageBox.btn1._visible = false;
[Code] .....

View 14 Replies







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