ActionScript 2.0 :: Adding A Method To MC Class?
Jul 16, 2009
Basically I want to create my own drawRect() for as2.normally, I would just prototype it:
Code:
MovieClip.prototype.drawRect = function(x,y,w,h){ //etc.. }
and then I would be able to use it like:
Code:
mymc.drawRect(a,b,c,d);
Is there a way to make that function a class so that I can still call it from a movieclip directly? I read in another post somewhere about calling super.drawRect() in an extended class, but I'm not 100% on how to actually do this.So far I have what is below. I don't think I'm supposed to be declaring the mc var, but I can't think of another way to do it.
Code:
class drawRect extends MovieClip{
private var mc:MovieClip;
function drawRect(x,y,w,h){
[code]....
View 0 Replies
Similar Posts:
Jul 5, 2009
I'm trying to make a new method for the XMLNode class and I want to use this method in other classes of mines that manipulate XMLNodes. Here's what I did :
1. I wrote an Ext class which you can read here :
[Code].....
It didn't work (saying that myMethod doesn't exist), so I added this line "static var e : Ext = new Ext();" before "function Testing () {}" Then my method worked. I don't understand why but great.
3. The problem is that I want to use the method not only in the main function but also in other classes of the application. However, when another class tries to call the custom method, it says that it is not defined. I don't know how to solve that.
Additional infos: I'm using the Eclipse IDE rather than the traditional Flash IDE so I don't have such a thing as "the first frame". My app only has the main function.
-MTASC which compiles my code doesn't support #include
View 1 Replies
Jun 15, 2010
I have been trying to add a movieclip to my .fla file from a class.my main fla file: main.flaactionscript file: script.asthey stay in the same directory.script.as file as follows:
package {
import flash.display.*
public class MyClass extends MovieClip
[code]......
View 1 Replies
Aug 16, 2010
I have two classes. The Main class calls a function, which is defined in a Second class.I'm getting the following error:Error 1120: Access of undefined property myFunctionBasically, I am creating buttons in the Main class that will add a corresponding Child to an Object in the Second class (if you click one button, child x1 will be added, if you click another button, child x2 will be added, and so forth).Here's the relevant code for the Main.as file:
package
{
import flash.display.MovieClip;
[code].....
View 3 Replies
Jul 15, 2011
I have the following parent class that I'm working with:
Code:
package {
import com.poptent.SubClassOne;
import com.poptent.SubClassTwo;
[Code].....
I am trying to set it up so that a parent method called by subClassOneInstance can affect subClassTwoInstance.
View 4 Replies
Jul 5, 2010
I have a rather silly question but as3's document class always gets me confused.I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).
View 6 Replies
Mar 23, 2009
I have two classes:
1. DocumentClass
2. GameClass
I would like to be able to call a public method of DocumentClass from GameClass. I don't know how to do that, I tried instantiating an object of DocumentClass within GameClass which simply throws me into an endless loop and after a short while application crashes.
View 2 Replies
Nov 4, 2010
I have a class, my document class, called SilkRoadTweeter. as I also have a class called User.as In my User class I need to call a method called nonce() I have tried this, trace(SilkRoadTweeter(root).nonce()); But I get the error, TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 4 Replies
Jul 6, 2010
I have a public method on my document class. I want to call this method from another class that is instantiated from within an object in the library of the flash file (the same one on whose document class I want to call a method).
I have tried everything and nothing seems to work. How do I do this?
View 8 Replies
Dec 28, 2005
I have a class called Unit. When I use this class in a .fla file, I create it by saying:
var unit00:Unit = new Unit(...);
So then it creates a gfx representation of the screen for me. I would like to have a method like this:
PHP Code:
[code]....
So how do I get this to work? I know that delete this will not work when defined inside the class. How do I target the .fla's instance name when I don't know what it will be called?
View 10 Replies
Jun 9, 2011
They are located in the same package and are both importing each other. I am trying to call a function from Class2 within Class1, but I don't know the syntax. I tried: Class2.godoThisThingNow(); But it gave me an error 1061, call to an undefined method. What's the proper syntax for this, and is it even possible in AS3?
View 3 Replies
Oct 12, 2009
From my LoadXML class I am trying to call a method, named onBackgrLoad, which sits inside the Main class. I made the method onBackgrLoad public. Inside the LoadXML class in the method ParseData I added an event listener. This is supposed to call onBackgrLoad but it doesnt work
[Code]...
View 3 Replies
Nov 24, 2011
The name of my DocumentClass is Main. So, what's the difference between :
var myClass:Main = new Main();
var mcInLibrary:MovieClip ;
/////////////////////////////////////////[code]............
View 1 Replies
Apr 2, 2011
There is a Point (flash.geom.Point) class in as3.I want to add method to class Point (e.g. convertToStagePointMyMethod()) and I'd like to call this method by using [code]What should I do in order to add this method to class Point? Is it possible without inheritance. I'd like to use it like "partial" classes in .NET
View 4 Replies
Aug 22, 2010
this is a massively simplified version of what I need to do but using the following classes, what do I need to put in the second class to call the function from the first? This class contains what I want to call:
package code
{
public class myClass1
{
[Code].....
View 8 Replies
Jan 10, 2011
I have two classes, in one (the Start class) I want to run a function I created in another (the Brown class). I commented in Start where I want to call the "addBrownListen" method. I tried doing it with the line:
Brown.addBrownListen();
But that didnt work.
Here are the two classes:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Brown extends Rebounders {
[Code] ......
View 2 Replies
Jan 31, 2010
Is it possible to check a class to see whether it has a method or not ? Or even a particular property
View 3 Replies
Dec 31, 2010
I want to obtain a list of methods available to a class, given its name. How can I do this?
View 1 Replies
Jan 11, 2011
I wondered if there is a simple way I have have a snippet which traces the name of a method when called. I found className which is half-way there, but not something for the method... a 1-line trace(...) is what I'm after so I avoid typing the method name and leaving myself open to mistakes.This is for testing the order things happen, when I don't want to step through in the debugger.
View 2 Replies
Jul 3, 2006
how I might go about adding a method to flash.display.Graphics so that I can call it just like I would drawRect()¯
for example, graphics.drawDottedRect()¯
I tried extending Graphics with a new class called Graphics and adding my function but this does not work. I'm sure that the display object is making its graphics instance from the real flash.display.Graphics class and not my extended class.
View 2 Replies
Apr 3, 2010
That's my "Rules.as" class file (which is inside a folder called Classes)[code]Why selectedHand is undifined? How code should be?
View 4 Replies
Aug 14, 2011
If I import class X with method Y, what happens? Is every method and field included in the class? Or is it that when I type y() I'm actually referring to x.y()?
View 1 Replies
May 9, 2009
Can you do this in AS3?
function onLoadMe(e){
};
var pic:Picture = new Picture; // custom dynamic class with a method called onLoadPIc
pic.onLoadPIc = onLoadMe; i'm trying to change the method of my custom class on the fly for this instance...
View 2 Replies
Jun 12, 2009
I am trying to pass an xmlList from this class, and am having some issues. The thing is, how can I call a method that listens for a result, then calls another method..
package com.ryancanulla.utils
{
import mx.rpc.events.ResultEvent;
[code].....
View 3 Replies
Mar 18, 2010
how can i use getUserID method in my main.as?
NetConnectionClient.as
package com {
import flash.events.EventDispatcher;
import flash.events.Event;
public class NetConnectionClient extends EventDispatcher {
[Code]...
View 6 Replies
Jun 18, 2009
I'm in the process of making a game (a shmup) and I've started to question the accuracy of the timers in ActionScript. Sure, they're accurate enough when you want to time things on the order of a few seconds or deciseconds, but it seems to perform pretty poorly when you get to finer ranges. This makes it pretty tough to do things like have a spaceship firing a hundred lasers per second.
In the following sample, I tested how long (on average) the intervals were between 1000 timer ticks intended for 30ms. Time and time again, the results are ~35-36ms. Decreasing the time, I found the floor on the timer delay to be ~16-17ms. This gives me a max fps of ~60, which is great visually but also means I can't possibly fire more than 60 lasers per second :-(. I ran this test a few times at 100 and 1000 loops, but for both the 30ms test and the 1ms test the results didn't change. I print to a textField at the end because using trace() and launching the swf in debug mode seems to negatively affect the test. So what I'm wondering is:
Is this test a decent measure of the Timer class's performance, or are my results questionable? Will these results change dramatically on other machines? I understand this is dependent on the getTimer() method's accuracy, but the discussions I find on this topic usually center around getTimer()'s accuracy on larger intervals.
[CODE]...
View 5 Replies
Dec 4, 2010
I can call JS functions with ExternalInterface.call('func_name',.args). OK
But what if I would like to call a js class instance method instead?
ExternalInterface.call('obj.method_name',.args) //this seems not to work
Is there any way of doing it?
View 2 Replies
Mar 29, 2011
i have to read the current class name inside a static method. For non-static method it's easy i just call getQualifiedClassName(this) but inside a static method this is off course invalid.
View 2 Replies
Aug 6, 2011
When I type a class name without new before, FlashDevelop does not show autocompleate. Is it a way to enable that feature? (do you have the same issue?)
View 2 Replies
Mar 14, 2012
I want to create an array of strings in a text class that I can access with the main document class. Then I'll be able to populate a text field with items in the array. The purpose of this is to avoid having massive lines of text in my main document... but I can't even get my test to work. The compiler is telling me that the array (txt1) is undefined. First here's my code for the array:
//text array class:format5000
package {
import flash.display.MovieClip;
import flash.text.*;
[Code].....
View 2 Replies