PDA

View Full Version : access display objects from within scrollpane instance?



Wheels
October 8th, 2007, 11:36 AM
Hi all,

I've seen several posting on various sites with this question but never found an answer that actually works.

Very simply, I create an instance of a scrollpane on my stage and I load in a mc from my library that has another mc nested within. I want to access that nested mc and I don't seem to be able to:


import flash.display.MovieClip;
import fl.containers.ScrollPane;
//MyBox is the class name of the mc in my library
var myMovieClip:MyBox = new MyBox();
//
var myScrollPane:ScrollPane = new ScrollPane();
myScrollPane.name = "myScrollPane";
myScrollPane.source = myMovieClip;
addChild(myScrollPane);
trace(myScrollPane.content.nested_mc.alpha)
When I run this I get the following error:

1119: Access of possibly undefined property nested_mc through a reference with static type flash.display:DisplayObject.

I've tried to access the nested_mc by using the content property as I've seen noted in one post on actionscript.org like this:


trace(MovieClip(myScrollPane.content.nested_mc).al pha)but I get the same error...

What gives? What is the best way to access content within the scrollpane component?

Any advice is greatly appreciated!

soulwire
October 8th, 2007, 01:18 PM
have you tried putting a trace(this) inside the nested mc and see what it outputs? This should give you the internal path that Flash is using, so you can work the rest out from that.

Wheels
October 8th, 2007, 01:52 PM
Duh! I'm a frakin' idiot!

I just had the parenthesis in the wrong place. This traces correctly:


trace(MovieClip(myScrollPane.content).nested_mc.al pha)

Thanks for the kick in the arse soulwire. Thinking about the path of the nested_mc was what made me realize my mistake.

soulwire
October 9th, 2007, 05:47 AM
;)