ActionScript 3.0 :: Referencing A TextField Inside Object On DisplayList
Nov 20, 2009
I have a bunch of objects with TextFields in them that are added to another object called Field.[code]If it is a player, and I can scale it, why can't I access the textField?
View 1 Replies
Similar Posts:
Feb 1, 2009
and I'm trying to add an event listener and a function to the class, but I keep getting errors of undefined, I tried just about everthing to be able to refference obj0
objGroup.obj0.addEventListener(MouseEvent.CLICK, onClick)
private function onClick (event:MouseEvent):void{
trace ("Click");
}
View 17 Replies
Feb 3, 2009
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?
View 1 Replies
Jan 24, 2012
I have a library MovieClip Class that consists solely of a dynamic textfield contained in a MovieClip. I want to instantiate this MC, populate the textField with text, get the width of the resulting text and, if the width is less than a predefined MIN_WIDTH value, append more text. When the width is equal to or greater than my MIN_WIDTH value, add this MovieClip class to the display list. My question is, does anyone know if its possible to retrieve the length of text in a textField using Textlinemetrics BEFORE the textField has been added to the display list?
View 2 Replies
Oct 11, 2011
I've found myself in a tricky place, I've built an app that loads in swfs as external libraries so they can easily be changed at run time, all works well. I now need to separate the code from the art in these libraries so that external developers can change the art without getting their mitts on the code. Trouble is to do this my new code only library elements will need access to my overall manager class, which is the main document class, so that they can access the library manager class to add the appropriate art assets to themselves.
Now there's a couple of clumsy solutions I've thought of:
1, Store a manager class reference in a static var but that seems like a cop out.
2, Go through a few hundred thousand lines of code and alter every instantiation of a library element to include a manager reference - erm, let's not go there.
3, Have the library element send a custom event to the stage from its constructor which passes a return handler to the event listener so that can pass back a manager reference. Sounded like genius initially up until I realised that at constructor stage the library element won't be on the display list so can't bubble up to the stage
View 4 Replies
Apr 15, 2009
i have two classes:
videoPlayer(Document class) and videoControls(which is added to the stage by videoPlayer).
videoControls put an object on the stage at some point:
dp = new displayEnd();
dp.name="dpe";
addChild(dp);[code].....
View 1 Replies
Sep 27, 2011
I use this sample code taken from the docs: all the code is contained inside SocketExample.as, that is the DocumentClass too.
package {
import flash.display.Sprite;
public class SocketExample extends Sprite {
public function SocketExample() {
var socket:CustomSocket = new CustomSocket("127.0.0.1", 5000);
[Code]...
View 1 Replies
May 25, 2010
how do I reference a dynamic text field in my fla file from a class which isn't the document class? For example: I have an fla file called main.fla which contains no actionscript and has a single dynamic textfield called "text_txt" on the main timeline.
[Code]....
View 8 Replies
May 25, 2010
how do I reference a dynamic text field in my fla file from a class which isn't the document class?
For example:
I have an fla file called main.fla which contains no actionscript and has a single dynamic textfield called "text_txt" on the main timeline.
My class file is called aClass.as and is the following:
package
{
public class aClass extends MovieClip
{
[Code].....
View 1 Replies
Feb 21, 2009
I am currently connecting to a PHP string in actionscript. While I'm having no trouble importing the variables like so:
Code:
this(variable);
I am having trouble referencing the same variable while inside a function:
Code:
_root.ButtonMovie.onRelease = function() {
this(variable);
}
I really need to reference the variable while INSIDE the onRelease function, because I need to apply some actions based on how many times the button has been pressed.
View 2 Replies
Apr 27, 2010
ActionScript Code:
function setUpButtons() {
var btnCnt = numeri_array.length;
for (i=0; i<btnCnt; i++) {
[code]...
i'm having a problem with this script... the onRollOver and onRollOut are working properly but the onRelease it's always the same i mean (my_mc.loadClip(foto[27], "container") for all the 27 buttons..
ActionScript Code:
for (i=0; i<btnCnt; i++) {
var temp = this["a"+i];
[code]....
and everytime i have to make a modify i have to write for every case..
View 2 Replies
Dec 16, 2010
I am trying to reference a movieclip located inside an array to add an eventlistener and function... I am using array[0].add...ect. The code for the first movie clip works, but for the rest I get an error 1010.
Code: Select allvar image:MovieClip = new Image();
addChild(image);
const MAX_ITEMS:uint = 6;
[code].....
View 1 Replies
Jun 18, 2011
I understand this, _parent keywords and its usage but I don't understand the following:
MovieClip.prototype.move = function() {
function toRight() {
this._x=50;
[code].....
View 3 Replies
Feb 2, 2011
I am trying to enter a student name into a textfield (student1_txt). I just can't seem to work out the correct syntax. The student numbers and names are in an array. I have the fields working fine outside of the movie clip but not inside.
I wonder if anyone can see what is wrong in the statement below:
_root.desk1_mc["student"+heidedata[0]+"_txt"].text = myStudents[0];
View 8 Replies
Nov 22, 2009
On the main stage I have a button that I have made invisible once the file is loaded. Inside a movieclip I have on frame 15 the following actionscript 3 code
button_mc.visible = true;
I want the button to become visible at the end of this movieclip. I am not using an external as3 file, I am putting the as3 code in its own layer on the first frame.
I know it has something to do with the path to the button, but I cannot figure it out. If there is anyone who can point me in the right direction for referencing instances by instance name that reside on the main satge from inside a movieclip
View 3 Replies
Jan 1, 2010
How would I go about refferencing a variable and then turning it into a string (if that is the correct terminology). e.g:
[Code]...
I need the result of variable something to end up inside the speech marks without loosing its obvious refference to the variable.
View 2 Replies
Jun 19, 2003
Say I have an object MyObject which hasan XMLSocket defined in it, how I can access the Parent object from the onConnect function:
function MyObject()
{
this.ConnectionState = false;
[code].....
View 6 Replies
Nov 12, 2010
How do you reference and already existing object in as3? My below program draws 2 circles and a line to connect the two. The circles and the line are all individual objects. The line (connector class) has a function called update that should redraw the line between the two circles. It has two variables which I want to be the references to the two circles. The circles (coolcircle class) has a variable which I want to be the reference to the connector. It doesn't seem like my update() function is getting called.
ActionScript Code:
package
{
[code]......
View 3 Replies
May 7, 2009
I have an object present in frame 3 of the main timeline. When the object was present in frame 1 i could access it from an as3 code file. But when I am keeping the object in frame 3 of the timeline (Please note that the previous frames for that layer is blank). I am getting a null value for the object. if I try to use trace the object.Logically if I am in frame 3 i should be able to access it.
View 3 Replies
Apr 19, 2010
I need to know how to call or reference (not sure of the terminology) an object by way of a string. What I'm trying to do is create a loop that will add event listeners to objects named "portfolio1" through "portfolio15", and use a function.[code]If I could just reference these fricken objects through a string and an integer, I could set up a small loop like this to make the button "portfolio1" bring up a big jpeg of "bigportfolio_1", and "portfolio2" bring up a big jpeg of "bigportfolio_2", ext. While yes, I could just go through them all and set up event listeners to each one individually, but its REALLY inefficient. Also, I am still working on more advanced actions (like scrolling through the portfolio pics chronologically) that absolutely requires a different reference method.
View 5 Replies
Oct 7, 2010
I have a class attached to a movieclip in the library
That class is calling an instance of a new class
How do I reference an item in the movieclip(which is on stage) from the called instance?
Movieclip - class attached - calling an instance of a class (this is the one I need to reference the stage)
View 2 Replies
Jan 15, 2009
I have my main flash, named "front page". Inside of it, I have 2 movie objects that have a time line, one named "About Us", and another named "Button Group". Inside of "Button Group," I've made a drop down menu that can go to a frame on the main page (in "front page") using the _root command. I was wondering if I could go from the front page into the other movie object ("About Us") by going through the main page.
Tl;dr, I'd like to know how to go to the parent of a movie clip and into another movie clip to modify where the time line is.
View 1 Replies
Nov 3, 2009
I was wondering if anyone could tell me how to access a certain object in an array. for example, I created an array of buttons displayed on the stage. Now I need to attach an onRelease command to each one to launch a new image on the stage.e going round in circles with this. I have attached the code below for reference:
thumArray = [];
function thumbs(){
for (i=0; i<totalImages; i++) {
[code].....
View 1 Replies
Sep 24, 2010
I have a fairy sizable class, a`nd an mx:Application that will periodically instantiate a new object of this class, which results in member functions of the class being assigned as event listeners to the application, and also other member display objects of the class being added as children to the application. When the application creates a new object of this class the old object is destroyed: to accomplish this, removeEventListener and removeChild are called on various members of the old object (to decouple them from the parent application) and then the final reference to the old object is set to null, and then finally the well known localConnection hack is called to force FP to actually free the memory.
And the thing is, the above destruction procedure always works to deallocate an object - except for the very first object allocated. it has proved impossible thus far to release the memory of the first such object created, or find out what is preventing it (i.e. find out what is still referencing it). So my question is - is there any useful utility that will tell you what is still referencing an object and keeping it from being garbage collected. Someone implied to me that the flex profiler would do this (which I do not have access to) but another 3rd party profiler I found for flex would not do this (i.e. tell you what is referencing an object and keeping it from being deleted.)
View 2 Replies
Jun 14, 2007
I am in no way very knowledgable with ActionScript, so this might be very simple and I am looking in all of the wrong places... but basically here is my issue: Instead of accessing an objects attributes like this, _level0.thumbnails.thumbnail0._width = 500; I want to be able to access it with _level0.thumbnails. (this.id) ._width = 500; where as (this.id) is a variable that could be equal to "thumbnail0" or "thumbnail99" depending on which object gets clicked. I have everything working to if I hardcode thumbnail0 it works fine, and this.id does get set to whatever thumbnail I click's "thumbnail" + ID
View 2 Replies
Jun 1, 2009
referencing instances of an object in AS3
I want to be able to build a navigation and reference each navigation item separately changing each instances properties depending on rollover actions etc.
I would have thought that once the name is assigned through the for loop that would stick, eg. the following code would create 3 vars called navItem, each with the name 0, 1, 2. But it seems if I trace the name outside of the for loop each is called 2. I think Im misunderstanding something really simple!
public function buildNav():void {
for (var i=0; i <itemNum; i++){
var navItem:NavItem = new NavItem ();
[Code]....
View 2 Replies
Oct 12, 2010
I've got a button which is called "playBtn", within this i have a MC called "btnlarge", If i remove the .btnlarge from the below code, then the "playBtn" is coloured correctly in my player,
Code:
var sColor:ColorTransform = player.playBtn.btnlarge.transform.colorTransform;
sColor.color = scolour;
player.playBtn.btnlarge.transform.colorTransform = sColor;
however with it in.. i'm obviously wanting the btnlarge MC to be coloured, but this isn't happening and its throwing me this error:
ReferenceError: Error #1069: Property btnlarge not found on flash.display.SimpleButton and there is no default value. at f4:layer/skinCompleteEvent()
Is there something really obvious i'm doing wrong? I've tried changing the "playBtn" into a MC and all kinds of things, but nothing seems to work, i can't seem to reference anything within another object.
View 5 Replies
Oct 16, 2011
I have a several objects nested within an array. I'm trying to reference a property of one specific object (intel).
function eventGenerator():void
{
var randomArea:Number;
randomArea = Math.ceil(Math.random()*5);
[Code].....
ainPlace names is the array's name. The random area variable contains the co ordinate on the array for the object. Each object on the array has a property called intel. The idea is I want to able to store the value of intel in a number and use in an equation. I would also like to be able to adjust the number. the trace function here returns an error saying it is undefined so eventArea.intel for some reason isn't referencing the intel property of the object.
View 3 Replies
Jul 7, 2010
I'm trying to:Jump from frame 1 to a frame later in the main timeline Reference an object that exists on the stage in that frame, but not in frame 1
Like so:
ActionScript Code:
function endGame():void {
gotoAndPlay("gameOver");
scoreField.visible = false;
}
A movieclip with the instance name 'scorefield' exists in the "gameOver" frame, yet for some reason, I just get a "Cannot access a property or method of a null object reference." This code is all within a function. By the time the reference to scoreField is executed, the timeline is at the right frame.
View 7 Replies
Dec 11, 2010
i'd trying to build an interactive tree that allows the user to move the tree's branches and nodes. the lines (branches) of the tree are drawn programmatically between points (nodes and tips). i'd like for the user to click on points to drag them while having connected lines and points move correspondingly. i've gotten this to work to some extent using the code below:
ActionScript Code:
function startMoveOa(evt:MouseEvent):void {
thisPtOa = Sprite(evt.currentTarget);
[code].....
View 2 Replies