ActionScript 3.0 :: Referencing The Child Of A Referenced Object?

May 23, 2011

Right now, I create the world class first, from my main timeline. This is placed as a display object, and it contains many other display objects, most notably the level Holder, which holds all foreground pieces.After creating the world class, I create the camera class from my main timeline, and pass it the instance of the world class as an argument. What I'm trying to do in the camera's code, is create DisplayObject variables for the levelholder (and several other children of world) and set it equal to world.lvlHolder, like so

Code:
public function Camera(input:DisplayObject)
{

[code].....

View 9 Replies


Similar Posts:


ActionScript 3.0 :: Referencing A Child Of A New Object Instance From The Library?

May 20, 2009

I make a movie clip in the library ( a button with a text field on it ) and export it for actionscript. Then I create an instance of the object using code ( myButton = new Button1(); ).And then I want to access and change the text field ( whose instance name is "myField" in Flash ) afterwards.Is that possible, or I have to create a custom class for the object, or just create an entire button dynamically?

Because what I have tried until now doesn't work.

Code:
var button1:button_test1 = new button_test1();
button1.x = stage.width / 2;
button1.y = stage.width / 2;

[code]....

This questions is for all movie clips: is there a way to access a movie clip's objects with actionscript after you have created (with code) an instance of that object (which was designed in flash, and exported for AS) ?

View 2 Replies

ActionScript 3.0 :: Flash Removing Child From One Class, Still Being Referenced In The Other?

Feb 12, 2012

I have two classes, one called car, one called game. When the user drives a car off the map, i wish to remove the car from the map, do some fiddling with vars (lifes etc) and then re-add the child.But i get the following error #1009: Cannot access a property or method of a null object reference.. I think it is because the car class is still trying to control the car even though it is being removed.

Car Class

Code:
package
{
// IMPORT ANY CLASSES OR LIBRARIES
import flash.display.MovieClip;

[code]....

View 5 Replies

Actionscript :: Weakly Referenced Object To Be Disappeared Immediately When Last Strong Reference Removed?

Oct 4, 2011

I read some articles about ActionScript's weak references. There are two types.

Trick with Dictionary class.
EventDispatcher class.

I expected weakly referenced object to be disappeared immediately when last strong reference removed.(regardless of GC behavior) But those tricks didn't work like that. The object referenced only weakly still live a while, and looks disappear when next GC time.Removing all of strong references didn't make weakly referenced object to be disappeared from object graph.(I know it'll not be deleted immediately)

View 1 Replies

ActionScript 3.0 :: Referencing A SWF Playing As A Child Of A MC?

Jun 7, 2010

OK. I have an empty MC sittin on the stage named "M1_mc".

In the first frame I have:

Code:
var movieOne:Loader = new Loader();
M1_mc.addChild(movieOne);
movieOne.load(new URLRequest("movie1.swf"));

At this point, the external swf is playing.

How do I control the child SWF playing? Let's say i wanted to stop() or gotoAndPlay(x) within its timeline?

View 1 Replies

ActionScript 3.0 :: Referencing A Child's Method

Nov 6, 2008

I'm trying to make a small card simulation that creates a pile of cards, and when I click on the deck it flips the top card over and moves it to another pile. Clicking on the other pile flips it back. I'm using Flash CS3 so can't use Flash 10's 3D abilities. So far, I'v created a Card class (extending sprite) which draws 2 rectangles (for the front and back faces), and contains a public method flipTo(). which when called starts a tween which moves the card and flips it (by adjusting it's scaleX value to negative, and when scaleX = 0 toggling the visibility of the card's faces).

This works fine, and so I have a for loop that creates 10 instances of the Card class on top of each other (and within a sprite container called rightPile), giving me my pile. I've attached an event listener to the pile, so when I click it, it performs the onRightClicked function, which calls the top card's flipTo() method. So when I click on the pile, the top card flips. However, when I click again, the same card flips again, and I can't figure out how to make the next card flip. I've tried keeping track of the index of the current card, and using rightPile.getChildAt(currentCard).flipTo(), but I get the following error...

[Code]...

View 5 Replies

ActionScript 3.0 :: Referencing Parent MC From Child?

Mar 9, 2012

Each of these children has an index value assign to it for the purpose of relating to an XML file, but that's beside the point. Those children have other children eventListeners that call a tween function. That tween function wants to tween the first child.First question: what is the proper syntax for referencing the parent and getting that index value? Does this work, with currentTarget being the child that called the function:var something = e.currentTarget.parent.index;If not, how can I get that index value?Second question: In order to determine which of the first children the tween is applied to, I could write a conditional that checks the index value and tweens based on that. Is there an easier way to do this? And what conditional would work best? I'm thinking if() else() but I'm relatively new to as3 so if there's something more efficient I'd love to hear it

View 2 Replies

ActionScript 3.0 :: Referencing A Frame On A Child From The Parent?

Nov 20, 2009

I have a frame that I want to display but the function that calls it exists on the parentHow do I call a frame that exists within a child movieclip from its parent?Here is my code. It is basically for a restart button.Here is the parent function.

Code:
function restart(event:Event)
{

[code].....

View 3 Replies

ActionScript 3.0 :: Referencing The Stage From A Child MovieClip

Dec 15, 2009

I feel like I should know this by now, but I'm having trouble. I want a function in one of my child functions to increment an integer in its parent function.

[Code]....

View 9 Replies

Actionscript 3 :: Cross-referencing Two XML Child Nodes?

Nov 24, 2009

I am building a mini language translator out of XML nodes and Actionscript 3.I have my XML ready. It contains a series of nodes with two children in them. Here is a sample:

<translations>
<entry>
<english>man</english>

[code].....

View 5 Replies

Actionscript 3 :: Referencing A Document Class From A Child MovieClip?

Apr 13, 2010

I have a document class with a child MovieClip on the stage. I have the clip already on the stage because it's part of an complex layout provided by the designer and it seems easier to leave it on the stage than to use addChild (since I would have to add about 60 objects).What is the best way to reference the document class from inside the child MovieClip class?

View 1 Replies

ActionScript 3.0 :: 1009: When Referencing Stage - Stagewidth From The Child

Jun 3, 2011

I have a main.swf and a slider.swf. I load the slider.swf into main.swf. In my slider.swf I have this code which adds an image to the stage from the Library:

[Code]...

I assume it has to do with the stage.stageWidth. Is there a another way to reference the stage. If I load the the image externally via a loader I can use the stage.stage Width.

View 4 Replies

ActionScript 3.0 :: Prevent A Child Swf From Referencing Its Parent Swf Stage Width/height?

Oct 11, 2010

I would like to know the way to prevent a child swf from referencing its parent swf stage width/height?

for example, i created a child swf that loads image and center it on it's stage. As a stand alone its fine but i loaded it with parent swf, it centers on the parent swf instead.

View 3 Replies

ActionScript 2.0 :: Referencing Child MC's - Error #1056: Cannot Create Property McDefault On RandImg

Aug 7, 2006

I'm using AS 3 in Adobe Flash 9 Public Alpha. I have a MovieClip named "RandImg" in my Library with an associated "RandImg.as" class file. I'm placing this MC on the stage during design time. This MC contains an instance of another MC with with the instance name of "mcDefault". In the constructor of my RandImg.as class file, if I attempt to reference mcDefault, I get the following error when I try to compile: ReferenceError: Error #1056: Cannot create property mcDefault on RandImg. How do I reference this movie clip in AS 3?

[Code]...

View 1 Replies

Child Of Child Movie Clip Are Null In Imported Object From Flex To Flash Right After Being Created?

Dec 16, 2010

I have an Movie Clip in Flash that have subobject of button type which has subobject of input text and movie clips. Right after creation core Moveclip all subobject are set to null, when I expect them to be valid objects.

[Code]...

MC_Core_design was created in Flash and exported to Actionscript. I've done this for button_1 class aswell. The code was written using Flex. When I comment out both lines that result in error I get correct view of the core Movie clip with all subobject. How can I set subobject properties right after object creation?

View 2 Replies

ActionScript 2.0 :: Referencing An Object In An Object?

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

ActionScript 3.0 :: Referencing Another Object?

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

Referencing Object In Differant Frame?

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

ActionScript 3.0 :: Referencing An Object With A String

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

ActionScript 3.0 :: Referencing A Parent Object?

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

ActionScript 2.0 :: Referencing One Movie Object From Another?

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

ActionScript 2.0 :: Referencing An Object In Array?

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

ActionScript 3.0 :: Utility To Indicate What Is Referencing Object

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

ActionScript 2.0 :: Variable Object Referencing

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

ActionScript 3.0 :: Referencing Instances Of An Object?

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

ActionScript 3.0 :: Flash Referencing A MC Within Another Object?

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

ActionScript 3.0 :: Referencing From An Object Within An Array?

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

ActionScript 3.0 :: Referencing An Object Inside A Class

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

ActionScript 3.0 :: Referencing An Object That Exists Later In The Timeline?

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

ActionScript 3.0 :: Referencing An Object's Stage Position?

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







Copyrights 2005-15 www.BigResource.com, All rights reserved