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


Similar Posts:


ActionScript 2.0 :: [MX PRO 2004] For Loop Variable Not Showing Increase On Each Iteration

Feb 22, 2008

I am wondering if anyone has experience this problem before:

[Code]...

I was experiencing some other "strange" behavior so I'm wondering if my code is getting too long. Maybe I'm running into some kind of limit. Has this happened to anyone else? Anyone know of some fixes? The loop is in a _global function, could that be causing a problem? other than that, the code is on line 4420 of the actionscript coding interface.

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

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 :: 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 :: 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

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

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 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 :: Show Steps Of An Iteration In It?

May 28, 2009

I did an ActionScript 3 version of my old algorithm made in c language to solve the �Tower of Hanoi� puzzle.

The problem is that I knew how to show the intermediary steps in c language but I don�t know how to do that in ActionScript 3.

The below .as file code uses just three disks of successive bigger diameters ( and different colors ) created as MovieClips in Flash which must move from the first peg to the third one, through appropriate moves, in such way that they end up piled up in the same crescent order as they were in the first peg.

The way the code is written just shows the beginning disks position and the end result but not the intermediary steps.

I want this code being capable to show the successive disks positions on the pegs in each step of the process, each time I right-click the mouse.[code]...

View 2 Replies

ActionScript 3.0 :: Pausing A Loop At Each Iteration?

Nov 30, 2009

I'm working on a script and I've run into a coder's writing block so-to-speak. I have an array of twenty object (with attributes). I want to loop through the array and for each object, update some text fields, create a tween, pause, and create another tween (i.e. fade in / fade out). I tried working with the timer class but the for loop, as expected, keeps on rollin' after the function has been called by the listener.

View 10 Replies

ActionScript 2.0 :: How To Remember Iteration Numbers

Oct 25, 2008

I have this code.
for (i=1; i<6; i++) {
this.attachMovie("myMovie","unit"+i,i);
this["unit"+i]._x = i*100;
this["unit"+i].onRelease = function() {
trace("Unit number " + i + " was pressed");
};}
I want to trace the number (i) of the button that is pressed. But no matter what button I press, I always get the value '6' on my trace. Isn't there a way to store the a value for i in each movie clip attached?

View 3 Replies

ActionScript 3.0 :: Last Iteration Of A Loop - Buttons

Jul 30, 2009

i have this from as2, where i can create many buttons on stage and loop. then create a function that applys to all the buttons

