ActionScript 3.0 :: Override A Shape Class?
Jul 4, 2011I want to pass extra arguments to Shape class.
I think this can be done if I override a native Shape class.
how can I override ? Or How can I add a property to a shape?
I want to pass extra arguments to Shape class.
I think this can be done if I override a native Shape class.
how can I override ? Or How can I add a property to a shape?
I have learned that there is a class called Function which is used as a blueprint for all as3 functions. Is there a way to override the call() function within the function class so that a trace can be made when any/every function is called?
View 2 RepliesI always have a question about override custom event. I am not sure why or what do to inside override function. I searched google but didn't get too many feedbacks. EDIT: My projects seem work fine even though I use my custom event without override. Anyone could explain it?
View 2 RepliesThe current implementation of the Flash Player ApplicationDomain with regards to override class definition seems like a giant security flaw to me.A parent SWF has complete control over what child SWF they want to load and add to its ApplicationDomain. It stands to reason that if the parent trust the child SWF enough to load the file, it should also trust the class definition defined by the child SWF and use those definitions.
In contrast, a child SWF has no control over where it is being loaded into, or if it want to be loaded into another SWF at all. Therefore, there is no reason for the child SWF to trust the class definitions defined by the parent SWF.I recommend changing the current implementation of the ApplicationDomain and allowing a child SWF to override any conflicting class definition in the parent's ApplicationDomain.
That is i have called one AA class in to stage. AA class is extends from BB class. BB class extends from CC class.CC class extends MovieClip. In CC class i have given CLICK event trace("this is CC class"). i am also given for AA class CLICK event ("this is AA class ").When I Click the AA in out put panel "this is CC class" ,"this is AA class ") i want to stop CC Class mouseEvents.
View 1 RepliesI'm having a total brain fart right now because I haven't dealt with AS2 library linkage classes in a while. I want to be able to let a designer assign an object in the library to a specific class and have that class listen for changed _x and _y values.I have the class made up that extends MovieClip:
Code:
class CoordinateMonitor extends MovieClip {
public function CoordinateMonitor () {}
}
But I draw a blank now on how I'm to monitor _x and _y values for the clip. I'm pretty sure I remember it being possible to do this and declaring an overriding function ("public function set _x(val:Number) { super._x = val; }") does not work as intended.
I have two child classes ClassA and ClassB both inherit the same base class.
I also have a function that has a parameter which could be an instance of either child classes.
function Test(instance):void //instance is either a ClassA or ClassB instance
{
instance.DoSomething();
}
However, when I run the test, it's always the BaseClass.DoSomething() get called. How can I use the same function (DoSomething()), but call child class function instead of the base class one?
I got a background asset loaded then I want to add a textField above that asset. How do I do this. It sets behind. And I can�t figure out how to override the IDisplay class.
View 0 RepliesIs it possible to externally override a public function of a class (as opposed to override via inheritance)?
For example:
Code:
Class Foo {public function doFoo():void {trace ("Foo");
}
}
Such that:
[Code]...
I know this is possible in JavaScript and ECMAScript, but the compiler won't let me get away with this kind of mischief in ActionScript, from what I've seen: It barfs up a 1168 Illegal Assignment error as soon as I attempt to assign a new function to doFoo.
I'm thinking specifically in terms of a "hot fix" solution where you deploy a small swf that replaces a specific chunk of code in a larger application, without the need to recompile/deploy the full application (or even see the sourcecode for that matter, just know the API).
i know its easy to override a function of a parent class, but I need to be able to override a function for a class on movieclip.. see highlighted code.
[Code]...
Is it possible to override/replace a method of a class in AS3? When I say "replace", I don't mean subclass it and override it. I mean I literally want to replace the existing method with my own. For instance, AS3 has the built-in HTMLLoader class which has a load method. I want to say, in essence:
HTMLLoader.load = function() { trace("Overridden"); };
Therefore, when *anybody* makes a new HTMLLoader object and calls the load method, it will call my method instead.
I've tried a couple things, and so far I've gotten this far:
HTMLLoader.prototype.load = function() { trace("Overridden") };
And I compile it with -as3=false -es=true -strict=false. The problem is it doesn't override the already-existing load method. It looks in the class first before looking in the prototype, thus making it not work. There must be a way. Even if I can't override it, can I proxy it like a decorator in Python or a macro in LISP? (So mine gets called then it gets called.)
override a custom class method with a function expression? For instance, if I want to change the destination of a button on the fly, I could theoretically type:
Code:
var new_destination:Function = function(evt:Event):void{ go_to_new_place();};
myButtonClass.mouse_clicked = new_destination;
but unfortunately that generates an error because the class method "mouse_clicked" is already defined in my class (with the eventListener tied to it). I tried using the "override" keyword in the Function Expression but that didn't work either.
This is for a playbook app. I have two classes:
public dynamic class Bullet extends Sprite {
public function update():void {
x += 5;
y += 5;
[Code]...
This is essentially what I'm trying to do. What's the best way to achieve this in actionscript?
Lets say I have the following inheritance hierarchy:
Code:
Select allpackage {
public class ClassA {
protected function foo():void {
// do something
}}} package {
public class ClassB extends ClassA {
[Code] .....
Now this is all well and good, as the call to ClassC.foo() will propogate through the inheritance chain; C > B > A. But what if I want ClassC.foo() to call foo() that is in ClassA and bypass the method call in ClassB? I have tried the following:
* Cast the method to the super-class type I want to execute, but this does not work as intended.
Code: Select all...
override protected function foo():void {
// do something related to Class C
// call ClassA.foo
ClassA(this).foo();
}
I have a videoplayer with a custom skin class. I want to override the functionality of the fullscreen button. When I add an click event, the player still goes into fullscreen mode. How can I prevent the fullscreen event from firing?
View 2 RepliesI'm having some troubles with the use of interface and inheritance in AS3. I've done lots of OOP in the past and what I'm trying to do seems obvious to me, but doesn't work in AS3. The question is : Is it possible to override a function that return an Object of class A, and make it return an Object of Class B which extends A ? It seems not to be possible, since I'm getting a signature error in Flash, when compiling. For example, the following set of class do not compile (the code in function definition doesn't matter):
[Code].....
My application has a lot of dynamically loaded shapes... Now i am working on an interface to change the color properties of each Sprite. The first idea was a simple colorTransform. But afaik this only allows for transforming the existing colors. I also want to be able to define a NEW fill, i.e. GradientType.LINEAR / RADIAL.
SOLUTION 1: There may be an undocumented method to retrieve a graphics current points. With that i could loop through this Array with lineTo and redraw the current shape with the new solid / gradient fill.
SOLUTION 2: Create a newSprite with the chosen GradientType, size it by currentSprite.getBounds(); and then use newSprite.mask = currentSprite; to fake my desired fill... However, i am afraid of the impact this creates on the application as there may be more than 200 of these Shapes displayed on stage... overlapping each other.
Does anyone have an example of using code and the shape class to create a star shape?
View 1 RepliesI am trying to create a circle instance of FirstCircle class (by Milan Toth):
ActionScript Code:
package
{
import flash.display.Sprite;
[Code].....
I supposed the constructor would do all the work then. When testing the movie I get no error but no circle was displayed, trace statement put in the class constructor displayed the message ok. When I put the class code directly to the ACTION FRAME, it works fine.
what should I do to get the circle visible in the fla using the FirstCircle class?
Im checkin out actionscript for basically first time kind of. Im now looking into creating shapes with actionscript at the same time learning the way actionscript handles oop.
So, here is my problem. Its easy to make a shape, but from within a method of a class, the shape will not appear on the stage. I try the same code snippet in my fla file, and it works fine. Here is the code im using:
The package file:
Code:
package com.adobe.shapelib {
import flash.display.DisplayObject;
import flash.display.Graphics;
[Code]....
why the shape is not appearing? As mentioned if i take the contents of the function named "circle" into my fla file directly, it appears as normal...
This is my first meeting with the Shapes; which don't seem cooperating, at all. Following is the Class code:
Code:
package
{
[code]......
I want to use Image Reflection in trapezoid shape. That why i ask how to create trapezoid shape with the class of matrix
View 1 RepliesI am having some problems regarding image crop.I am able to crop an image but with the use of rectangle class or in rectangular shape.But i would like to crop in circular shape(for example go to URL...).
View 8 RepliesI drew a line (stepVoltage) in a fla using the graphics class. Once drawn, I want to move it to the right in an update function, but am having trouble. I tride just moving the line with statements like stepVoltage.x = newX; stepVoltage.y = newY; but this didnt work. Then I tried to delete the previous line and draw a new one with a clear () function (see below) but this blocked the next drawn line from showing up.
The code:
var stepVoltage:Shape = new Shape ();
stepVoltage.graphics.lineStyle(2,0x000000);
addChild (stepVoltage);
[Code]....
So I'm playing with a project where I want my class to be able to use the functionality of the Graphics class without needing to extend Sprite/Shape. My goal aside, I guess I'm confused as to how it works at all? It's methods don't seem to return anything, and since it's added as a child property of the Sprite/Shape classes , I can't seem to figure out what it's actually doing? It's also one of those classes that can't be instantiated.
At this point, I'm just plain curious. EDIT: I should provide more clear distinction of what I'm looking for as answer. I have read the documentation, but the documentation doesn't account for what AS3 is actually doing. I'm looking for educated guesses about the programatic relationship between Graphics and the the classes that use it.
I downloaded an Mc Tween Class from [URl] so I can use the ColorTransformTo method. However, the method only works when my movieclip is an image; and I need the method to work when the movie clip is a shape...
View 1 RepliesActionScript Code:
package {
import flash.display.MovieClip;
public class Base extends MovieClip {
public var baseHP:int = 50;
var newRect:Shape = new Shape();
1046: Type was not found or was not a compile-time constant: Shape. 1180: Call to a possibly undefined method Shape. What does it mean by "undefined method"? I am somewhat of a newby, so sorry if there are any stupid errors
Whenever I add shape hints to a shape tween the shape disappears in the between frames. I am using CS5 on Vista. I using files from [URL]to practice.
View 2 Repliesneed to draw the shape of a existing movieclip which is irregular shape.
View 2 Repliesneed to draw the shape of a existing movieclip which is irregular shape.
View 1 Replies