-
Classes?
How can i define a class like the Array class where you can assign values to a variatble directly and yet have it have functions attached to it.
I want to be able to do this.
myVar = 5;
myVar.testOutput();
//-----I want output to be
5
is this possible?
thanks
-
FK'n_dog
not 100% sure on what you seek
is it this -
code:
function testOutput(theVar){
trace(theVar);
myOutput.text = theVar;
};
myVar = 5;
testOutput(myVar);
hth
-
no.. i want to create a class similar to that of the array class where you can assign values directly to the variable
myVar = new Array();
myVar = [1,2,3,4];
myVar.push(5);
I want to be able to do the same
define a class with functions - maybe i'm using the wrong terms... maybe its not a class that i want to build - but i think that's what a collection of function is right?
myVar = new myClass();
myVar = 5;
myVar.add(6);
trace(myVar);
//----output
11
did i make myself clearer now?
-
FK'n_dog
myClass = new Object();
myClass.myVar = 5;
myClass.myVar += 6;
trace(myClass.myVar);
you reached the limits of my approach to flash, so this might help
http://www.macromedia.com/support/fl...del/index.html
-
possibly what your looking for...
http://www.actionscript.org/tutorial...e/index2.shtml
Inheritance is probably the hardest concept to understand in OOP for Flash.
-
the add() function i added to the class was just to illustrate that i want to be able to add functions to a variable while still addressing it as a variable.
Flash Arrays() have direct access
myVar[5] = 6;
Flash Arrays() have methods
myVar.push(6);
this is what i want to be able to do, so that
myClass has direct access
myVar = 5;
myClass has methods
myVar.someFunction(6);
is that clearer?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|