Code:
for (var i = 1; i <= 3; i++)
{
bt = this["button" + i];

[Code].....

View 3 Replies

Flex :: Recursive Iteration Through Every Component Instance?

Nov 17, 2009

I have various custom component instances in my flex app. I want to loop through them recursively and get their instance Ids. The recursive part is very important to me. I have tried doing this, but it didn't do recursive:

for each (var myItem:* in this.MasterContainer.childDescriptors)
{
trace(myItem.id);
}

View 3 Replies

Arrays - Make For Each Loop Dynamically Depth Of Iteration?

Mar 24, 2012

I hope I am clear enough. My data set is populated I have

comment:CommentVO;
comment.replies=[comment:CommentVO,comment:CommentVO,comment:CommentVO];
_comments:Array = [comment:CommentVO,comment:CommentVO,comment:CommentVO]

I've correctly populated my _comments Array and the replies array in my CommentVO Obj.

[Code]...

View 3 Replies

Xml :: Flex ListCollection Iteration Concatenating Collected Values?

Dec 29, 2010

I am working in flex builder 3 with an XMLListCollection and have run into this (should be simple) parsing snag...The XMLListCollection Data:

<data>
<term name="NUMBERS">
<alt_form name="1"/>

[code]......

View 3 Replies

ActionScript 2.0 :: Use Iteration To Reference Each Array Name To Pass It Into A Function

Nov 12, 2004

In AS2 I have several arrays constructed like this :

var myArray0:Array=new Array(value,value,value...)
var myArray1:Array=new Array(value,value,value...)
var myArray2:Array=new Array(value,value,value...)
var myArray4:Array=new Array(value,value,value...)
...

What I'm trying to do is use iteration to reference each array name to pass it into a function.

[Code]...

View 2 Replies

ActionScript 3.0 :: Iteration Through Array Of Complex Data Object On Different Properties?

Sep 27, 2011

I am not sure my title is correct.Is there any 3rd-party library on AS3.0( like STL in C++), can do this: I define my class and use its objects as associative array, for example:

class Company{
var public name;
var public logo;

[code].....

View 7 Replies

ActionScript 3.0 :: Displaying A For Loop Iteration Counter In A Dynamic Text Box?

Jan 26, 2012

I am just learning how to use Flash AS3. I have made a very basic animation that is a circle with a slice in it that grows larger over a couple of seconds until it is about a quarter of the size of the circle. It is designed for my research subjects to watch and follow for range of motion and speed as they complete a leg exercise task. I used a basic for loop in the animation to repeat it 10 times, then a frame appears that says "Set Complete." I would like to add a repetition counter to the screen so that subjects know which rep they are on throughout the animation. I know that I have to use a dynamic text box to do this, but I don't know where to put the script so that the new counter number will appear on the screen after each loop. Here is what I have so far for script:

Action Layer first frame of loop:

var count: Number=0;

Action Layer last frame of loop:
count++;
if(count<=9){

[code]....

View 6 Replies

Arrays :: Actionscript 3 - Creating A New Array For Eache Iteration Of The Function Call. AS3

Oct 5, 2011

so I have writing a function that returns objects on the stage and puts them into an array. and the function works fine until i call the function on more than one object name, meaning if im in the root class, and I call this function on object1 lets say it will add all the object one's from the stage, but if i call it on object2 it will throw an error, which makes some sense, i guess it means that it is not adding it to a unique array, but im not sure how to do that. would it be a good idea to maybe make a multidimensional array? if that is the case would it be too slow?

[Code]...

View 1 Replies

Actionscript 3 :: Skip An Optional Parameter And Assign Value To The Parameter After The Skipped One?

Dec 14, 2010

Can we skip an optional parameter and assign value to the parameter after the skipped one?

For example I have a function:

public function Dialog(message:String,title:String="Note",dialogsize:int=99):void
{
}

I can easily call the function with a message and a title:

Dialog("HELLO","Intro");

Is there a way to skip the title and just pass in the dialogsize? I've tried it but can't make it work:

Dialog("HELLO",,dialogsize);

Is it possible to skip some optional parameters without using (rest) parameter?

View 3 Replies

ActionScript 3.0 :: Read A XML File And Check A Parameter For Duplicates Of That Parameter In The File

Dec 8, 2009

I am trying to read a XML file and check a parameter for duplicates of that parameter in the file. There could be up to 200 entries with this parameter which is a number. How can I check to see if there are any duplicates?

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

Actionscript 3 :: Passing Custom Class As Parameter To Custom Class Where Parameter Class Not Constructed?

Jun 16, 2011

I have a custom class being constructed from my main class. In the custom class it has another custom class that is passed in as a parameter. I would like to strictly type the parameter variable but when I do, 'the type is not a compile type constant etc'.This, I understand, is because the custom class used as a parameter has not yet been constructed.It all works when I use the variable type ( * ) to type the parameter.I suspect this is a design flaw, in that I am using an incorrect design pattern.It is actually hand-me-down code, having received a large project from someone else who is not entirely familiar with oop concepts and design patterns.

I have considered using a dummy constructor for the parametered class in my main class but the passed in class also takes a custom class (itself with a parametered constructor). I am considering using ... (rest) so that the custom classes' parameters are optional.Is there any other way to control the order of construction of classes? Would the rest variables work?edit)in main.as within the constructor or another function

var parameter1:customclass2;
customclass1(parameter1);
in customclass1 constructor:

[code].....

View 1 Replies







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