ActionScript 3.0 :: Flash Extending The TextField Class?
May 26, 2011
Basically the issue I am having is related to the TextField class. I was hoping to create a custom textField class which would allow me to specify the x and y positions of the textField upon creating it.
However in trying I received numerous errors. Below is my code.
AS file
Code:
package
{
import flash.text.TextField;
[Code].....
1119: Access of possibly undefined property xPosition through a reference with static type flash.text:TextField.
I don't how to describe the situation in short, so I am going to describe it in details.
I have created a class, extended from MovieClip. It looks like this:
// Libraries are imported public class WindowObject extends MovieClip { public function WindowObject():void { dragArea_mc.addEventListener(...);
[Code]...
When I clicked on the errors, they redirected me to the WindowObject class.If I don't create new classes, but just write the additional functions on the MovieClip directly, and set back the base class to be WindowObject, it works fine again.
I made a custom event, but was getting this runtime error: TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@1498f491 to com.esidegallery.net.BatchLoaderEvent. and eventually found what I thought was the the answer here - [URL] I made the necessary changes, but I'm still getting the same error! It's just a batch loader that dispatches a custom event for every item that loads, with its LoaderInfo object attached. Here's the event code:
I want to add a property to the MovieClip class. I just have a bunch of MovieClips that are placed on the stage by reading an XML file and creating lots of clips according to the information in them. Now, I need to know which MovieClips were created below previous clips, and I figure that the easiest way to do so would be by extending the MovieClip class and add an order property.I have some problems though: I don't know how to set or get this order property within the main clip, I don't know how to place this clip within my movie, and I don't know how to create them dynamically (do I just do something like var myNewObjectOfExtendedClass : myExtendedClassName = new myExtendedClassName?)
This is the code I have on my extended class, called Expando.as:
I made the transition to AS3 two years ago, but I still carry with me old AS2 habits. Could someone please help me understand how I extend a custom class correctly. I have the bad habit of putting most of my code in one .as file (the Document class), but I use a few custom classes now and then. What I'm tring to figure out is how I would extend a class of this type:
public class ClipDragger { private var _clip:MovieClip; public function ClipDragger(clip:MovieClip) { _clip = clip;
[code]....
For example I would like to add a MOUSE_MOVE listener, and also add actions to the drag function.
I'm having an issue extending a class in the JWPlayer API, but I think it's probably more of an issue of the way I'm extending the class in AS3 rather than the class itself. Here is the code:
All three of the final functions do not return values even though I have event listeners only calling those values one Event.COMPLETE (of the loaded SWF that contains this script).
am attempting to make a simple asteroids game using push button engine. In the game the ship should fire when the user pushes the spacebar button.To do this my KeyboardController class should make a new instance of the Bullet class on every tick when the spacebar is down.The problem is for some (probably simple) reason I can't extend the Entity or IEntity class. IEntity is an interface so I understand why I can't extend that, but I'm not sure why it's not letting my extend entity. Heres my code for calling the bullet constructor:
if (PBE.isKeyDown(InputKey.SPACE)){ var _newBullet: Entity = Bullet(); }
By this question, I don't just mean add a final to your class name.I'm talking about, let's say that you have a class that only one other class uses, but should not be accessed by no other class. Is it possible to say in the extended class that only this other class can extend me?*Change* Also, can you restrict which classes are allowed to initialise it?
I have an AS file named MovieClipTLnd which I created to add a property to the MovieClip class, plus a function to trace the current value of the property I added. I works out just fine. But when I do the same trying to extend the Button Class, it won't work.
check the last lines of this LiveDoc, a few days ago someone posted a comment regarding this problem
[URL]
I know there are some workarounds for this problem... like embedding the button into movieclips and assigning properties as objects, but I need to know if it's possible to Extend the Built-in Button class itself just like it can be done with the MovieClip Class.
extending a class from MovieClip? I could just make a movieclip variable in the class to make it simpler. I heard if you extend from Movieclip it makes it feel like its dynamic because you have frames (gotoAndStop, etc). However, it allows me to have direct access to variables (or this.) instead of somemc., and I believe thats faster because 1) smaller name variable lookup, 2) no get function call.
I've been going through the OOP AS 2.0 tutorial here on Kirupa, and I was curious WHY this code is in a class which extends the MovieClip class and is used to affect a linkage item in the library:
Code: // init method for arguments which in other normal // circumstances (non-MovieClip classes) would be // given to the constructor. Not an option with MovieClips
[code].....
Is there something undocumented about why I wouldn't pass those parameters in when instantiating a new instance of the class in question? What is different about extending the MovieClip class?
I have class that subclasses fl.controls.DataGrid. The function below from the DataGrid superclass throws a compile time error (implicit conversion fl.controls.DataGrid to DataGrid) when the subclass resides in an unnamed package.If I place the subclass in a named package, the error disappears. If I use a different class name (e.g. DataGrid2), the error disappears.I never intended to leave the subclass in an unnamed package. However, I am curious as to why the unnamed package is preventing the compiler from seeing that DataGrid is a subclass of fl.controls.DataGrid.
Code: public function addColumnAt(column:*, index:uint):DataGridColumn { var dataGridColumn:DataGridColumn;
I'd like to write a class that extends String, changing the functionality of several methods such as charAt to incorporate the Welsh alphabet. The reason for this is that the Welsh alphabet is as follows: as you can see, some "letters" actually contain two characters, which messes up any charAt operations, etc.
Is it possible to extend String? When I try, I get "base class is final".
I found this thread on another forum which talks about doing this, but has no mention of it not being extendible:[URL]..
i have class A, then class B which entends class A, then class C which entends class B.now in class A there are couple of empty methods currently defined as protected.in class B these methods are also empty //i dont know how to make this exactly, they should obvioulsy be here as well because... -> then in class C i want to override these methods and actually do something in them.so how do i stretch these empty methods from class A to class C?
Code: class A: protected function rollOverHandler(e:MouseEvent):void {} class B: override protected function rollOverHandler(e:MouseEvent):void {
I have this extremely odd problem. OK to start off I have an MC in my library with the linkage identifier "Interface" and the AS2 class "Player" (both without "" of course). Now, my player class looks like this.
I have an AS file named MovieClipTLnd which I created to add a property to the MovieClip class, plus a function to trace the current value of the property I added.I works out just fine.But when I do the same trying to extend the Button Class, it won't work.check the last lines of this LiveDoc, a few days ago someone posted a comment regarding this problemknow there are some workarounds for this problem... like embedding the button into movieclips and assigning properties as objects, but I need to know if it's possible to Extend the Built-in Button class itself just like it can be done with the MovieClip Class.
I'm just now learning the new object oriented way of scripting. It's been a wild ride, but I've finally learned how to keep script off my frames (very hard coming from as2).Here's my problem:
I have a TextField on the stage in my main .fla file named loadPercent.
I'm loading a jpg with preLoad.as and displaying the bytes loaded in loadPercent.
I can access my loadPercent TextField from my MainClass
I get three '#1120 access of undefined propery' errors for each time i try to access loadPercent.
a few basic questions: 1. all my files are in a folder in my documents, not in the flash directory, is this bad? I've seen people using com.whatever etc.
2. my main .fla file does not share the same name as my MainClass.as (it's not named MainClass.fla) Is that a problem?
I'm assuming these are inconsequential because my code seems to work up to a certain point.
I am creating objects for a game, they are all sprites. but I also want them to implement an interface. Is it possible to do both ? If not, how can i have an object have the capabilities of a sprite and also have it implement an interface. I am wanting to create another class that checks all my objects to see what datatype they are and evaluate them accordingly
I am trying to extend the TextItem class in Flex 4 but I keep getting the following error: Could not resolve <custom:txtIdNumber> to a component implementation.
My txtIdNumber.as is as follows package custom { import spark.components.TextInput; public class txtIdNumber extends TextInput { public function txtIdNumber(){ super(); [Code] .....
Initially I thought that I might be extending the class in the wrong way, but all the examples I found look the same.
I can't quite wrap my head around the differences. In what situations would I choose one over another?Specifically, I'm creating a sort of View component (in a very hack-y sort of way, I'm sure) that can redraw the interface with the same visual components (some of which change slightly depending on the mode) in 3 different modes: Normal, Small, or Fullscreen. The trick here is that both the Normal and Small modes can *also* go fullscreen as well, though you'll never be able to switch between Normal and Small in the same session (it's determined up-front).
In classA I have an object constantly moving around (Event.ENTER_FRAME).classB extends classA.From classB, I am trying to trace the object coordinates(or even the object itself) from classA while it moves. The coordinates are constantly returning 0. I know I am extending correctly, cause I can trace classA variables. Any variable change though, and it will not allow classB to see it. I even tried to "super.method()" and it still doesn't see the classA object moving around.
Code: public function SideModule() { if (stage) { init();// stage accessible, call init function[code]....
if i extends thsi class with class B (class B extends class A) how will i get this events in class B? do i have to register for them in class B as well?
I've never extended a component class in AS2, and I'm having problems with it now.
Here's my class file: Actionscript Code: import mx.video.FLVPlayback;import mx.video.*;class AkamaiFLVPlayback extends FLVPlayback{ public function AkamaiFLVPlayback(){ super()}}
Here's how I'm trying to instantiate it from the FLA: Actionscript Code: import AkamaiFLVPlaybackvar g = new AkamaiFLVPlayback()this.attachMovie(g,myVid,1)g.contentPath = "[URL]"
Now this does not work at all. I can see that the super class FLVPlayback is creating variables, but it's not loading to the stage or initializing.
When you do, you'll see that the movieclip should obviously be at position (0, 0) on the stage. However it appears at (25, 5)! if I leave in the original "this.x = xx;", then it appears at (50, 5). If I also leave in "this.y=yy;" then it appears at (50, 10).