ActionScript 3.0 :: Calling Package Constructor From Fla?
Jul 22, 2009I have an as3 package which looks like
package {
// imports
public class ColoredSquare extends Sprite {
[code]........
I have an as3 package which looks like
package {
// imports
public class ColoredSquare extends Sprite {
[code]........
I've read through the Sticky in ActionScript 3.0 forum and looked through other threads in the topic but maybe I'm not using the right search terms. My problem is creating a new object in the constructor method, I've created a package "com.weenz.shutters" and created many class files within that package. The compiler is giving me the following 2 errors for the "Window.as" file[code]...
View 3 Replieswhat i am trying to do is by pressing zero_btn which is an object in the library to print a number in the dynamic text box ( result_txt ) which is also an existing object in the library and on stage. my knowledge in actionscript is not much and messing with .as files is totally new to me! then thing is that this code when i locate into to .fla file works fine. there is no error with the code i posted, but am sure something is missing ... like calling the constructor of the .as file.In the library the name of it is Zero_btn and the instance name of this object is zero_btn and it is a button.[code]
View 11 RepliesI am new to AS3 but not to AS2. I have written a simple class and when I import it, I don't see the object that should be created upon calling the constructor. Can you guys tell me where am I going wrong. And I am very puzzled about 'document class'. Yes, I have google numerous threads on "document class" but still very shaky on this matter. Here is my simple class which should place a button object on the stage when I create a new object of this class. Once I have created the BTN class, I have made sure that I have button component in my library, I then instantiate the object by creating a new CS3 file and importing my class:
import com.learning.as3.*;
var b:BTN = new BTN();
When I test the movie, I get the following errors:
1172: Definition com.learning.as3 could not be found.
1046: Type was not found or was not a compile-time constant:
BTN.
1180: Call to a possibly undefined method BTN.
If a constructor takes its parameters as a vararg (...) it seems to be impossible to create a subclass that will just pass on that vararg to the superclass.
There is a related question with fix for this same situation for normal functions: Wrapping a Vararg Method in ActionScipt but I cannot get that to work with a super call.
base class:
public class Bla
{
public function Bla(...rest)
{
[Code]....
Aside from actually moving the handling of the parameters to the subclass or shifting it off to a separate initializer method
is it possible to get the name of a calling function or the constructor from the called function? is it possible to determine the previous function of the thread?
i would like to call some setter functions from my constructor and have my setter functions determine if it was the constructor that called them.
currently, i'm setting a boolean for this functionality, but perhaps there is another way?
public function Constructor(myNumber:Number)
{
this.myNumber = myNumber;
}
[Code]....
I have a document class name elevator and my constructor is also elevator as usualHow to call this constructor function within elevator class? Is is possible or not?
View 1 RepliesHow to create new class instance without calling constructor function, meanwhile constructor function must exist and is requiring 1 parameter.
var newclass:myclass = new myclass; <- still calls function myclass in myclass class
I would like to call constructor function later:
newclass.newclass(myparam);
How can I call class.functio from timeline?? with package name
package game {internal class carnode {
public function carnode() { function printtrace():void{ trace("Tesitng package
[code]....
Is it possible to create an instance of a class without triggering the class' constructor?[code]In the case above, say I wanted to play around with a Foo instance, but I really don't want my global.foobarCount going up, nor do i want to pass in any value at all for bar.This could be useful for introspection where you want to learn more about or pass a particular class object but don't want to provide required arguments or trigger anything that the constructor may do.Is this at all possible? (Obviously, new Foo() just doesn't cut it here, since it would throw and arguments error, nor does just using Foo, since that's a reference to the class itself).
View 2 RepliesI'm having a small problem with packing my classes at the moment.Here's my problem
Code:
map[1][1].addUnit(new Infantry);
map is an array of MapTiles which are a part of the "Map" package I've created. addUnit is a
[code]......
I've got a simple program that consist of a document class and a buttonTemplate constructor class. I need to call a function called updateText that should be in the document class, when someone clicks on a button. So that after each button is clicked, it updates some text in my document class. My event listeners for the buttons are in the buttonTemplate class. My question is, how do you call a function in the document class from a constructor class? Here is my simplified code below
DOCUMENT CLASS
Code:
package {
import flash.display.MovieClip;
import flash.text.TextField;
[Code].....
How do I call class constructor functions with indefinite number of arguments?
For example:(this piece of code doesnt serve any purpose, just to demonstrate an example)I wish to create a new class Foo with the parameters bar1, bar2, bar3, bar4.
[Code]...
I am having troubles passing an x and y argument into a package function that creates a projectile on stage at the tank.gun's x and y.I have attached a zip of the code I am working on.[code]
View 6 RepliesI'm running into this weird thing with ASDoc. It will only document one package function per package.For example.I have these two functions:
gs.util.printf
gs.util.ftrace
In these files:
gs/util/printf.as
gs/util/ftrace.as
The only function that get's documented in ASDocs is "printf". But I know it can do more than one. As an example, in the livedocs [URL] There are more than one functions documented.
I have an actionscript file,it has a package name,it locate C:demo directory,like follows:
package demo{
import flash.display.*;
public class ABC extends Sprite{[code]............
Then I compile above code like following command,but it raise following error:
C:>mxmlc demoABC.as
Loading configuration file C:sdkframeworksflex-config.xml
C:demoABC.as: Error: A file found in a source-path must have the same package structure '', as the definition's package, 'demo'.Where is wrong above command?
This is with Flexbuilder 3.2, Eclipse 3.3.2.I am moving my development environment to a new machine. Actionscript classes that compiled in the old environment now get a compile error:
A file found in a source-path must have an externally visible definition. If a definition in the file is meant to be externally visible, please put the definition in a package.I do declare the package in these classes - I think failure to declare the package is the usual reason for this error.To add to the mystery, many classes in this project compile without errors.
I have classes witch resides in this package :com.network.interface_as. When I try to load one class from that package in another class in the same package like this:
[Code]...
I'm getting stack overflow errors when I'm trying to publish() a NetStream after close()ing it. Pasted below is the error stack:[code]
View 1 RepliesI have a class. I can call the constructor (initialize the class), and the constructor can then call a function/method inside it's own class (so I know it works), but when I try to call the same function/method myself from the instance of the class I just initialized, I get an error.
View 3 RepliesYou can declare variables outside of the constructor in a class, so what is the point of a constructor in AS3?
[Code]...
I do know that you cannot call functions, however what is the purpose of the constructor when the code in the class is executed? Why not allow functions and make it simpler?
there is a better way to abbreviate the following code??[code]
View 7 RepliesI'm getting an error that says Method cannot be used as a constructor - and I can't seem to find what that means exactly.
Here's my code (the line that is getting the error should be in bold):
stop();
var currentAnimation = new mapIdle;
makePlay();
[Code]......
I am trying to things efficiently and put as little code as possible on the timeline.
I have a document class loading and working at runtime.
It creates a button that takes me to a different frame on the timeline.
I have a movie clip there. I put a trace in the constructor of the class of that movie clip but it will not show the trace comment in the output window-its not working. There are no errors.
I also tried instantiating the same movie clip from the document class-which worked-but the trace in it's class's constructor still does not output.
I'm having a problem with a .swf which when loaded into another .swf has its constructor function ignored
when i'm running local it works fine, but when theres a real loading the constructor doesnt run, also making timeline code ignored ( since timeline code is just addScript call in the clip constructor)
anyone else has had this problem?? same problem happens either using Loader class or BulkLoader, also happens when simulating download in the IDE
Is it possible to define 'public properties' of an object in the constructor method when you create the object ? similar to..
var leftmain_scrollertext = new TextField({length:10});
I have a TextField and I want to set its maxChars, x, y, width etc.
when I specify one or more of these I get... 1137: Incorrect number of arguments. Expected no more than 0.
am I forced to specify each property I want individually after I have constructed it ?
I have an object that has been added to the stage, exported properly for actionscript, and given an instance name.It's class file is this:
PHP Code: [code]....
And yet none of this works. The trace doesn't even go off, meaning the constructor is never activated. It's linked properly; if I go to the movie clip's preferences and hit "edit class file" it takes me to the proper one.It's possible that the problem lies with the frame numbering. The first time this object is added to the display list is in Frame 2...and it says "export in Frame 1" but I'm not exactly sure what that means or how it affects the class definition or how to get around it. I tried adding it (var sb:SoundButton = new SoundButton in the first frame,
I searched the forum, could not find questions like this so I hop this is the right forum.[code]...
how I should add this package to CS4?
I just downloaded the AIR SDK, I just don't know how to proceed. Some sites on the internet tells me to execute the
adt -package SIGNING_OPTIONS air_file app_xml [file_or_dir | -C dir file_or_dir | -e file dir ...] ...
command line, but I just don't know how to do it.
The application is already developed and ready to use, but I can't package it.
I am going through the book gameprogramming university and checked to make sure my code matched.
I am using 2 classes the main class attached to the timeline, and an airplane class that contains a symbol in the library with different frames.
the main class is
Code:
package {
import flash.display.*;
public class airraid extends MovieClip {
[Code].....
when i execute it i am getting the error:
1136: Incorrect number of arguments. Expected 0.
This is at line 7 where it is creating the airplane object.