ActionScript 3.0 :: Accessing An Instance Of Parent Movieclip For HitTest?

Dec 13, 2009

I have a stage with instances of bauble_mcs on it that are attached by the document class of the main timeline (can someone tell me what the right term is here? I don't know what I call the main time line in AS3).I then have instances of snow_mc attached by the same class. Inside the snow_mc I want to test to see if it is hitting any bauble_mcs but I don't know how!

inside snow_mc I am trying:

PHP Code:

if(this.hitTestObject(this.parent.bauble_mc)){
}

to which flash says:

1119: Access of possibly undefined property bauble_mc through a reference with static type flash.displayisplayObjectContainer.

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Accessing A Parent Instance From A Loaded Swf?

Jul 21, 2010

I have a "MainSWF", that loads and places other SWFs "LoadedSWF". The LoadedSWF has buttons that are supposed to make some layers in the MainSWF visible/invisble. These layers are in a placed navigation bar that is defined as a symbol, was placed on the Main Stage and given the instance name "FlashStageMainNavigation". I have a hard time figuring out how to address the layers in the MainSWF, because it seems I am missing something.

When I use a loop to trace all the child instances on the stage of the MainSWF with:

this.getChildAt(i).name

I get the following info:

instance1 this.name=0
FlashStageMainNavigation this.name=4

When I trace stage.getChildByName(this.name) in MainSWF I get "FSMain", which is the name of my main Class

My assumption was, that I could (from the LoadedSWF) address the Navigationbar in the MainSWF by using something like:

stage.FSMain.FlashStageMainNavigation.visible = false; //or
stage.getChildByName("FSMain").FlashStageMainNavig ation.visible = false; //or
stage.getChildByName("FlashStageMainNavigation").v isible = false;

neither of that worked.

To sum up/rephrase my question: How can I find out, which object instances are placed on the stage and how do I address them from the LoadedSWF?

View 4 Replies

ActionScript 3.0 :: Accessing Parent MovieClip From Child MovieClip?

May 17, 2011

I'm trying to access a parent movieClip from the child movieClip

Here's what I want to do,

I've got a movieClip named wrong_mc, which plays for a couple of frames and on the last frame, its got a close button "close_btn" inside of it, now I wanna write the code such that when close_btn is played the movieClip "wrong_mc" should go and stop at frame1, I'm just not able to access this movieClip from the button.

View 5 Replies

ActionScript 3.0 :: Child Swf Accessing Parent Swf Movieclip/s?

Oct 21, 2011

how to access a movie clip/s in a parent swf from a child swf. for example:Interface swf has buttons as mc's (home, about, services, portfolio e.t.c.) and loads in a swf when one of the buttons in the interface swf is pressed. When a button in Interface swf is pressed none of the other buttons can be pressed until the swf of the button that was pressed has loaded.

The reason for this is so that if the user tries to press the buttons quickly lets say the user pressed services button but changed thier mind right after pressing it and wanted to press lets say portfolio button they couldnt press the button until the services swf has loaded. Ive seen websites that dont do this and is makes it all mess up. Ive been able to do this in the past in AS2 but i cant figure it out in AS3.This is the code i would use in AS2:

Interface swf code is:
ActionScript Code:
_level5.btn_1.enabled = false;[code]...........

View 4 Replies

ActionScript 3.0 :: Accessing MovieClip Objects On Parent MovieClips?

Sep 11, 2009

So for my main timeline:

var lightBox:mc_lightbox = new mc_lightbox();
lightBox.x = 300;
lightBox.y = 200;
addChild(lightBox);

I get a lightbox up on the screen, within the lightbox is some more script, there are three menu options for that new window. So far when you click on it the loading part comes up just fine but whenever I have it go to another scene it leaves behind the lightbox above. I'm able to removeChild(loading) because its right there just a function above but I'm unable to removeChild(lightBox) because it's one up. How can I access that child? I tried many variations of parent, MovieClip, and root relationships but still couldn't get flash to find it.

View 1 Replies

ActionScript 3.0 :: Accessing Class Instance At Root From Movieclip

Nov 15, 2010

I have declared a object in my 1 st frame of application.

ActionScript Code:
var objTest:Test = new Test();

I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error

ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);

