ActionScript 2.0 :: Where Class Functions Are Defined
Apr 19, 2005Can anybody tell where the class functions are defined?[code]
View 1 RepliesCan anybody tell where the class functions are defined?[code]
View 1 Replieswhere the class functions are defined?
e.g. the function function toUpperCase():String; in
C:Documents and SettingsuserIdLocal SettingsApplication DataMacromediaFlash MX 2004enConfigurationClassesString.as
I am using flex builder 3.2, Action Script 3 and develop for Flash Player 10 and am quite new to it. when I call a method of a self defined class, I get the 1061 error (not defined). But the class and the method exist and are public, so what the hell am I doing wrong? Flash Builder is even offering me this method in the auto-completion, so at least the builder knows it... I have already tried cleaning the project (as this is the common source of strange errors when working with java/eclipse),
edit: solved... The problem was that a package had the same name as the variable I used for the class. Very strange error message, thumbs down for this .
Trying to find the best way to use the xDoc variable in the newImg function without adding the newImg eventListener to the xmlLoaded function
var myXML:XML;
var xDoc:XMLDocument;
var xmlLoader:URLLoader = new URLLoader();
[code].....
I don't understand why within my function, initially the status of stage.scaleMode via a trace() is NO_SCALE, then it becomes SHOW_ALL. The code below is found at three different location in my overall code.
stage.scaleMode = StageScaleMode.NO_SCALE; backgroundPositioning(myStage.stageWidth, myStage.stageHeight); stage.scaleMode = StageScaleMode.SHOW_ALL;
wrote the code for motion straight into the action panel of the bubble symbol and simply duplicated the symbol alot to add more bubbles. What I wanted to do is change all that code into global functions that can simply be called by each movie clip thereby cleaning it up alot and making it more modifyable. The problem is that I can't figure out how to write and call the functions properly. Here is what I have:
Layers:
Actions: where the functions are defined
Bubble: contains symbols (clip calling the functions)
[code].....
I have two classes. The Main class calls a function, which is defined in a Second class.I'm getting the following error:Error 1120: Access of undefined property myFunctionBasically, I am creating buttons in the Main class that will add a corresponding Child to an Object in the Second class (if you click one button, child x1 will be added, if you click another button, child x2 will be added, and so forth).Here's the relevant code for the Main.as file:
package
{
import flash.display.MovieClip;
[code].....
I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem to be working for me.[code]
View 1 RepliesI've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem to be working for me
package jab.enemy
{
import flash.display.MovieClip;
[code].....
I have two SWF files loader.swf and external.swf, external.swf is sitting on a remote server and I load it up from loader.swf using MovieClipLoader. external.swf includes a class definition for SomeClass by including a .as file, which also sits on the remote server. External.swf defines a method that returns an instance of SomeClass.
Once I've loaded up external.swf via loader.swf I can call the function that returns an instance of SomeClass. The problem is that laoder.swf seems to require a local copy of the as fiel that defines the class, rather than being able to receive the information it needs from external.swf, I really need to keep this class definition on the remote server, and not have a copy of it locally. Is thre any way I can encapsulate this within external.swf? I'm free to cahnge whatever I like.
How can i list all the names (and values) of public (and private / protected) const defined in a class ?
[code]...
I 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?
I have a class that contains a MovieClip and a String.In my library there are 3 exported MovieClips: Movie1, Movie2, Movie3.I want to define 3 variables of this class and each with a different MovieClip and String.[code]...
View 5 RepliesI have a very simple class[code]...
when I click I get "undefined"
How do I get at references that are defined within a class when I am on the timeline
I'm trying to set the height of a vertical bar (activityBar) but it does not appear to do anything. i have tried something similar with the whole component, but setting the dimensions does nothing (even in the mxml used to instantiate the class). Indeed, I've added transparent graphics just to give the component some dimensions
FYI: I'm trying to create a mic activity bar that will respond to the mic by simply setting the height of the activityBar child (which seems to me to be more efficient than redrawing the graphics each time).
package components {
import mx.core.UIComponent;
public class MicActivityBar extends UIComponent {
public var activityBar:UIComponent;
[code]....
I've got a string which, in run-time, contains the name of a class that I want to instantiate. I read suggestions to use
flash.utils.getDefinitionByName():
var myClass:Class = getDefinitionByName("package.className") as Class;
var myInstance:* = new myClass();
However, that gives me the following error:
[Fault] exception, information=ReferenceError: Error #1065: Variable className is not defined.
This is quite strange to me since the MouseCursor class is being used as static.
Mouse.cursor = MouseCursor.BUTTON;
This is what I am using the MouseCursor class as and hence it is static. We got this error posted by a customer and the customer has also attached a screenshot of the error.
ReferenceError: Error #1065: Variable flash.ui::MouseCursor is not defined
I first assumed that this could be perhaps because he was running an older version of Flash Player ( older than v10 ). But his screenshot clearly shows that it is running version 10 of the flash player.
I have defined some sprites in a class .as file and I want to put them in the screen. How can I do this?
View 2 RepliesIve got a flash file linking to a FMS, its just going to be a little game, all connects fine and I have a chat client working through this. My problem is when i come to use classes to import movieclips ect...
When i set the main Class name in the properties menu and play the swf, NetStatusEvent and SyncEvent are give me the following error...
1046: Type was not found or was not a compile-time constant
If i remove the main Class name the swf connects to the server fine, or if i remove the code for the connection to the server and play the swf my movieclip attaches and behaves as the class files intended.
i may be doing a fundamental error here but i really cant see it and its annoying with the 2 aspects running independently but not together.
Code:
class className () {
//constructor
function className(targetmc,linkId) {
[code]....
My question is how can I set up an interval when I click on a button that is created from within the class.
I need my function updater to keep repeating untill I clear the interval.The only way I can figure out is to give the full path like this._parent._parent.instanceName.updater inside the setInterval, but although this works I think is just dumb to hardcode the instace name of the class. I could of course try to pass the instance name as a parameter, but I would really love to find out the smart way to do this (by the book).
I have been trying to migrate a CS3 based Flash project to the new CS4 IDE for some days, but it has been impossible. All the conponents of the library throw the same error at building time:
ReferenceError: Error #1065: Variable <Class> is not defined.I have changed the name of all clases with the same name as
the package,
I have also changed the name of the main class.I have created a new empty .fla to copy and paste all the elements of the library,BUT I DO NOT STILL GET TO SOLVE THE PROBLEM.
When coding in the Flash IDE, i very often use the following procedure to create specialized versions of MovieClip classes:I design my object in the IDE, for example, i add two buttons and give them the instance names "btn1" and "btn2". Then i select them together and convert them to a symbol. I then select Export for ActionScript and give them a classname, let's say "MyClass".Then I go and write a specialized MyClass.as for it, like this:
public class MyClass extends MovieClip{
private var _button1:Button;
private var _button2:Button;
[code]....
(ps: i know that i wouldn't have to assign the values to the private variables _button1 and _button2 and instead could directly make calls to btn1, but I like to use only Typesafe variables in my code)
This works very well in Flash IDE. when I create a new instance of MyClass() it will contain all the elements that i positioned in the Flash IDE when defining the Symbol. This is very convenient and straight forward.
Now I want to do the same in FlashBuilder.For this i designed the MyClass Symbol as before in Flash IDE, gave it the classname MyClass and then select the library symbol and export it to MyClass.SWC
In Flash Builder i add MyClass.SWC to the buildpath and I write a MyClass.as with the same code as in the Flash IDE example. but this time, the code won't work. on
_button1 = this["btn1"];
i will get an Error #1069 stating that "btn1" was not defined.So - how to do this properly if developing with Flash Builder? PS: i use the default package in Flash IDE when setting the Classname for the symbol as well as in FlashBuilder for the as file.
Why I am losing scope on an array that i define as a private member in a class? I am able to access it from a couple of different functions but in one place inparticular it keeps coming up "undefined". What causes scope to be lost in a function for an array that is defined as a private class member?
View 4 RepliesI'm wondering if anyone has experience with if there is a big difference in performance in ActionScript 3 between keeping a class with only public static functions, and utilizing those functions often (as in a frame event at 30fps), and in turning the class into a "normal" class of which I instead make an instance and call the functions via the instance instead.
View 1 RepliesI realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it
Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function
[code].....
I have a class file defined in my package as MyGlobals.as.[code] (I have tried adding/removing "static" and "dynamic" to no effect.)I am trying to call a touch event from the main timeline in this way:myObject.addEventListener(TouchEvent.TOUCH_BEGIN, MyGlobals.myFunctionName);(I have tried removing the class name to no effect.)When I compile I get the error 1046: Type was not found or was not a compile-time constant: TouchEvent. This error occurs on function definitions in the class file.What syntax/concept am I getting wrong? The functions were working fine when I was using constants in the timeline, but I need to be able to reuse these functions over and over again, so I wanted them to be able to take touch event variables so that I didn't have to write a different function for every touch event.I tried googling "error 1046" but I can't find anything useful.
View 3 RepliesI want to make a little game. What I need is to add event listeners to all of Tank objects inside the Battlefield instance. I just can seem to figure out how.
View 1 RepliesMain is my doccument class . how can i call Main.Caller
package { import flash.display.Sprite; import flash.events.Event;
public class Main extends Sprite {
public function Main():void { if (stage) init(); else
[Code]....
I have a label component in a mxml file like below
<mx:Label x="700" y="409" text="Label" id="lble" width="131" height="41"/>
if i want to access it and change its text content within a method defined in action script class that i have written, how to do it?
lble.text="test";
I am trying to use the CSVLib from [URL].. However; when trying to use one of the examples I get an "1180: Call to a possibly undefined method addFrameScript."This is what I did.Extracted the files, then moved all FLA, AS and CSV files in the root (where also the COM folder resides). Then added the import statement to the Applicaiton file and defined document class.
View 2 Replies