ActionScript 3.0 :: Get The Reference Of One Object's Parent?
Oct 21, 2010i have classA and classB like bellow
class ClassA{
public var myVar:String="test";
public function ClassA()
[code].....
i have classA and classB like bellow
class ClassA{
public var myVar:String="test";
public function ClassA()
[code].....
I'm creating a bunch of movieclips, associating a sound object with them, and then updating them with a progress bar, like so:
var theClip:MovieClip = new MovieClip;
theClip.track = new Sound;
[load sound from URL pseudocode here]
theClip.track.addEventListener (ProgressEvent.PROGRESS, onLoadProgress);
function onLoadProgress (erogressEvent):void {
How do I reference the movieClip the sound is a child of? e.target refers to the sound object; e.target.parent returns an error. And you can't assign properties to sound objects.
I'm trying to create a timer object within a movieclip, which, due to the dynamic nature of the movieclips, works well. However, when a timed function is kicked off I'm having trouble referencing the 'parent' movieclip.I'm trying the code below but the'Evt.currentTarget.parent' line throws an error. Anyone know how to make that reference work?
var mc:MovieClip = new MovieClip();
mc.transitionTimer = new Timer(30, 0);
mc.transitionTimer.addEventListener("timer", stepTransition);
[code]......
I have been using:
yourbutton.addEventListener(MouseEvent.CLICK,f);
function f(e:Event):void{
Loader(this.parent).load(new URLRequest("newswf.swf"));
}
which was suggested to me in a different post to target the parent loader class, however i now no longer can reference my preloader in the parent swf (extract from the parent swf):
[Code]...
I cannot use the following in my ActionScript due to conflicts with the host application:
_level0
_root
_parent references
On a pop-up box I have a close button with an absolute reference: closeBtn.onRelease = function{ unloadMovie("_level0.Page_1.holderBox");} Is there another way to make this work without using _level0 or _parent? I've read that it is possible to use a global variable on the main timeline and ref that, but cannot get that to work.
I have a site class with different properties. The site class creates a Background class. I want the background class to use the Site class' stylesheet object. How can this be done?At first I thought about passing the site object to the Background class' constructor, but maybe there is a way to reference to the calling class?
View 8 RepliesI am writing some codes inside a movieclip but I want to activate a mouse over event from a parent object since there is a removeEventListener method that delete the the event!Is there a way to do it in actionscript 3.0?
View 11 RepliesI am trying to run a function of the main class, but even with casting it does not work. I get this error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at rpflash.communication::RPXMLReader/updateplaylist()
at rpflash.communication::RPXMLReader/dataHandler()
[Code].....
I have an AS3 class on my Flex project[code]...
View 2 RepliesThis is my code in Flash/AS3, in a frame's action:
import flash.events.Event;
stop();
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void{
[Code]....
This is because I believe it is referring the splashTimer1 function by "this".
How can I refer to parent frame there, so that I can remove its event listener.
So I am trying to access a variable that is defined within my parent code from a class which has been called from my parent code. I am using this:Code:TileCode(parent).game_quests.add_quest(0);to try to access the game_quests variable (which is defined within TileCode). However, for some reason it is not picking that up. It is working for other variables which I have called and ran in a similar fashion
View 7 RepliesI want to listen for a custom event dispatched from the document class in a custom subclass. For example, let's say in the document class I have:
ActionScript Code:[code]....
So that the subclass will trace 'Event from document class received' when the 'customEvent' event from the document class is listened by the eventlistener. However, the output is only 'customEvent dispatched', meaning it wasn't heard in the subclass.
I am wondering how to correctly reference child/parent movie clips when creating event handlers? I have a button within a movie clip, which is within a movie clip.This is what my handler looks like right now:
this.DropMenus.DMSeats.ButtonSeats.addEventListener("click",SeatsOver) ;
The button instance name is ButtonSeats Problem is, I get this:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Also, if I were to move the vent listener directly into the movie clip where the button is located, how could I reference the parent/ parent timeline(the main timeline)? Am I correct to understand that .this refers only to the current clip?
I'm having bit of a headache with 1119 error and I can't figure out why.What I'm trying to do is:
1. Add Display Object "imagesGallery" to mainWin
2. Add MovieClip "imagesPreloader" to "imagesGallery"
3. Fire the "load" function from "imagesListLoader" which should fireup the function imagesLoaded in "imagesGallery"
Here's the code:
mystage/MainWin.as:
Code:
package mystage {
import flash.display.MovieClip;
import flash.events.Event;
[code]....
I'm having bit of a headache with 1119 error and I can't figure out why.The problematic line is in red.
What I'm trying to do is:
1. Add Display Object "imagesGallery" to mainWin
2. Add MovieClip "imagesPreloader" to "imagesGallery"
3. Fire the "load" function from "imagesListLoader" which should fireup the function imagesLoaded in "imagesGallery"
[Code]...
I have one MXML File as
<objecthandles:ObjectHandles xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" backgroundAlpha="1" xmlns:mx="library://ns.adobe.com/flex/mx"
[code].....
I have problem with accessing object created by function imported from another package.
I have 2 packages DragDrop and UserInterface. In UserInterface I create methods for buttons and later add them in DragDrop . I make it in two different ways:
One(this one works):
[Code]....
[code]All clips are squared.Ok, on the PlayerPlane, there are little soldiers, which have hotkeys. The effect I'm trying to create is I want to position the GameStage so that the currently selected soldier appears in the center of the GameClicker clip.The GameStage is movable by the player (to scan other areas of the map)by holding the CTRL key, so it's easy to kinda lose track of where your players are.I have tried using localTo Global and globalToLocal techniques, but I think I'm lost on the actual math of getting the GameStage to move the correct distance so that the selected soldier is centered to the GameClicker.[code]
View 2 RepliesI define a variable (var photo1Show:Boolean = false;) in the actionscript layer. I have a movie clip component on stage at this level.I double click it to open it. This movie clip has an actionscript layer were I place the code "parent.photo1Show = true;".when I test the
application,I get error:1119: Access of possibly undefined property photo1Show through a reference with static type flash.display:DisplayObjectContainer.
Parent frame: contains several layers. the two in question are the action and photo layer.action layer:
// Prev and next botton navigation controls
var photo1Show:Boolean = false;var photo2Show:Boolean = false;var photo3Show:Boolean = false;var photo4Show:Boolean = false;var photo5Show:Boolean = false;[code].....
Can I access a static variable of a subClass' subClass? I don't want to instantiate it, just looking to get the variable because it has already been initialized by the subClass.example:
package
{
public class A extends MovieClip {
private var classB:B = new B();
[code]....
I'm coming to Flash from a mixed graphic design / 3D animation / motion graphics background. In any of the animation programs I've used before, including After Effects, parenting is a simple operation. ...But it seems that in flash, it's more complex. So far, I am beginning to understand that it has to do with nested scenes, or nested time lines (which may be the same thing?)... So my question is... What is the easiest way to parent one object to another?
View 5 RepliesI want to print the content of the label property in the Alert window.[code]...
But the Alert window is completely empty. What am I doing wrong ?
I guess the keyword "this" is referencing the application instead of the LinkButton, right ?How can I reference the LinkButton itself, without having to add an ID to all my linkButtons?
Like I have a parent with 5 children which are the same type of object, like the same class. Is there a function or property that tells me what index this particular child is in its parent? Like this child is the 3rd child in its parent.
View 2 RepliesI 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)
Im using the following code to place an object inside a container:
testParent = new MovieClip();
testParent.graphics..beginFill(0x0000FF);
testParent.graphics.drawRect(50, 50, 300, 300);
[Code].....
this gives the testParent object a margin of 50 from top and left. The testChild object should have have the same margin relative to stage. But doesnt.. The child object is at 0,0 relative to stage. Whats causing this?...
I'm trying to do a cross-fade effect for my gallery. To do that, I'm using two movieclips, one that holds the image currently displayed, and another one that holds the image that should be displayed next. When the coming image is loaded, the cross-fade effect should happen, the container that holds the image that was on stage should be cleared out, then the image in the other container should be displaced to the former container. I'm almost there now, but I got stuck at the last part. Here's my code so far[code]...
View 2 RepliesI have an object called helpDialog that has a sub-object called "closeX"- You click the X and the helpDialog closes. But I'm a little stuck. Let's say I add a new helpDialog to the stage:
Code:
addChild(new helpDialog());
and let's say that closeX has the following class definition:
[code]........
How do i actually detect an object from parent(maintimeline)? I'm trying to add a listener on this loaded picture_mc such that when it's drag to this specific object, box_mc on the maintimeline, picture_mc will perform some animation.
View 1 RepliesI've got an external class and make like 20 objects with it. If I e.g. hover my mouse above them, the objects themselves know that, the parent clip however does not. Now I want a global boolean to be set to true, if one of those objects is focused. So in other words I want to set a parent variable from inside of an object that I created with a class.
I could make myself an enter-frame-loop and check all of the objects all of the time, but that doesn't sound like a good solution.
I could also add 20 change-listeners to the parent clip, but I'm not sure about the performance of that. And I have listeners inside the objects anyway, so those should be somehow able to take care of that, or isn't that possible?
ERROR:1119: Access of possibly undefined property contact_mc through a reference with static type flash.displayisplayObjectContainer.
[Code]...