ActionScript 3.0 :: Control Stage With Custom Classes?
Jan 12, 2010
I am making a video player class that will be imported as a custom class into a fla (not document class). how i can add clips to the display object without having to return them from the class?
is there something like stage.addChild or root.addChild or something that i can use?
I have a CustomSimpleButton class and a CustomSprite class which creates a bunch of CustomSimpleButtons and displays them at runtime. How can I access other objects on the stage in Flash inside of my two custom classes? If I want an object tween to occur when one of my custom buttons is clicked how do i reference the object that I want to tween if I'm inside of my custom class.
I've created a base class to house some basic functions I'd like to have across several movie clips in a game I'm making, however, when I link a custom class to the same movie clip I get the message; "The base class will not be used because the class specified is already defined and extends its own subclass. If you wish to use the base class, specify a class name in the Class field that will be auto-generated or enter the default base class 'flash.display.MovieClip' in the Base Class field." I removed the 'extends MovieClip' inside the Class but it still shows the message. Does this mean that I cannot use a custom class and a custom base class on a movie clip?
I use multiple custom classes like tweenlite, csvparse, papervision and many more. The way I do is put them in one central location and edit Flash CS4 Actionscript 3.0 settings to include that location.The problem I face is even though I don't use all the classes in a project, flash CS4 compiles every single class that is in that central location eventually increasing my compile time by minutes.
Is there any way to get a list of custom classes? I'd like to be able to dynamically access the custom classes (that I've created by the "Export for Actionscript" checkbox in the "Linkage" dialog) without having to hard-code their names into the script.
I really like the fact that dynamic features are available in Flash, despite their slowness.With that said, is there any way to "auto detect" when a new property is being added to a dynamic class?I'd like something along these lines:
Code: public dynamic class Detector extends EventDispatcher {
[code]This is my document class, with the Textfields beeing placed on stage.While this all compiles and displays fine I do not get the trace output for the text fields, actually the only trace I get is "constructing". I tried it without the "each" keyword but to no avail as well.
I'm looking to extend Vector.<T>, but it's final, so I'm going to have to include it as a member instead.Regardless, I'd like to make the wrapper class type independant, so I was wondering what the snytax for template classes are.
i'm still in the process of grasping my move from AS2 to AS3 (or from timeline coding to external classes), and here's a problem i've run into.i have two classes, for the sake of easiness, call them Class1 and Class2.in frame 1, if i have
ActionScript Code: var c1:Class1 = new Class1(); var c2:Class2 = new Class2();
I'm trying to get a button to change color via a Custom class written in ActionScript. I have built and attached an example to show you all what I'm trying to achieve. The code works perfectly with a MovieClip, but when I try to apply it to a Button, it falls flat (can't even find the reference to the button it seems). On my stage are two objects:
1. A Movie Clip 2. A Button
These are both set to "Export for ActionScript", and have an attached class called 'ColorClass'. ColorClass is basically what does all the work (makes a Color object, and has set and get methods). I also have an action layer where all my other code is contained. I'm fairly new to ActionScript, but come from a Java background
im trying to port my code to as3 but i stumbled on a problem i have no idea how to fix. error report:
Code: verify PointAirFri$iinit() stack: scope: [global Object$ Point$ PointAirFri$] locals: PointAirFri Number Number Number 0:getlocal0 stack: PointAirFri scope: [global Object$ Point$ PointAirFri$] locals: PointAirFri Number Number Number 1:pushundefined stack: PointAirFri void? scope: [global Object$ Point$ PointAirFri$] locals: PointAirFri Number Number Number 2:setslot 14 stack: scope: [global Object$ Point$ PointAirFri$] locals: PointAirFri Number Number Number 4:abs_jump 78424138 45 stack: scope: [global Object$ Point$ PointAirFri$] locals: PointAirFri Number Number Number 0:getlocal0 stack: PointAirFri scope: [global Object$ Point$ PointAirFri$] locals: PointAirFri Number Number Number 1:pushscope stack: scope: [global Object$ Point$ PointAirFri$] PointAirFri locals: PointAirFri Number Number Number 2:getlocal0 stack: PointAirFri scope: [global Object$ Point$ PointAirFri$] PointAirFri locals: PointAirFri Number Number Number 3:constructsuper 0 VerifyError: Error #1063: Argument count mismatch on Point$iinit(). Expected 3, got 0. at PointAirFri$iinit() at docClass/::init() at docClass$iinit() this is how the defined the classes:
Code: package{ public class Point { vars public function verlet(a) { code } public function savePoint() {; code } public function restore() { code } public function Point(__x:Number, __y:Number, __fr:Number) { x = __x; y = __y; dx = 0; dy = 0; vx = 0; vy = 0; friction = __fr; } } }
package{ import Point; public class PointAirFri extends Point { private var airFriction; public override function verlet (a) { code } public function PointAirFri(__x:Number, __y:Number, __afr:Number) { x = __x; y = __y; dx = 0; dy = 0; vx = 0; vy = 0; airFriction=__afr; } } }
if anyone has any idea why that error happens please enlighten me
I have a few custom classes stored in AS files. Is it possible to have these classes imported another way from using the following method:
Code: import ClassFile;
I want to have the AS files loaded from a server (policy file created for inter-domain talk) into to flash. Also I want it to work, if a person downloads the main SWF and plays it on their compy,i want the class files to be loaded from [URL] and so on.
I've started to work with Actionscript 3.0 for a couple of weeks and I've just started my very first "top-to-bottom" AS3 project which I'll be delivering (a "demo") next Monday.However, some basic complications are arising and I just don't know what to do, this probably has been answered a lot of times but I can't seem to find a single blogpost/forum/website that addresses this issue in a way that I can understand instead of "copy/pasting" code.[code]Ok, when I press a button inside the NavBar class I want it to execute a function that tells the DocumentSetup generated MovieClip(contentLoader) to load in a different SWF based on the arguments passed on the Event.My questions are:
1 - How do I access a public function on a different class? Let's say I have my navFunction() placed on the DocumentSetup Class, do I need to create "another" instance of the DocumentSetup Class just to tell it to do something?
2 - Let's say you're able to explain to me how to solve the problem above.How can I reference a MovieClip generated by the DocumentClass through another Class? I need something to tell the contentLoader MovieClip to change contents, how do I communicate with it from another Class if the MovieClip was added to the DisplayList through code on the DocumentClass?
3 - How can I create a Variable which is identified throughout the website, let's say I have an XML file with all the text content that's going to fill in the content placeholder's. How do I make this XML data accessible from all classes instead of having to re-import the XML again and again?
My external classes all work 100% themselves but I cannot get them to communicate with each other, I keep getting compiler errors...A website in which you can't navigate to a different page is basically useless
I have a an array of a custom class that I'm trying to store in a SharedObject.Storing is working fine, but when I recall the SO next compile it only returns an array of generic Objects instead of my custom class. This only happens with custom classes.Code excerpt below, this may be way too cut out, but it seems it's what I've narrowed the problem down too.[code]
In developing (and learning) some OOP gallery class structures, I seem to hit a snag with the non-blocking nature of AS3.[code]However, I need to get these into a grid, and I have a grid class written that takes an array input. So, ideally I would push the i and v instances into the array, and have the grid class loop through and put them in a neat little block. However, I can't access the width and height of the img and vid class instances. I tried getters, and am thinking of having to do some custom events but I'd rather not. Surely there's something I'm missing?The closest thing I got, but it still triggered late, was an Event.ADDED in the img class.
So this is probably an easy thing I don't know, I'm hoping. But when I publish my project and test it in a normal HTML, the swf can find some classes but not others for some reason?
How can I make sure all the classes get compiled into the Swf? I got the main timeline calling the first class (CalypsoPlayer); and it finds this class find -- which is under the same class path. But CalypsoPlayer can't find the class it needs, even though it's under the same class path as the class.
I've tested the project in Flash itself and it all works great without any errors so I'm not sure what's going on. It's only when I test the published SWF that it can't find all the classes it needs.
I have two custom as3 classes, TriviaGame and TriviaQuestion, and I am attempting to retrieve a bitmap image stored in TriviaQuestion and have found it impossible thus far.
It seems the root of my problem is that bitmap is somehow null in my GetImage() function, even though it is class data that has been set earlier in ImageLoaded(). The only time I am able to access the bitmap's info (in order to add it to the display) is inside ImageLoaded().
In TriviaQuestion.as, loading the image: private function XMLLoadedHandler (e:Event):void { xml = new XML(e.target.data);
I have made a very simple custom class for keeping track of groups of offices for a company. The class has a Number variable to tell it how many different offices there are, and an Array to store the individual offices by name. It looks like this.
class officeCluster{ static var _className:String = "officeCluster"; // variables var numOffices:Number; var locationArray:Array = new Array(); // functions function officeCluster() { trace("officeCluster constructor"); }}
Now, it is my understand that when I create different instances of the class, they will each have their own version of "numOffices" and their own version of "locationArray". When I run traces of "numOffices", this seems to be true. For example, trace(manufacturingOfficeCluster.numOffices); trace(servicesOfficeCluster.numOffices); yields 5 4
In the output panel, which is correct. However, there is trouble with the locationArray. It seems that as I assign different values to it, regardless of what instance I specify, there is only ONE array- NOT one for each instance. In other words, trace(manufacturingOfficeCluster.locationArray[1].theLocation); // theLocation is a String. The locationArray itself holds Objects.trace(servicesOfficeCluster.locationArray[1].theLocation);
Is anyone aware of any issues partaining to using Arrays within Class instances? I've been able to work around this by creating multiple arrays within the class and using a different one for each instance, but this seems very sloppy.
I'm using a electronic device to dispatch events within AS3.
short explanation: -->
Think of these events as a KeyboardEvent.My point is to dispatch an Event (like a Key that is being pressed) so I can listen to this event on EVERY Class I need to.I'm not sure how to instantiate or listen to these events correctly =/
I mean: I want to be able to listen to the key that is been pressed as if that was a global event every Class can receive...
long explanation: --> I'm doing something like this:
1) created a (main) Class that extends a Sprite.
2) created a class (KeyboardInput) that extends the main class.
3) created a class (KeyMap) that extends EventDispatcher.
4) created a class (HomeScreen) that extends a Sprite.
My FLA file is associated to the KeyboardInput Class.This Class creates a listener for the KEY_DOWN KeyboardEvent and instantiate the KeyMap Class that dispatches a CustomEvent:
stage.addEventListener(KeyboardEvent.KEY_DOWN,function(evt:KeyboardEve nt):void { keymap = new KeyMap(); keymap.setKey(String.fromCharCode(e.charCode)) });[code].....
Incorrect number of arguments. Expected no more than 0.hen I try to:ar countries:Country = new Country(10);ormally this would work in Java or C++, so I'm not sure what's up!?Here is my custom class.
package { public class Country { var cName:String = "noName";
I was wondering if anyone knew how to create a .swc library file that could be used in Flash or Flex?I want to compile a custom package of classes into a .swc for use and download,
I need to build a preloader for a swf which size is about 3MB, I tryed and tryed giving up at the end to integrate a preloader in the swf itself because it shows up only when fully loaded, no way to fix this thing, looks like if you embed fonts there's no way to stream the swf for some reason. So a moved to another way, the classical , for me, one I wrote a simple, light swf which works as preloader and I load in it the big swf, the 3MB one. Every thing works, connection to the MySQL DB is ok, parameters are passed successfully to the Java scripts etc.. the fact is when it comes to the loading of custom classes crashes brutally, the errore code is #1009, whenever I declare an instance of a custom class in the AS3 of the 3MB SWF it crashes.[code]