1119: Access of possibly undefined property objTest through a reference with static type flash.displayisplayObjectContainer.

How to access a object instantiated at root from a movie clip.

View 1 Replies

Professional :: Accessing Class Instance At Root From Movieclip?

Feb 25, 2010

I have declared a object in my 1 st frame of application.

ActionScript Code:
var objTest:Test = new Test();

I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error

ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);

[code].....

View 4 Replies

ActionScript 3.0 :: Accessing Class Instance At Root From Movieclip?

Nov 16, 2010

I have declared a object in my 1 st frame of application.

ActionScript Code:
var objTest:Test = new Test();

I am tring to access the object from a movie clip. Movie clip is located in frame 2. I am getting error

ActionScript Code:
this.parent.objTest.IncrementCount();
trace(this.parent.objTest.QuestionCount);

[code].....

View 3 Replies

ActionScript 3.0 :: Error Accessing Function After HitTest

Oct 4, 2010

I've been using asGamer's excellent set of game design tutorials to put together a basic 'ship and enemies' shoot 'em style game - my first proper venture into using AS3 and external class files - and I've hit a problem with executing hit test results. To explain: The game uses Engine (the document class), Ship and Enemy classes. Enemies (new instances of the Enemy class) are added to the stage in the Engine class, where they are also stored in an array, enemyList. The Ship fires a Laser, and the Laser class is where we test for a hit on Enemies.

Now, in asGamer's original version he uses the hitTestObject to test for hits, and if a hit is registered, this line
PHP Code:
Engine.enemyList[i].takeHit();
Calls a function in the Enemy class to remove the relevany clip. However, as the hitTestObject includes the bounding box of a clip in its hit test, I decided to use Corey O'Neil's Collision Detection Kit for greater accuracy. The CDK CollisionList class returns an array, the each element of which is a clip with which the target object has collided.

The problem this presents is that rather than using
PHP Code:
Engine.enemyList[i].takeHit();
To deal with a collision, I now use
PHP Code:
collisions[j].object1.takeHit();
Where 'collisions[n].object1' are the movie clips hit.

When I test the game it throws an error
PHP Code:
ReferenceError: Error #1069: Property takeHit not found on com.asgamer.basics1.Laser and there is no default value.
at com.asgamer.basics1::Laser/loop()
Although the movie does not break, and continues to remove destroyed enemies as if there was no problem.

What the problem is with calling the takeHit function via the collisions array rather than the Engine.enemyList array? And perhaps suggest a way to prevent it? I should point out that the 'laser' is in fact a blast that can take out any number of enemies intersecting with the blast radius, which is why I'm using CollisionList to detect hits.

View 6 Replies

ActionScript 2.0 :: Create An "hitTest" Script Inside A Movieclip That Is Actually Part Of That HitTest Code?

Jan 15, 2009

i just would like to know how to create an "hitTest" script inside a movieclip that is actually part of that hitTest code?I mean... I have mc A, and mc B. and the current hitTest code im using (that is on the timeline) makes mc A, destroy mc B when collide with it... but there are many mc B on the stage (with the same instance name) so, when mc A collide with one mc B, it destroys ALL mc's B... but i want it to destroy only the mc B that he collides, not all the others... maybe an hitTest script inside a movieclip B would work (somethig like "if MC A hitTest ME = i die" (not all the others)).

View 1 Replies

ActionScript 2.0 :: HitTest And Changing Scales And X-y Positions Of Parent Clips?

Sep 29, 2005

I'm just wondering if hitTest can be affected by the changing x,y coordinates or the changing scale of the parent clips. My platform engine doesn't seem to work everytime I try to add a script to a parenting clip (of a playable character and a computer character) that changes the x and y values of that clip as well as the scale (simulating a camera that keeps both characters in focus).

View 2 Replies

ActionScript 3.0 :: Different Movieclips Same Instance Name - HitTest

