ActionScript 3.0 :: Difference Between Using 'this' Inside Class And Not Using It
Dec 24, 2009
i am not very clear what is the difference if you are using this and if you are not.[code]In php you have to use $this to access class properties. But in actionscript you don't.In AS you can trace testVar using this or without it like this:[code]
View 3 Replies
Similar Posts:
Mar 22, 2012
I'm wondering if anyone has experience with if there is a big difference in performance in ActionScript 3 between keeping a class with only public static functions, and utilizing those functions often (as in a frame event at 30fps), and in turning the class into a "normal" class of which I instead make an instance and call the functions via the instance instead.
View 1 Replies
Mar 16, 2010
what is the difference between document class and normal class.
And I have no idea which class should call as document class or call as an object.
View 1 Replies
Jun 28, 2010
Given that both of these calls to getQualifiedClassName return the same thing (mx:Label), how would one go about programatically differentiating between an instance of a class and a reference to the class...
var lab1:Label=new Label();
var lab2:Class=Label;
var qcn1:String=getQualifiedClassName(lab1);
var qcn2:String=getQualifiedClassName(lab2);
In other words, how could I know that lab1 is of type Label, while lab2 is type "Class". typeof() simply returns "object" for both... getQualifiedClassName returns "mx.controls::Label" for both...
View 3 Replies
Jun 29, 2010
I'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;
}
View 1 Replies
Jan 9, 2010
I don't understand what is structurally different between a Value Object and a Class in ActionScript3. Can any Class be a VO if you decide to call it one?
View 1 Replies
Apr 1, 2009
I'm trying to get the as3corelib to work as when I run my file at the moment it tells me: 5001: The name of package 'com.adobe.images' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. /Users/markbunyan/Websites/craftmagic.co.uk/JPG_encoder/JPGEncoder.as I thought I had imported the as3corelib fine but can't get this to work. Can I simply import the code from JPGEncoder.as???
View 3 Replies
Apr 14, 2011
what is the difference between document class and interface in as3?
View 1 Replies
Jun 9, 2009
When I upload a file using a Flex application,what is the difference between complete and uploadcompletedata events? In which cases one of them will be dispatched and the other one won't?
View 1 Replies
Jun 12, 2007
I have this sample class
Code:
class TestPrivate{
public function TestPrivate(){};
private function getGo(){
trace("can execute");
}}
And then after instantiate I just calling the method...for testing the "public" and "private" keyword purposing only...
Code:
import TestPrivate;
var obj1 = new TestPrivate();
obj1.getGo();
The result is still can be execute even though I put the private keyword in front of the methods. So what's the private keyword stands for actually...I thought it prevent been get accessed from outside...
View 2 Replies
Sep 23, 2009
package{
public class Character{
protected var _hp:uint = 50; //Character Health Points
protected var _power:uint = 5; //Damage dealt
[Code].....
I`m instancing a Character and a Player in the Main Timeline, all in frame 1.
When I use: ""player.attack(character)"" it works fine by itself.
So I added the if (defender._hp <= 0) this.win() which gives me the following error:
1061: Call to a possibly undefined method win through a reference with static type Character.
"defender" is a Character instance, "this" is a Player instance and "win()" is a Player method. I try to call the Player method inside a Character method using the Player instance adding the "." and his method name
Do I really need to define the win() function in the Character class? Is there a bypass to use a subclass method in a parent class method if it`s called from an instance of the subclass?
View 6 Replies
Feb 3, 2009
Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.
I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().
I hate to be defiant, but what if I don't want to?
Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?
It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.
That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.
HERE ARE THE STEPS I'M TRYING:
- Create new flash document
- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage
- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()
- Set a name for that box using box.name = "test" let's say
- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great
- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";
That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?
View 1 Replies
Feb 12, 2009
i have a BasicMap.as that takes an Array and populates itself with the MC objects passed to it by a String reference.it inherits from Sprite, and so it just places the objects on its self.then i have a class that inherits from that class, and gives a little more functionality to it, but in order for it to do that, it needs to place the objects not on itself, but instead inside a holder Sprite, so here is my problem:
code:
package Mushroom{
import flash.display.Sprite;
[code]......
View 8 Replies
Oct 7, 2004
I was wondering why my current code for calling a setInterval on a function doesn't work inside my class.I have this code inside one function, calling a second function.
intID = setInterval(selfReferential, dupe, 30, 0x000000);
The selfReferential keyword refers to the current class,but was defined previously (selfReferential = this; ).I get no errors, but the dupe() function is never called.and I had the selfReferential variable replaced with the this keyword at one point as well.
View 5 Replies
Jul 8, 2007
I want to know how to make class instances into listeners and broadcasters, from inside each class. Here is what I am trying specifically... part of the Proj class... (projectiles, as a matter of fact)
Code:
private function listen():Void {
u.register(this);
onUpdate = function(){
step(); // a function I have which makes the projectile move (not shown)
}
}
where "u" is another class, the Updater class with this code...
Code:
class Updater {
// const. --- make this a broadcaster
public function Updater(){
[code]....
PS: What is the syntax for using AS2 code tags instead of just "[CODE|"?
View 2 Replies
Feb 18, 2007
I am having a problem instantiating a Character class inside of a game class.I am working on converting URL...l these tutorials to A.S. 2.0.[code]
View 2 Replies
Apr 19, 2010
This is what i'm trying to do :
I have 1 class that extends movieclip, let's call it Class0. I have 1 class that extends movieclip, let's call it Class1.
I create an instance of Class0 on stage like : var myClip0:Class0 = new Class0(this, "Class1");
The class Class0 when initializing, will create a new movieclip (myClip1) and add it as child, as an instance of Class1, like myClip0.myClip1. But it's when i create that clip, i want to tell it, it's an instance of Class1, like :
private var myClip1:Class1 = new Class1(this);
Where Class1 could be any class.
How do i pass Class1 to Class0 so it can create it dynamically?? Do i have to use the apply function??
inside Class0, i have a function that does :
Code:
if(subClass){
initSubclass(subClass);
}
[Code].....
View 8 Replies
Dec 24, 2009
Performance wise, is it better to instantiate inside or outside the constructor?
Code:
public class example {
private var _mc:MovieClip = new Movieclip();
[code]......
View 4 Replies
Nov 6, 2009
I am very new to flash and on the net I've found a class that allows me to use a nice scroll bar for the content. My problem is that I can't get a preloader working with the class. When I want to add scrips to the frames it bugs the class if I try to implement the preloader inside the class I can't get it working. Here's the class I am using for the scroll bar. - if you want to test it, it will require additional data. You can get it all here: [URL].
package{
import flash.display.*;
import flash.text.*;
import flash.events.*;
import gs.TweenLite;
import com.warmforestflash.ui.FullScreenScrollBar;
public class Main extends Sprite{
[Code] .....
If I try to insert the preloader script inside the class it has problems with the stop(); & play(); commands. Any way to get a preferably simple preloader working with the class I am using?
View 1 Replies
Feb 27, 2007
i've defined a class and inside that within a function i''m calling the getURL function and passing the variables using the POST method.but while compiling the compiler throws and error of There is no property with the name 'POST'when i try to assign ths "POST" to a string variable and pass that variable to the getURL function i'm getting an error of only "POST" or "GET" method is allowed.
View 8 Replies
May 11, 2011
I have a problem running gotoAndStop from insida a class (.as). I have a class called deathScreen, when you click a button which i made it will go to another frame. This is what i have:
package classes
{
import flash.display.MovieClip;
import classes.dummyCamera;
[Code]....
When i run this i get an error saying: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Function/<anonymous>() The object is created dynamiccly in the code (precisly when the player dies, this object is placed on the stage)
View 2 Replies
Nov 21, 2011
The attached SlideshowExample.as file works quite nice when I use it on stage directly. But when I tried to use it in Gallery_mc movie clip, it doesn't work
View 3 Replies
Feb 3, 2009
I have a private class variable that is an array. I have the getters and setters like I would for any other variable. When I push something on to the array from outside of the class using the instancename.arrayname.push() it pushes it onto all of the arrays of all instances of that object like it is a static variable or something.
View 2 Replies
Feb 18, 2004
How can I use LoadVars inside a class?I mean, if I assign the method name to onLoad of LoadVars, the method will be override, and will not pertence to my class.look this:
[AS]
class myClass{
var lv:LoadVars;[code]...
this at onLoad function points to loadVars not to myClass.the only solution I found to this was to myClass extends LoadVars, but it limit me since AS 2 does not support multiple-Inheritance.I think I will face the same problem with all others components that does not has addEventListener capabilitie.
View 3 Replies
Nov 8, 2005
Take a look at these example:
Code:
function loadMap():Void {
varxdata:XML = new XML();
xdata.ignoreWhite = true;
[Code]....
Now, im creating a local variable var var_temp:String; cause, there is no way that i can pass the values, inside the onLoad handler to a property of the class.
If i try some this.some_var its reference to escope inside the onLoad handler..
View 2 Replies
Nov 24, 2006
I have created a class file with 2 functions one to load an xml file and the other to parse the file and push the values into an array. My problem is that I can't access this array inside another function unless pass the array as a parameter or the main timeline. Below is the class file I'm using:
Code:
import mx.utils.Delegate;
class XmlTest
{
[Code]....
What I would like to do is pass the array to another function in the class file. This function would loop through the array and push certain values into an array that would be returned to the main timeline so I can using them.
View 4 Replies
Feb 19, 2007
I am curious in what strategies people are using (if they are using) the Key events inside of their classes. I am trying to build up a character class and I wanted to encapsulate the movement inside of the class.
View 3 Replies
May 3, 2011
I created two children from my document class "MainClass". One (hero) is of the class "HeroDo" and another is from the class "canDy".
Code:
public static var hero:HeroDo=new HeroDo
public static var blue:canDy=new canDy[code]....
...
Now the simple thing I want to do is to remove the "blue" child from within a function of the "hero" child and the hero child to remove itself from "its inside".I tried this, but it gives me an error. :C
Code:[code]...
View 6 Replies
Feb 18, 2004
I mean, if I assign the method name to onLoad of LoadVars, the method will be override, and will not pertinence to my class.
[AS]
class myClass{
var lv:LoadVars;
function myClass(){
lv = new LoadVars();
lv.onLoad = onLoad;
} function onLoad(sucess:Boolean):Void{
trace(this);
} function trigger(){
lv.sendAndLoad("testeURL",lv,"POST");
}}
This at onLoad function points to loadVars not to myClass. The only solution I found to this was to myClass extends LoadVars, but it limit me since AS 2 does not support multiple-Inheritance. I think the same problem with all others components that does not has addEventListener capabilities.
View 3 Replies
Nov 11, 2010
I'm just starting with as3 object oriented programming -- i've always liked the idea, but could never "see" how the whole objects/classes worked with actual game development.in my fla file i have this...
Actionscript Code:
var moveBob:MoveMan =new MoveMan()
in my MoveMan.as file...
Actionscript Code:
package { public class MoveMan { public function MoveMan() { bob.x = 5 } }}
and on the stage i have a movieclip with the name set as "bob" If i use this line in my fla file... bob.x = 100 it works.But when i try to move the movieclip inside the class i get this.1120: Access of undefined property
View 1 Replies