Home Tutorials Forums Articles Blogs Movies Library Employment Press
Prev Previous Post   Next Post Next
Old 06-16-2012, 11:40 AM   #1
tommyzDad
Registered User
 
Join Date: Jun 2012
Posts: 8
Unhappy Referencing Objects on the Stage From Inside a Movie Clip

I did find topics on this, especially this one: (Edit: I can't post a link to the thread, as I've zero posts....)

But as a complete novice to AS, I'm still at a loss to understand it.

So can we work with a simple example?

On the stage I have a movie clip in which I have a button, instance name myButton.

Also on the stage (outside of the aforementioned clip) is a square, instance name mySquare.

In my simple example, I want to change the alpha of the square to .5. My ActionScript (which is in inside the movie clip with the button) works fine of course when the square is in the same movie clip as the button.

Code:
myButton.addEventListener(MouseEvent.CLICK, blueSquare);
function blueSquare (evt:MouseEvent): void
{
	mySquare.alpha = .5;
}
But I cannot find a rudimentary explanation or example of what the code should look like when I want to reference that square if it is on the same level as the movie clip that has the code referencing it, i.e. is outside of the movie clip.

From another thread I found the following, which when changed for my use:

Code:
myButton.addEventListener(MouseEvent.CLICK, blueSquare);
function blueSquare (evt:MouseEvent): void
{
	this._parent.mySquare.alpha = .5;
}
But I get a _parent property no longer supported error. Out of frustration I've tried variations (this.parent....; _root.mySquare....; root.mySquare....)

I feel not knowing how to do something as rudimentary as this is holding back my learning the more advanced ActionScript. Your help will be greatly appreciated.
tommyzDad is offline   Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:09 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.