Jan 3, 2011

I'm creating a platform game, and I have those boxes which needs hitTests on all sides - including the bottom.I want my hit areas to have the same instance names. With that I mean, that I want only one instance name for all the bottom hits, one instance name for alle right hits - and so on. If it's possible. 'Cause else there will be so much actionScript code to write.I've been trying to simply make a normal hitTest on for example hitGround, and then place two movieclips with the instance name hitGround, but the hitTest function only works on the last added movieclip with that instance name.I have also been trying to look up some for each in-arrays, but I don't really get the meaning of how to use them.

View 2 Replies

Professional :: 3 Object HitTest - Removing Instance

Jul 7, 2011

I am trying to make the instance 'red' be removed when all 3 objects have hit it here is my code:

var hit = 0;
addEventListener(Event.ENTER_FRAME, hittest);
function hittest(e:Event){
addChild(blue);addChild(green);
addChild(pink);
addChild(red);
[Code] .....

View 2 Replies

ActionScript 2.0 :: HitTest Detect Random Duplicated Instance?

Sep 25, 2005

I've got this code on my frame:

if (_root.count <= 20) {
duplicateMovieClip("_root.clip", "clip"+_root.count, _root.count);
_root["clip"+_root.count]._x = random(500)+50;
_root["clip"+_root.count]._y = random(1)+20;
}

And I need to figure out how to have the hitTest see the randomly generated instances of this duplicated mc.

I can get the hitTest to see the first instance (called "clip"), but then it doesn't see all the rest.

Here's the code I have on the hitTestMC:

onClipEvent (enterFrame) {
if (_root.chime1, hitTest(_root.clip)) {
_root.chime1.gotoAndPlay("play1");
}
}

View 1 Replies

ActionScript 3.0 :: Error 1120: Access Of Undefined Property Parent + Movieclip(parent)?

Mar 15, 2011

I am trying to access a function that is on my document class for my AS3 project, from a nested class. That is, the Document Class calls Class A which then calls Class B. So I am trying to access a function from Class B, I am trying to use MovieClip(parent).function(); but I am getting error 1120. The MovieClip(parent) (fixed to reflect my document class, etc) works when I try it from other classes but not from this nested class.

View 9 Replies

Actionscript 3.0 :: Parent.parent.movieClip.visible = False; - How The Heck Do Climb The Ladder Then Go Back Down Again Into Another Clip

Dec 10, 2009

I've struggled with this for a long time and have thrown in the towel. How the heck do you climb the ladder, then go back down again into another clip?

View 2 Replies

ActionScript 3.0 :: Accessing Parent's Variables

Mar 8, 2010

I'm trying to access the AchievementScreen's textfield from a medal object. Point being to have a mouseover event of the medal, change the content of the textfield shown. I tried a trace first: trace(this.parent.parent.parent.parent.textLineCon tainer); 1119: Access of possibly undefined property textLineContainer through a reference with static type flash.displayisplayObjectContainer. trace(this.parent.parent.parent.parent) shows me it is a AchievementScreen object. textLineContainer is the instance name of the MC nesting the textfield (I actually drew the achievement screen then exported it to actionscript.

[Code]....

View 11 Replies

ActionScript 3.0 :: Accessing A Parent Variable?

Mar 15, 2010

Lets say I have a movieclip on the stage.

On the stage on frame 1 I define a variable. Lets say its a string that reads "hello".

Now in my movieclip on stage I am trying to trace that string I defined on frame 1 on the stage. How can I make this happen?

I have tried a few things but I can't seem to get it working right.

View 1 Replies

ActionScript 3.0 :: Accessing Parent Through One Of Its Properties?

Jul 6, 2011

I'm doing some work with JSON in as3 using as3corelib (very useful) and was wondering if it is possible to get an object if all you have is one of its properties, also an object.Here's an example of some JSON:

ActionScript Code:
"parentObject": {
"propertyObject": {

[code].......

View 2 Replies

ActionScript 3.0 :: Accessing Parent From A Loaded Swf

Jun 8, 2010

Well, I know how to access the loaded swf variables from its parent, but how do I access the parent SWF variables from a loaded SWF?! I'm trying it.. But get no results.

View 6 Replies

ActionScript 3.0 :: Accessing A Parent's Variable From The Child?

Aug 27, 2009

This is probably a fairly easy answer, but I can't figure it out. I have a dynamically added child, and I have a dynamic text box on the parent. I'm thinking that it should be possible for me to add to the text box from the child timeline, but I don't know how to target the text box.

View 1 Replies

ActionScript 2.0 :: AS2: Accessing Parent MC Class From Child MC?

Jan 27, 2010

I've been using greensock classes in a parent movie, but am now looking to use the same classes from within some child movies, but it doesn't work (I presently have to import them into each child movie - what a waste).

Do I need to create the classes as a shared library object perhaps? If so, how would I go about it? as I've only ever done this for MCs or MP3s.

View 2 Replies

ActionScript 3.0 :: Child Accessing Parent Variables?

Sep 6, 2010

What's the strategy for getting a child to access variables in a parent.I have a Main class.In that class I create instances of a Unit class and save those to an array.In the Unit class, I want to access the x and y coordinates of other instances of the Unit class.So I'd like to access that array I made in the Main class.I tried:this.parent.theArray[i].xbut that doesn't work. I tried using the get command, but I don't really know how to, so my efforts failed.

View 3 Replies

ActionScript 3.0 :: Accessing Parent Function From Class?

Nov 17, 2011

I have a .fla file with some code in the actions panel.A bit of code calls a function in a class from the actions panel .The function in the class is run, but I want to be able to call a function in the main actions panel code from the function in that class .The class doesn't extend anything so (parent as MovieClip).function() does not work.

View 7 Replies

Flex :: Accessing States Of Parent Application?

Dec 10, 2010

I have several custom components all of which are included in the parent application.When I try to change state from a custom component, I get an error saying "undefined state: state name". How do I change the state of the application from within a custom component ?

View 2 Replies

Actionscript 3 :: Accessing Variable In Parent From Child

Oct 30, 2011

Im trying to access some variables from the parent in a child mc.[code]nothing shows up in any of the dynamic text fields...

View 1 Replies

ActionScript 3.0 :: Accessing Parent Root From External Swf?

Jul 23, 2009

I am able to access main root from an external swf by doing this:

MovieClip(root.parent.root)

but how to avoid getting an error when testing external swf alone? Is there any try catch system I can do to avoid thoses errors?

View 1 Replies

ActionScript 3.0 :: Accessing Variable Outside Of Its Parent Function?

Sep 30, 2009

ActionScript Code:
function createMaskBox():void {
var maskBox:MovieClip = new MovieClip();
galleryContainer.addChild(maskBox);
}

creates maskBox under the function therefore not accessible form outside of this function from what i understand. Is there a way to create a var WITHIN a function which would exist as if defined outside of it, directly in code?

View 3 Replies

ActionScript 3.0 :: Accessing Variables From A Parent Movie?

Nov 10, 2009

i am trying to make a basic preloader for an AS3 site. I followed the tutorial on this site (Preloading actionscript 3 the easy way) where its similar to AS 2 - create a Preloader movie and load the whole .swf into it.

only problem is i need some variables that i pass to the movie via QueryString parameters in the Object and embed tags. Is there any way to get this in my loaded movie?

i have tried
root.loaderInfo.parameters
and
stage.loaderInfo.parameters
and
parent.loaderInfo.parameters

none of them work. Can i create a variable in the prelaoder and just go "parent.thevariable" ? or does parent even work when something is loaded into a loader?

View 1 Replies

ActionScript 3.0 :: Accessing Variables Of Child Swf From Parent?

May 4, 2010

I have TestA.as the base class file for my TestA.fla that has nothing but a movie clip with instance name box.

TestA.as

ActionScript Code:
package
{
import flash.events.MouseEvent;
import flash.display.MovieClip;

[Code].....

View 0 Replies







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