ActionScript 3.0 :: Handling Unknown Number Of Vars?
May 8, 2009to pass an unknown number of variables to a function and do the same thing with each one.
[Code].....
to pass an unknown number of variables to a function and do the same thing with each one.
[Code].....
I read up a bunch of vars and pop them in arrays to use in a series of if statements. That works fine. Right now I have a fixed number of items so I can just write the code below.How could I set this up to work so that it could deal with any number of items in the arrays.The length of all the arrays will always be the same.It could even be one array I think, as items could be fed in in order.[code]
View 2 RepliesI'm trying to load a known number of variables. So I set up this code in flash[code]...
View 1 RepliesI'm trying to load a known number of variables. So I set up this code in flash[code]...
It recive "antal"which is how many variables there are. The variables name are named produkt_0 produkt_1 produkt_2 produkt_3 and so on..
So it collect the varibales correct i've checked this by set loader.data.produkt_load to loader.data.produkt_0. But since I don't know how many I just can't set loader.data.produkt_load to loader.data.produkt_0. Insted I want produkt_load be a variable like it is in my code, but it seems that loader.data.produkt_load became undefined, why this? Can't you set a variable that change in loader.data.hereismychangingvariable?
i wanted to a load unknown number of variables from a text file
View 1 RepliesDoes anyone know how to load an unknown number of photos into an array from a specific file path? I want to then use them in a photo carousel.
View 3 RepliesI have a project that uses a lot of remoting calls and I'm hoping to abstract the process. I've hit a problem with passing parameters to the final call...[code]...
I know how to loop through the ...rest param to obtain their values but I'm struggling at how to construct the final gateway.call() which could have 1 arg or 10.
Basically what I'm trying to create is a custom timer that uses frames rather than milliseconds. But I can't figure out how functions like setInterval calls the function you passed along with the arguments. First I create a reference to the function I want to execute after a certain interval and name it fc, then I create a list of arguments my function want to pass using Array, but then how do I put those arguments in fc()?
View 2 RepliesI have an object MyTester, that has an instance of another class MyClass, and I want to test MyClass API through it:
public class MyTester {
internal var myObj:MyClass;
public function MyTester() {
[Code].....
How can I cancel the switch and make it work for any number of arguments?
I've made an user login, working with php and MySQL. When the user logs in, he can see all of his details, loaded from a database. Here he can press a button to change this content. After changing it, he needs to press the "save" button to load the new data into the database. But everytime the user presses the save button, it's adding an extra line to the data into the database, which results in an error of displaying the data. Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required 'google_verify.php' (include_path='.:/usr/local/lib/php') in Unknown on line 0
View 1 RepliesI was wondering if it is possible to add 2 numbers together if one of them is being pulled from an xml file,
[Code]...
I have a function:
Code:
function test(arg1:int, ...rest) {
function anotherTest(rest); // -> Seems not working
[code]......
I got an input function in witch i set all the variable i want to display. To make it clean i would like to input any number of vars without having to change my input function to avoid the "Expecting more/less arguments". Then i would like to get any type of var (bool num int ....) in the input and then check their type, instead of declaring the first input var being exclusively a number for example. Is that possible and how, don't know if i was clear,
View 5 Repliesi am trying to load vars from a text file into a load vars object.
var kitchentext = new LoadVars();
kitchentext.load('moccastext.txt');
Once in the object, i thought i could reference them like so
kitchentext.name
kitchentext.style
but i am having trouble doing this.
i have a textbox called displytext.
_root.displaytext.text = kitchentext.name;
doesnt work
Dear Guys I Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It , Is There Any Solution
View 5 RepliesI Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It,
View 4 RepliesWhen swf file shows up on a computer as an unknown file, does that mean the computer doesn't have flash player? Or do I need to change my publish settings?
View 3 RepliesThe problem is simples as this, I don't have the slightest what this gomx class is:[code]I have a lot calls like these in the .as files of this site, no import, nothing, I can't find any reference in the code except this line.Also, I can't seem to find any information on the web about this class.. The only thing that I know is that it takes one object and one movieclip. I don't know if this is in house code or not, I can't find it anywhere on our disks so I think not.
View 1 RepliesI have a Hgroup that contains of four panels. Sometimes it happens then when users open it the panls have a unknown width even bigger than the window resolution.
<s:Scroller width="100%" height="100%" >
<s:Group width="100%" height="100%">
<s:VGroup gap="10" width="100%">
[Code]....
how can I have the name of the target object, even unknown with the hitTestObect? the function is working when i am giving the object name as parameter to the function, but i cant figure out how to find the name of the hited object.[code]
View 1 RepliesI'm trying to load in a simple xml file that I created in about 5 seconds. Its not complicated. Infact, its really simple. Yet, flash doesn't recognize it..Here is the code.
PHP Code:
var rq:URLRequest=new URLRequest("http://www.myserver.com/information.xml");
var loader:Loader = new Loader();
[code]....
a project needs to load a bunch of images of which at runtime only the filename, but not the filetype (ending) is known. so i need to load "thumb01" but i do not know if it is ".jpg" ".swf" or ".png" how i can i make sure it loads finally. shall i use the IOErrorEvent.IO_ERROR Event to know that for instance "jpg" did not work and then try "png" and so on.
View 1 RepliesI am trying to breake apart text in flash (CS4) and distribute it to separate layers. The breaking apart works fine, but when I want to distribute the letters into layers, I get this: "could not complete operation because of an unknown error".
View 7 RepliesWe have a big project, which include about 700 classes and based on Robotleg frameworks.at some point looks we reach some limitation of flash ide, we got this error and can't render properly.[url]...
View 1 RepliesUsing the Embed tag, we can embed in the swf file not only swf's or jpg's etc, but also unsupported file formats like:[code]When i instantiate such a class, what type of object do i get? Is it possible to get a ByteArray from this class?[code]
View 1 RepliesI am taking over a Flex / MXML project for work. The last programmer lost the original source code so I ran it through a decompiler. In the main MXML file there are 3 lines that return errors. IMPORT COM.TURBO.*I've never heard of this and I can't seem to find anything on it. I assume its some kind of plug-in. Does anyone know what it is?
View 1 RepliesI have 3 navigation buttons and an empty movie clip on the stage. Clicking each button loads a 'page' into the empty clip, and each 'page' is a movie clip in the library. When the movie initially loads, the 'home' page movie clip automatically loads into the empty clip on the stage and plays to a frame half-way through. When a navigation button is clicked I want to finish playing the loaded movie clip, remove it, load the new 'page' into the empty clip, and play it (also to the half-way point). I have been able to accomplish everything except getting the name of the loaded 'page' clip and making it play to the end. This is what I have in frame 1 of the main timeline with the code for 1 button:
var homeMovieClip:MovieClip = new homeScene();
emptyMC.addChild(homeMovieClip);
gotoAndPlay(2);
bioButton.addEventListener(MouseEvent.MOUSE_UP, bioClickHandler);
function bioClickHandler(event:MouseEvent):void{
[Code] .....
I have been working on a large sized movie lately and found that I was getting some unknown errors. So naturally I placed trace statements, still I had no idea what was going on. Then low- and -behold I noticed that I had two varaibles one name xPos the other Xpos. Now of course noramally I would assume like other programming languages such as java and C++ variables are case sensitive. I found that If I assigned xPos a value and wrote a trace statement (with different case) ie
[Code]...
If i have a function and im strict typing: such as
[Code]...
obviously the second doesnt work because y is a movieclip and x is a number, but i want to be able to set x to whatever type is being passed in.
I'm trying to convert some C# code I have and one problem I can't find a solution for is to have a function take parameters of unknown types.
C# code:
PHP Code:
public T Maximum<T>(T v1, T v2){ return v1 > v2 != null ? v1 : v2;}
A straight translation to AS3 would look something like this, for making it easier to understand for people that might be confused by C# syntax.
[Code]...
This way you can send in anything as the parameters (notice the <T>), be different classes for example, depending on what situation you want to use it, instead of writing a lot of duplicate functions for every possible parameter type.
Is there a way to do this in AS3? Edit: Seems like I managed to find a solution right after I wrote this. Seems like one can use "*" as parameter type.