ActionScript 3.0 :: Create A Property For Class That Extends MovieClip?
Dec 23, 2009I'm beginning to learn AS3. I'm getting the following error[code]...
View 5 RepliesI'm beginning to learn AS3. I'm getting the following error[code]...
View 5 RepliesI am new to AS3, as well as Flash in general, so forgive me if this seems highly elementary. All I am trying to do is create a custom class that extends the MovieClip class and contains a custom property of "marker". I want to be able to use and change the value of this custom property on the timeline for an instance of this class and have it behave just like any other (Ex: this.x ==> this.marker).
[Code].....
googled it and hardly found any answer(seriously)need a quick solution for this:- How to create object from class that extends MovieClipSay i have a class name MC
Code:
package {
import flash.display.MovieClip;
[code].....
i came across this problem and i have no clue why it's happening. basically, consider 2 nested movieclips on the stage, something like stage -> main -> filler. both movieclips have instance names (main and filler).
[Code].....
this throws an error 1119: Access of possibly undefined property filler through a reference with static type A. can anyone give me a hint on that, as it works with class A, but not B extending A? i understand it was meant to work?
How do I create a class that extends the String class?
Lets say I've created an 'exString' class that extends String.
In my project file I do the following
Code:
var test:exString = new exString();
test = "Hello World";
text.someExStringFunction();
I get a type mismatch in my "Hello World" assignment because Flash sees it as a String and not as an exString.
If I have a Document class that extends MovieClip, and I want to use it as the basis for another Document class, is it possible to create a subclass that extends the main document class and use that for a different FLA?
For example,
fla1.fla has a document class of MyMainClass:
public class MyMainClass extends MovieClip
fla2.fla has a document class of MySubClass:
public class MySubClass extends MyMainClass
I've tried, but now I'm getting errors that all of my variables that reference stage instances aren't being found.
I am trying to create an AS 3 class that extends DopDownList (Spark) but behaves differently than your classic DropDownList. The difference is that when a user selects an item from the list, he cannot just click on the item. The user must "mouse-down" on the item, drag it over to the right, then "mouse-up" and then the item will be selected. The purpose of this is to act like a safety feature so the user doesn't select the wrong item. I am new to AS 3 and I am stuck on how to do this. I've been playing around with different events and methods for the last few days, but to no avail. If anyone could give me an idea on how to implement.
View 0 RepliesIf I can create dynamic variables on a MovieClip.. why would I not be able to create dynamic variables on a class that extends MovieClip?
[Code]...
I created from a mc symbol in the library. it works fine, except for adding the custom variable.. .. which I need to be able to do.
i'm trying to cast a MovieClip to a custom Class that extends MovieClip called MovieClipExt
ActionScript Code:
package {
import flash.display.MovieClip;
[Code]....
...but sadly returns null instead of a MovieClip converted to MovieClipExt
what should i change to make this work?
I'm having an issue using a class I've created as the base class for library symbols: I've created a class AvSkin which will act as the display for an instance of AvChild. It looks like this:
package avian.environment.skins
{
import flash.display.DisplayObject;[code]....
Is there a way around this? I don't want to do either of the following:
Make AvSkin extend MovieClip.
Create a class for my library symbol that extends AvSkin.
in human.as:
class human extends MovieClip {
function onEnterFrame() {
_x += 10;
}
[code]....
in my fla:
Object.registerClass(skin1, human);
_root.attachMovie("skin1", "User1", 1);
so i have an attached movieclip on _root now, i can see it but the onEnterFrame function doesn't work. Why??
Is there any way to get the name of the MovieClip that a class extends?Lets say I have an MC on stage called boxMC exported for AS using a class box which extends MovieClip.If I trace (this) within my class I will get the name of the class, if I trace (parent) I will get the name of the main MovieClip that boxMC sits within. So how can I target boxMC?Basically I want to be able to return the name of the MovieClip that the class is extending
View 2 RepliesI was just wondering if there is any easy way to extend the MovieClip class itself, without making a new class? I'd like it to be equivalent to using MovieClip.prototype ... or should I just use prototype?
View 5 RepliesI'm working on a Flash Lite 3.0 application using AS2 and I've created a class that extends MovieClip. The problem is that I'd like to dynamically add Child Movieclips using the addChild method... but it doesn't work, it gives me the following compiler error: "There is no method with the name 'addChild'". But I can call other MovieClip specific methods such as this.getNextHighestDepth()
heres a reduced version of my class:
class com.sck.DragList extends MovieClip {
//Declarations
private var placeHolder:MovieClip;
private var listMask:MovieClip;
[Code]......
I am having trouble using inheritance, I made a class called newchars_2 that extends my class newchars and i get this error (newchars class extends movieclip):
1203: No default constructor found in baseclass newchars.
newchars_2.as:
package {
public class newchars_2 extends newchars {
private var obj_no = 3;
public function newchars_2() {
//contructor class
}}}
And when I want to import this class do I import both the class's or just newchars_2 because it has all the functions inherited?
I need to make an item draggable (dragable?) Sorry if my terminology is not right!I have a class where I will store variable and do calculations:
package Classes
{
import flash.display.*;
[code].....
I have a class called Player that extends Movieclip? Why wont my code to attach a movie clip work?
Code:
import GAME_CLASSES.*;
Player1 = new Player()
Player1.setName("BobZdog")
Player1.attachMovie( "MainChar" , "Character1", 75)
Player1._x = 100
Player1._y = 100
[Code] .....
I've built a class which extends MovieClip an works ok. In this class i'm creating some MCs.and this part works ok.Before i've built some prototypes which adds some methods to the MovieClip object I'd like to use these methods in the class i've created.
But using the include before the class statement throws an error during compile
How can i do to add the methods in the prototypes to my MCs in my class?
I've got a class (say ButtonBase) that extends MovieClip. ButtonBase has a method that names it ((this.)name = 'bb1') and adds it to the MainTimeline. Now I can see my extended ButtonBase MC on the MainTimeline. And if from a frame I write trace(this['bb1']), it returns an instance. The problem is that the instance is not recognized as an instance of ButtonBase. Suppose ButtonBase has another method, say testMethod(). Well, if I trace(this['bb1'].testMethod) from a frame on the mainTimeline, it returns undefined. If I trace(this['bb1'] is ButtonBase), > false I can attach a fla if you need it.
View 3 RepliesI've recently started using the cache as bitmap switch on my on-stage movieclips, to great success, while creating my isometric RPG. What I can't grasp though, is how to apply it to AS-instantiated classes/object.How can I turn on cacheAsBitmap inside a class that extends movieclip? Alternatively, how can I do it from outside the class, from another class that adds mentioned movieclip to the stage?
View 1 RepliesI created a movieclip symbol and exported to actionscript, I created the .as file:
class BRIQUE extends MovieClip
{
function BRIQUE()
{
[Code].....
"graphics" is an image imported on the stage inside my symbol, but it seems not to be accessible this way (I get an error), nevertheless it works this way in as3 then what is the right way in as2 ?
What I've done is I have an existing fla file I'm using on line, which I want to use a document class, something I've never done. The as file I have (using Alternativa 3D 7.8) extends movieclip - here's the basic structure:
package {
import alternativa.engine3d.containers.ConflictContainer;
import alternativa.engine3d.core.Camera3D;
import alternativa.engine3d.core.View; etc.
public class test5 extends MovieClip {
private var container:ConflictContainer;
private var cam:Camera3D; etc.
public function test5() {
// constructor code
}}}
The thing is, it works fine when I use a blank fla (class named test5) but when I apply it to my existing fla - which uses a a mile of actionscript - all of my dynamic images dissappear and I'm left with the image from my as file (test5).
I followed the example from a previous question and I am loading an external swf using a loader and inside the loader event handler I am trying to cast the loader.content as my custom class PanelReferenceClip which extends MovieClip
When I publish I receive a this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Just to make sure and test that the swf location was correct and the swf was actually being loaded, I changed the type of the content to as MovieClip and it worked fine.
EDIT: I also wanted to add that these swfs are being stored locally and not being pulled across the internet, multiple networks or servers.
I am not sure if I did something quirky in my class so I am providing the source to my custom class PanelReferenceClip
package com.components
{
import com.UI.DevicePanel;
import flash.display.MovieClip;
[Code]....
I'm not really asking how. What I'm asking is, is it possible? And I ask because I thought it was not - certainly it didn't work in AS2 - and yet that's what I appear to have done. Am I going crazy? Structure: A SWF (#1) with a class NewActivity that extends class AActivity. Another SWF (#2) with a shared library of code in it, including AActivity. A third SWF (#3) which loads the library followed by SWF#1. Here's what happened: I didn't expect AActivity to be able to be shared. I mean, it should be compiled no matter what in SWF#1, as SWF#1 includes a class that extends AActivity. I had added some properties to the AActivity class, ran the project, and when SWF#3 tried to set those properties I was told they couldn't be applied. "Of course", I said, "I need to recompile SWF#1, because the code is now out of date. The version of the class there doesn't include these new properties.".
However, that didn't work. I got the same problem. Maybe, I thought, there's a definition conflict between SWF#1 and the library, so I removed the AActivity class from the shared library in SWF#2 for the time being. Only SWF#1 uses it, and it should already be compiled into SWF#1 as, like I said, it is extended by another class there. But when I ran the project, I was then told that the AActivity class could not be found at all! Looking at SWF#1 in a decompiler, there is in fact no mention of AActivity (I had up to this point assumed it was implied). So this left just one option: I needed to recompile the library in the first place, not SWF#1. I added AActivity back to the library, recompiled, and it worked.
To check I wasn't going crazy: I added a test property to the AActivity class and recompiled the library. The containing project - SWF#3 - then set this property on SWF#1, which had NOT been recompiled, and then read it back out. No errors. I should point out that the getting/setting of this property is done through an IActivity interface - AActivity is not being accidentally compiled into the main project (SWF#3), and the decompiler indicates this also. Am I going nuts? I really didn't think having a runtime shared super class was possible in any way. If it is, that opens up a whole new world of awesome, even though I've created this project on the basis of that being impossible.
I'm trying to load a RSL library into a flash animation developed with Flash CS5 IDE, that extends a custom class and implements an interface. I have reduced the problem to the simplest setup and find that I can have my main class extend another class or implement an interface, but not do both at the same time if I want to load an RSL.I have a very simple class to extend:
import flash.display.Sprite;
public class MySprite extends Sprite
{[ code]...........
but if I want both I get the VerifyError: Error #1014 with MySprite not found and ReferenceError: Error #1065.
I want to create a movieclip class that subclasses another movieclip class and inherits all its properties (rather than having to rely on the include statement). In my project I'm using:An abstract parent class that extends a movieClip: "infantryDroid".[code]However everytime I try this, flash acts as though nothing was imported from the parent movieclip class.If I was to try the above code I would get the message that _root and speed (which were defined in the parent class) "are undefined".
View 6 RepliesI want to create a complete (and real) 2-dimensional array. In order to use a maximum of Adobe code, I want to use ListCollectionView which can manage sort and filters. But to use a second dimension, I need to override getProperty method, like following code.
[Code]...
In AS3, I'm trying to check whether an object is an instance of, or extends a particular class. Using something like if (object is ClassName) works fine if the object is an instance of ClassName but not if it's an instance of a class that extends ClassName.
Pseudo-code example:
class Foo {}
class Bar extends Foo {}
var object = new Bar();
[Code]....
I'm not sure if it's possible, but can you override a variable of a parent class like you can override a function? I'm trying to create my own event class that can handle the target property. I have a custom imageLoader class, but when it dispatches it's loading complete event:
ActionScript Code: dispatch(new Event("load_complete")); and a listener picks it up, e.target = null where I would like e.target to equal the imageLoader instance that has finished loading.
Does anyone have an answer or a better way to accomplish what I am aiming for?
I'm programming a kind of "Lights Off" game in Flash Professional (not Flash/Flex Builder)and it would be very nice if I could manage on/off state in a grphically designed Symbol like this[code]...
View 2 Replies