ActionScript 2.0 :: Difference Between A Variable And A Function?
Jul 16, 2004Whats the difference between a variable and a function? Ive started reading an actionscript book.....and to me it seems there the same.
View 4 RepliesWhats the difference between a variable and a function? Ive started reading an actionscript book.....and to me it seems there the same.
View 4 RepliesWhat is the difference between declaring a variable like this: variable = 1; and declaring it like this: var variable:Number = 1? Why is it better to use the second way?
View 4 Repliesjust wondering if theres a difference between using
function x() {
}
and
x = function(){
}
i find sometimes,but rarely function x() will not run while the other will??
I would like to know what's the difference when I write a temporary variable like this (these are just examples): version1
[Code]...
What's wrong and right? Currently I write it like version 2 and I'm not sure if I should change it to version 1. I know most developers write like version 1 but I'm a little bit confused because I am totally unaware about version 1. If I use version 1 does that mean that my value is stored explicitly in a temporary variable that is cleared in every cycle?
What is the difference between set and get function?
View 2 RepliesI'm wondering what the difference is between creating a new object with a class or function? For example:
Code:
class snake{
this.id = index++;
this._x = 0;
this._y = 0;
}
or
Code:
function snake(){
var snake = new Object();
snake.id = index++;
snake._x = 0;
snake._y = 0;
}
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"?
I working on a game project in Flash AS3. I need to pass data from one class (Game) to other class objects (Ships) on EnterFrame and performance is starting to be a issue. I was wondering is there a difference in performance between calling to the Ship a direct function or dispatching an event which the Ship can listen.
another question is where should I put the enterframe function. Is it better to use only one enterframe function and call the methods dispatch events from there, or it will be wiser to put the enterframe in the different objects (Ships)? note: some Ships are inactive most of the time.
What is the difference between the following two function definitions in ActionScript 3?
f = function(arg) {
// body
}
and
function f(arg) {
// body
}
If i keep aside the loose coupling advantage of Events, what is the difference in the way of working of
1) Simple function call
2) Dispatching an event
is there a difference between classifying a function 'private' or 'private static' in a singleton? It seems that they both do the same thing. Maybe some difference in performance?
[Code].....
anyway im using flash as3 for about 6 months, and im still kinda confuse in this things like getters and setters, and idk what you call that but here's and example :
private function myBoolean():boolean
{
//codes here //
{
idk how to use it, and what it differs from getters and setters,
wat's the difference between finding a angle using Math.atan2(y,x) function and by finding using the movie clip's rotation (mc._rotation*Math.PI/180);
View 9 RepliesWhat exactly is the difference between using "this" and 'this' when you do something like set a variable?
View 2 Replieshow you would target a function's local variable through a concatenated variable string.For example:
var txt = "Hello World";
function testing(msg) {
var test1 = msg;[code].........
I'd expect the trace to be "Hello World" but rather is given "undefined". So if variables created outside functions are created on the main timeline, where are local function variables created and how would you access them?
I'm trying to combine PHP/SQL and Flash. I've got a problem now. I want to load a variable that contains an url to an image. so the variable is like this: [URL] Now I want flash to load the image, not the text. The variable is called 'img1' but the loadmovie function doesn't work when I put it in.
View 2 RepliesI want to monitor a variable. Whenever the variable value changes I want to call a function. In actionscript 2 I can use "watch" but in as3 what can do ?
View 1 RepliesI have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc. Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. 1120: Access of undefined property theAnswer. I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.
[Code]...
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.
I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).
ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",
[code].....
I want to create a vector, then call a function that populates that vector with arrays. Fine. The only catch is the function itself will declare new array variables to put into the vector, but are these new array variables private to the function only?e.g. something like this
ActionScript Code:
public var vec:Vector.<Array> = new Vector.<Array>();
private function populateVec():void {
[code]....
Is this "kosher"? a was declared in the private function but added to something outside the function..?
I have taken variable in one function and want to use that value in another function.
View 2 Replieshow to get variable value from a function to a text box here is the code :
import fl.controls.ComboBox;
import flash.events.Event;
import flash.events.MouseEvent;
TxtAnswer = Array();
[code]....
.. i want that variable "sk1" to next scene text box ..i putted the code like this :
q1.text = sk1;
but it is not working..
me how I can use the variable from one function in another function?
For example:
function init():void {
var test:Number = 1;
}
[Code].....
what is the diference between:
function show()
{
}
versus
show = function()
{
}
I use this two methods to build a function.there is a difference?
I have created an actionscript function which stops an animation on a specific frame which works fine. I have then loaded in a php file with a variable which will contain the number for the frame i want the animation to stop on. This has loaded in fine and i have loaded it in a function. what i cant seem to do is to get the variable into the function which tells the animation to stop playing.
here is my code:
//load variablesvarReceiver = new LoadVars(); // create an object to store the variablesvarReceiver.load("http://playground.nsdesign6.net/percentage/external.php");//load variables
[code]....
I have this code:
for each(var tool in tools){
tool.addEventListener(MouseEvent.MOUSE_DOWN, function(){
trace(tool); //Always the last tool
});
}
How do I bind the value of tool to the function so that it's accessible on callback?
Can't seem to get the value of myXML outside the function, despite being declared outside. The data loads and traces correctly inside the function.
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("flightPlannerBoard.xml"));
var myXML:XML;
// Check XML data fully loaded
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
myXML = new XML(e.target.data);
//trace(myXML);
} trace(myXML);
I'm using the following class as part of my project:
Code:
package {
public class getData extends main{
[code]......
I have successfully passed a value to my function using another class.how do i know it works? Because when I put the trace statement in that function it gives me the value of the passed value.Now I want that value from that function to be get or to be used IN OTHER FUNCTION WHEREIN THAT FUNCTION IS ON ENTERFRAME. But I cant for some reason._a is a global variable
ActionScript Code:
package {
import flash.display.MovieClip
[code]......