ActionScript 3.0 :: Declare Multiple Variables?
Apr 5, 2011How to declare Multiple Variables?? with or without data types
View 3 RepliesHow to declare Multiple Variables?? with or without data types
View 3 RepliesHow to declare Multiple Variables?? with or without data types
View 1 RepliesI'm just wondering if there is a short way to declare variables at the beginning of a class if you have lots of them? [code]...
View 3 RepliesI have a problem with functions and variables.. how to get functions that i use every onEnterFrame. et c: A MC is using this:
[Code]...
As you can see it gets new variables onEnterFrame... How do i get around this?
Is this the way to declare variables in AS3
Code:
var positionX:Object = null ;
var positionY:Object = null ;
positionX = rect_mc.x;
positionY = rect_mc.y;
I've looked arround and cannot seem to find exactly what I am looking for.I have a movieclip that I want to get a number of instances to the stage. Instead of declaring them individually (which works):
var a1_mc:monitor = new monitor();
var a2_mc:monitor = new monitor();
var a3_mc:monitor = new monitor();
[code].....
how a can i declare global variables in mx 2004? i want 2 declare a variable that can be accessed by all buttons & movie clips. i tried to put it in the main thingie (the one u find in the actions panel when you're not selecting anything)
View 3 RepliesI have a problem that I have read a few other threads about, but the solutions that are offered don't seem to work for me.
The solution offered was to declare the tween variables outside the function....
I have done this, but every now and then it doesn't finish the tween.
Here is my code for that part..
Code:
var alphaTween:Tween;
var myTimer:Timer=new Timer(150,0);
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, addMC);
[Code]....
I am working with URLLoader and URLRequest in this case.
I have two buttons. One listens for the mouse click event and then runs the following function (less code not applicable to this question):
function loadURL (e:MouseEvent):void {
....
var myRequest:URLRequest=new URLRequest("*URL*");
myRequest.method=URLRequestMethod.POST;
[Code]....
The other button, when clicked, calls another function, say resetAll, that then resets the "session" by clearing out all the current variables and canceling anything currently in progress. Within that function I want to call myLoader.close(myRequest); but myLoader is not accessible from within resetAll.
In this case, should I declare var myRequest:URLRequest=new URLRequest("*URL*"); and var myLoader:URLLoader = new URLLoader(); outside of the function even if I do not need them yet?
I can't access the variables that I declare in the main timeline from a child.
I attach the child to the stage during runtime.
Basically here is what I want to do[code]...
But I got something wrong in the declare statement.
If i have a series of variables that are referenced on an enter frame function, is it better to declare the frequently used vars at the class level? Is there a performance benefit? What is the standard?
Example
[Code].....
Can you declare multiple classes and then register each movieclip from the library to a different class? It isnt working for me.
I created two different classes and created two entire different movieClips and registered each movie clips to a different class.
However, I can only use on movieClip at a time, when I use the duplicateMovieClip... command to create copies of the movieclip, i find that only those movieclips, whose class i declared first, appear on stage.
I just want to know if there is a way to assign multiple variables, and if there is a way to check multiple variables.
I want to be able to assign variables to false and then check if all the variables are false.
Does anybody know if it's possible to declare variables in a "for" loop or in a "for each in" statement? If it isn't possible, is there any workaround to this? I'm not entirely informed about single variable usability, e.g. having only one "Sound" variable and playing multiple files from only that variable.
[Code]...
I'm trying to declare a few variables in a for statement using the variable in the for statement. In older flash versions I would use something like this.
Code:
for(a=0;a<10;a++) {
_root["variable"+a] = "Some text "+a;
[code].....
I want to declare on multiple numerated variables like this:
var myVar1;
var myVar2;
But I don't want to do this manually for every variable instance but automatically, so I need a way to instruct the compiler to declare by himself on every variable and to numerate them automatically.
So hopefully I explained myself well, I wanted to know if there is such way to do this?
Currently I have a simple setup which sends some data to PHP and then PHP returns a variable to flash. I have no problem tracing out the returned variable in Flash, however i'm strugling to send back more than one variable.[code]If I remove the trace and echo for fromPHP2, it's all good, however with with my second echo for fromPHP2 it just gives me back undefined:[code]It seems that fromPHP1 is basically returning both echo's.
View 1 Repliesi'm trying to trace this out - but i don't believe i have the right syntax:
trace (levelNum + "Questions" + [questionNum[currentQuestionNum]].correctAnswer);
i can trace out 'levelNum' and it traces out fine. i can trace out 'questionNum[currentQuestionNum]' and it traces out fine.basically without any variables my object array would look like this:
lvl(1 or 2)Questions[(a # here)].correctAnswer.
But my trace is not working and i'm not sure how to group that all together.
I got a problem with URLVariablesprobably better to show by example
Code:
for each(var foo:String in fooArray){
variables.foo = foo;
}
this unfortunately doesn't work as intended as the old foo variable in the URLVariables get overridden each time.Thus when I output the variables as suchTried looking around the net for it but couldn't find anything. Also it seems logical enough that the variable gets overridden and I wouldn't really question it if it wasn't that ive been told the querystring should contain multiple definitions of the foo variable...
I am using the Kirupa email form to gather some results on a form...How can I load variables from 2 different movieclips to post in the php? I tried...
_root.loadVariables("email.php","POST");
_root.myMC.loadVariables("email.php","POST");
As seen below, I tried to return more then one variable from a function but , I think I have some syntax problem..
function hesapla3(parametre1,parametre2):(Number&&Boolean) // PROBLEM IS HERE, I NEED TWO VARIABLES TO RETURN{var yenideger2:Number=new Number();var bol2:Boolean=new Boolean();yenideger2=parametre1+parametre2;if(yenideger2>80){bol2=false;}return yenideger2;return bol2;trace(yenideger2);trace(bol2);}
I have been focusing on PHP a lot lately and just had a client that requires an MP3 player playing multiple songs so I had to whip out my rusty actionscript skills. I have the player completed and it is working as desired. The down side is it has multiple songs. I am using separate functions for each song and separate event listeners. My main question is there a way to combine these funtions into one and just use the event listener to pass another variable to the functions? Below is a sample of one of the code for Song1. I would like to make it so anywhere there is Song1 in the code, I can make it a variable so I can put in for example (Song2, Song3, Song4, etc.) This way, I can have one or two functions handle all the songs instead of having to copy, paste and then find and replace.
// Song 1
var Song1:Sound = new Sound();
pbSong1.source = Song1;
//pbSong1.visible = false;
var Song1Loaded:Boolean = false;
[code].....
This may be a weird question, but I'm wondering if there's any way to efficiently (perhaps using namespaces?) have different default variables in a class per developer in an actionscript project. I ask because we're currently working on a series of Flash games: 24 in total. Each is loaded by a shell container. The shell receives a flash var for which game to load. In our development environment (Flash/FlashDevelop), there are no flashvars, so a constant in the AS defines which game to load when there's no flashvar:
[Code]...
I am a designer trying to modify some ActionScript for a web project. When defining the variables, I would like for some of them to have multiple parameters/categories[code]...
View 2 RepliesI have a conditional statement (if) that I am trying to use contingent on multiple variables being true. So the AS I have right now is:
[Code]...
But when I run that I get the following error message: "Error 1050: Can not assign to a non reference value" What do I need to change so that once 1,2 and 3 have been visited visitComplete is set to true?
I've automated a lot of my script, but cannot automate the very beginning where one sets the variables. I have the following script that I'd like to put in a "for" loop :
private var aliPlane1:Plane3D;
private var aliPlane2:Plane3D;
private var aliPlane3:Plane3D;
[code]......
I've tired to load multiple variables from a php file like this :
[Code]....
But dosen't work , it display me only the first var, the most simple metode to do that.
I am working on a project where I am getting some data back into my .swf via FlashVars. They are being sent back in a HTML Code: <param name = "FlashVars value ="resultstring=&username=value&userfirstname=value&userlocation=value" I am not sure how to target the resultstring in actionscript to retrieve all of the different variables?
View 9 RepliesI am sending a complex flashVar sequence where a shell swf gets the URL for a SWF to load via flash vars. The URL for this loaded swf has flashVars appended to it. I need to pass in two flashVars to the loaded swf, but can't get it to work. I think it might have to do with escaping the "&" -- I've tried & but no dice -- in both cases it just ignores the & and everything following it. I can't post sample code as the forum won't let me post what it considers 'links' -- but basically the flash var string passed to the loading swf is something like [code]...
View 1 Replies