I'm trying to create a class that acts just as an normal textfield, same properties and all, but that also draws a background filled with a gradient behind the text. I'm not focusing on the gradient yet , just trying to figure out how to assemble the code... Is this the right approach?
I'm new to AS3 and I'm trying to load a data from a XML file ("AppData") and set the data (text) in a dynamic text field("Label") on the stage. For accessing and manipulating the XML file ,I have an external as file with a class called "DataClass". And I running scripts in project frame to access the data from XML in the class "DataClass" to set it in the text field.
I 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
I have created a class, call it Class1, that has various objects drawn on the stage (drawn in the IDE). It also has a function, called setColour, for changing the colour of those objects. The function works fine if I call it from within Class1.
Now I have another class, call it testClass1, that imports Class1 and calls the setColour function. First of all, none of the stage objects from Class1 are visible. Secondly, when setColour tries to modify the colour of an object, I get the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
I've been trying to change the text within a SimpleButton instance using this:
var drawButton:SimpleButton = main.drawButton; var upButton:DisplayObjectContainer = drawButton.upState as DisplayObjectContainer; var upButtonText:TextField = upButton.getChildAt(1) as TextField;
I have a video gallery that generates a menu from xml.I first create a container then add textfields as menu items to the container I have listeners for mouse OVER on OFF for each menu item as welll as a function to change the text color ON CLICK.What I need to do is figure out how to switch a previously clicked menu item's text color back to "OFF" color when a new menu item is clicked But I Can not figure out how to traverse the display heiracrhy to get to the textField's color in all the other menu items.
heres the function:
ActionScript Code: //create Moviclip to hold menu function createMenuContainer():void {
[code]....
so the video menu item's heirachy is some thing like
but of course this does not work. I think my logic is reasonably sound I just not sure of the correct syntax to get at the textField.textColor of all the other menu items that ARE NOT clicked on the Mouse Click Event of a menu item that is clicked.
I have a movie clip which animates out and then places an input textfield on the last frame for the user to type in to. The main movie clip is controlled from external ActionScript. Once the last frame hits and the input field shows I want to focus the users cursor with focus(); but I can't figure out how to call to that TextInput from the time line. mytext.focus(); ???
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]
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
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 can't find a way to directly access a MC (or textfield, etc) on the timeline from a Class loaded into my Document Class. No problem from the Doc Class, but can't do it directly from the loaded Class. Is there a trick to essentiall extend the Doc Class AS from another external class?
I'm being really dumb today and I know this should be simple.....How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width? So I've written.....
ActionScript Code: var myTweenX:Tween = new Tween(this, "x", Regular.easeOut, this.x, stage.stageWidth, 60, true);
instance is a public static variable on the default class, Main. I can do Main.instance.defaultClassFunction() with no problems at all, I use it to access functions and variables from within other classes. Is it possible to use this method to call a function on the subclass, currently I have to do this,
I'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:
I have a dynamic textfield in a libraried movieclip.
I referred to the movieclip from an external class and have the linkage setup for it.
However, no matter what I try to do to instanciate the text field inside it, I keep getting:
Error #1010: A term is undefined and has no properties.
Now I really want to have this dynamic textfield inside the movieclip because it's part of a preloader so I don't just want to addChild to the stage. So Now I think I can't just build it.
I've been working on this all afternoon long and can't seem to shake this error.
I'm trying to create a background for a textfield like this: When I access the textWidth property it always seems to be the total width. Which is fine for all the lines expect the last. So it possible to access the width of the last line text?
TextField objects have a built in context menu containing items which target cut, copy, paste, delete and select all events.i would like to map keyboard keys and modifiers to these events to obtain their free functionality.
I've created several textFields, writing: ActionScript Code: for(i=0;i<=10;i++){ this.createTextField("texto"+i,i+1,100,100,100,100); }; That's O.K. But I can't put a text in them... when I write ActionScript Code: for(i=0;i<=10;i++){ ["texto"+i].text = 15; }; It simply doesn't work!
In my main swf I load preloader swf that contains two layers on time line. First layer is gradient shape and second layer is dynamic text field with instance name preloaderTxt that I am trying to access. Well I load it with success and in event complete I have this code: Code: preloader = new Sprite(); preloader = Sprite(loader.content); preloaderHolder = new Sprite(); stage.addChild(preloaderHolder); preloaderHolder.addChild(preloader);
I tried this: trace(preloader.getChildAt(1)); trace(preloader.getChildAt(1).name); First trace is: [object TextField] Second trace is: preloaderTxt
But when I try to set its text property like this: Code: preloader.getChildAt(1).text = "test" i get this error: 1119: Access of possibly undefined property text through a reference with static type Code: flash.display:DisplayObject.
How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width?[code]
I have created a movieclip in the library and added a class to it. I want to access a function and set an Array in that class from the document class...Heres what im doing now which is not working... it says startnow function is undefined.
PHP Code: package comimport flash.display.*; import flash.events.*; import com.NavMC public class Capability extends MovieClip Constants: //
Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.
I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().
I hate to be defiant, but what if I don't want to?
Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?
It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.
That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.
HERE ARE THE STEPS I'M TRYING:
- Create new flash document
- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage
- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()
- Set a name for that box using box.name = "test" let's say
- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great
- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";
That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?
I'm just now learning the new object oriented way of scripting. It's been a wild ride, but I've finally learned how to keep script off my frames (very hard coming from as2).Here's my problem:
I have a TextField on the stage in my main .fla file named loadPercent.
I'm loading a jpg with preLoad.as and displaying the bytes loaded in loadPercent.
I can access my loadPercent TextField from my MainClass
I get three '#1120 access of undefined propery' errors for each time i try to access loadPercent.
a few basic questions: 1. all my files are in a folder in my documents, not in the flash directory, is this bad? I've seen people using com.whatever etc.
2. my main .fla file does not share the same name as my MainClass.as (it's not named MainClass.fla) Is that a problem?
I'm assuming these are inconsequential because my code seems to work up to a certain point.
I'm trying to write a class that somehow emulates the old AS2 gotoAndPlay(); function, but i'm failing to find a way to reference the timeline that is calling the Class Constructor.
this is what i am using to call the class, i'm placing this code in the frame of the timeline i want to control. but it always gives me a null error.
I Know senocular adressed the timeline issues in one of this forum's post, but i can't figure out what to do in order to register this class in the specific timeline in order to control it.
why can i access the first function in a class with
PHP Code:
import test.test var test:test = new test();
but I cannot access the second or third function in the same manner? they seem to be seperte entities within the class definition.
can access
PHP Code:
public class NetStreamex { public var connection:NetConnections = new NetConnections(); public function NetStreamex():void { connection.createNetConnection("rtmp://localhost/test/1");