ActionScript 2.0 :: Silent Failure With Class Properties?
Nov 26, 2007observe the following code:
Code:
class A{
private var canvas_mc:MovieClip
[code]....
observe the following code:
Code:
class A{
private var canvas_mc:MovieClip
[code]....
The following class I've coded fails to fade the MC on stage. Could someone explain why the code fails?
[Code]....
I'm having a fun little bug with the loadClip function of the MovieClipLoader class. I've passed it a valid MovieClip and a valid filename (verified by traces) and it still returns false. It never calls the listener object I created with a onLoadStart or onLoadError event.
Code:
import mx.events.EventDispatcher;
import mx.utils.Delegate;
class MultiSWFManager_MiniLoader {
public var dispatchEvent:Function;
public var addEventListener:Function;
public var removeEventListener:Function;
[Code] ......
It never calls onLoadStart (I figured it might be a scope issue, so I placed the function inline. Otherwise, I created private functions for each event.)
component, or any other method, which will enable silent printing of a PDF from a projector?
View 3 RepliesI need to use stage.width/height in my CustomClass so I found some topics about it.
if (stage)
{
init(ar,firma,kontakt,oferta,naglowek,tekst,dane);
[code]......
I have a class, call it MyClass, and there are several variables that I need to be able to access each instance of from within the class.So for instance, I need the object myObject1, a member of MyClass, to store the variable myNumber.From the main timeline, if I trace myObject1.myNumber, I get whatever number I've stored.
However, I need to check the numbers against another parameter, so I need to be able to test if myObject.myNumber == myOtherNumber. But from within the class, if I trace this.myNumber or myNumber I get null.What is the proper syntax for accessing a variable within a class?
I have an mc called sunny. In the properties panel I export her for actionscript. I put Sunny in the main class and Drag in the base class. The reason for this is that I want her to be draggable. I can't use Drag in the main class as another object is using that name. The Drag.as has the drag functionality. Why can't I drag her. I already have a solution - I wrote a specific class for her and extended the Drag class. However, if I have 10 mcs I'm not going to write specific classes for all of them. Summing up: Using the base class Drag in properties panel - why isn't she draggable?
View 7 RepliesI'm pretty new to fully using class's for my programming (in-frame scripting satisfied me for a while). I am having a problem accessing the properties of a class from another class. The first class (I'll call it controller) receives a reference to an object of another class (I'll call it display). Display have several specialized subclass (I'll call one SequencedDisplay). SequencedDisplay has a timer in it that I need to access:
[Code]...
i have created a Vehicle.as file and a Car.as file which are in the same project. The problem i am having is trying to use the properties in my Car.as from my Vehicle.as file.
[Code]...
When i type this line of code, _gasMileage = mpg; and build it i get the following error, C:UsersvistaDocumentsFlashDevelopProjectsVehi cleAppCar.as(20): col: 4 Error: Attempted access of inaccessible property _gasMileage through a reference with static type Car. Now i tried to add an import statement i.e import Vehicle but that did not work. How can i use the private attributes of my Vehicle class in my Car class appropriately?
I have two movie clips on the stage at frame 1 and frame 2. Both are instances of seperate classes. (They are not dynamically created, just their linkage is set to their class names)I have created soundChannel and Sound Objects in Class 1 and I want to access them from Class 2. (I want to stop the sound channel that was started in class 1)Is there any way to do this? If yes, will this be true for other properties also?
View 7 RepliesI've been working on a project in Flash CS3 for a while. To follow an object on the screen and keep it centered, I'd adjust the Document Class' x and y properties.
Yesterday I bought/installed Flash CS5 and thus Flash Player 10 was also installed. Now when I go play my SWF it seems everything is all buggy, as if the code that modifies the Document Class' x and y properties isn't exactly working properly...
I've since reopened the CS3 FLA in CS5 and converted it to a CS5 format and I can't seem to get it working the way it used to.
Did something change regarding the Document Class and how to modify the x / y properties of it in the Flash Player 10 version? I really don't know what's going on at this point.
I'm working in CS4. I am trying to add 20 squares to the stage. Each square must have a different number in the middle(1, 2, 3, etc.).
This is my code so far:
ActionScript Code:
package {
import flash.display.Sprite;
[Code]....
Ideally, I would like the squares to be added automatically, with increasing numbers and 100 x 100 pixels apart. Possibly a 'for-loop' statement?
I've heard it's considered best practice to keep all class properties private and to change them using getter and setter methods.
View 5 RepliesI have a class - call it MyClass - and an instance of that class with instance name myObject.In MyClass I declare:
public var myVariable:Number;
In the main timeline I try to set it using myObject.myVariable = 3;
In the main timeline, if I do a trace (myObject.myVariable) it will return 3. Within the class, if I do a trace of (this.myVariable) it returns null.However, if I add a line of code in my class and add this.myVariable = 3, it traces 3.Why can't I get myObject to correctly change its own parameters?
I've created a movie clip and placed it in the library. I've given it a class name via the properties panel in the library. Every time I drag it to stage I want to make sure its alpha is set to 0. If I drag 300 of those clips to stage, is there a way to reference the class name I gave it in order to automatically set the alpha value as soon as they're dragged into the stage?
View 2 Replieswhen I try to access a property of the document class from another class, I get an error:
Quote:
1119: Access of possibly undefined property _left through a reference with static type flash.displayisplayObject.
Maybe I'm not doing it correctly? This is how I've been accessing document class properties so far. Does the fact that they're private make a difference?
Quote:
root.property
I can't use a "for in " loop to enumerate public properties of a custom class. So I have a class "ClassA" , which has some public properties. if I try :
PHP Code:
trace(classInstace.hasOwnProperty('property1'));// true
trace(classInstace.property1) // traces the property correctly
trace(classInstance.propertyIsEnumerable('property1')); // traces false ????
I'm currently working on an interactive app, (site) which requires me to modify a few textfields, and change images dependant on the user choice (using mouseevent). This is a separate module, thus I'm posting the question in here instead:there are three images, that are lined up, with a textbox next to them. When a image is chosen, and enlarges, the text changes with the chosen image, according to XML.The textFields, 'text_title', 'text_description' are contained in a movieclip, called 'textbox'.This has been built in the Flash IDE (CS3) named info.fla/swf, which refers to a Document class 'com.info', made in Flex Builder 3...I attempted to modify the textfields using this:textbox.txt_title.text = "Loading";textbox.txt_desc.text = "test";But, I was unable to at first to change the text using the document class, as it gives "1120: Access of undefined property <variable>".
View 3 RepliesI'm just starting to learn about classes in actionscript, I am following along with Moocks book Actionscript for Flash MX and are trying to execute a trace on the properties of my ballclass but all I get is undefined. He is what I have in my actions panel.[code]
View 5 Repliesim having trouble figuring out how to script a tween in AS3 with multiple properties. I have the single property syntax down, like such, import fl.transitions.Tween;import fl.transitions.TweenEvent;import fl.transitions.easing.*;var name:Tween = new Tween( gar, "x", Regular.easeInOut, 60, 300 , 3, true);
but if I want multiple properties, im having trouble finding that info.
I'm new to as3 and I was trying to make my own slider for a while until I found the slider component. The slider component is so perfect for what I want to accomplish. But the size of the little graphics is ridiculous. If you click on the line that the slider knob is on top of the knob will snap to where you click. This is great but with only 3 pixels of height to click on it's pretty much useless. I tried going into the slider movie clip and altering the individual graphics but when I run the program the sizes are back to their teenie tiny size.
View 1 RepliesHow can i list all the names (and values) of public (and private / protected) const defined in a class ?
[code]...
If I've already specified in the symbol's package which class the symbol's class extends, do I still need to specify the base class in the symbol properties dialog?
View 2 RepliesI am trying to access the x and y properties of the stage so I can set an objects' x and y properties to place it on the center of the stage:
this.x=stage.stageWidth/2;
this.y=stage.stageHeight/2;
The call to instantiate the object(*.fla):
[code]......
I am trying to use "maxPauseBufferTime" property in NetStream class.I am using Adobe Flash Pro CS3. I have defined an object by the name nsStream of NetStream class. When I write nsStream and put a dot next to nsStream it shows me a drop down list of the properties of NetStream. However it doesn't show me maxPauseBufferTime property. I also tried the same with Adobe Flash Pro CS5. Even there the drop down list for nsStream doesnt show me the maxPauseBufferTime property.The adobe help page (first link that shows up when I google for as3 NetStream. Forum rules doesn't allow me to post the link here) indicates that this property is part of NetStream class.
View 3 RepliesI am trying to access a property that belongs to the stage, from a class. For example, let's say I add a textfield with an instance name of "magic_txt" on the stage. In the Document Class, I am able to access magic_txt and update the field like so:
magic_txt.text = "Magic Text"
However, since I would like to work in classes, I am having a difficult time figuring out how to access the property "magic_txt.text" from a class. I know I need a reference, but I am unsure how to set this reference.
I am coming from a strong background in Visual Basic, and in Visual Basic, the way to access a form property is to call the form name (dot) object. In actionscript, it doesn't seem to be as simple.
Steps:
1)I have created One movieClip & named as MyComp
2)I export this movieclip to actionscript.Class name for this movieclip is MyComp.
3)After that,Dynamically I have created 5 instance for this class & added to stage.
4)Now i need to change width of MyComp. it should reflect on previous 5 instance too.
I tried like, I have created MyComp.as file in same location. There I tried to inherite DisplayObject properties Width.
If I create a class and set up one property which is a variable initiated at the start of the class but not within a function or a constructor and I reference the property from the .fla in a for loop as:Book is the class and myBook is the new object.
myBook:Book = new Book(); // (fla script).
for(var prop in myBook) {
trace(prop);
}
[code]...
The trace does not return anything. However when I include myProp (the class variable) in a function (other than Book function) and call that function from the .fla then the trace works and I can see myProp. Do I need to include Class variables in called functions (methods of the Class) in order for them to be properties of the Class?
I'm having a little trouble with the properties of an instance of a specific class. Here's and example of the code I am using:
Code:
package {
import flash.display.MovieClip;
import flash.events.*;
public dynamic class Circle1 extends MovieClip {
private var _root:Object;
[Code] .....
This is in the class code for Circle1. Now here is the error that is being displayed int he Output Box when I try to run the file:
Code:
TypeError: Error #1010: A term is undefined and has no properties.
at Circle1/eFrame()
Here's the code that creates the two class instances as children on the Main Time Line:
Code:
if (spaceDown) {
var newCircle1:Circle1=new Circle1();
addChild(newCircle1);
} if (enterDown) {
var newCircle2:Circle2=new Circle2();
addChild(newCircle2);
}
EnterDown is a defined variable for the key press of Enter, and spaceDown is a defined variable for the key press of Space.
I'm trying to find all the class properties for the tween class. I know of:
[Code]....
are there more? Is there a listing somewhere on the web that has this information?