Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access variable in main movie from loaded movie 1

Status
Not open for further replies.

goaganesha

Programmer
Dec 4, 2001
178
BE
Hi there,
I have a site in which I want to load different movies like cascading windows.
In my main movie I have defined a variable "top". When I load a new window(read swf) by clicking a button, the level to which the new window is loaded is defined as _root.top+1 to make shure the new window is always on the top level. These windows are also dragable. My problem is that when more than 1 window is loaded on top of another, and i want to drag the top window, for some reason the window which was loaded first (and isn't on the top level) is being dragged. therefor I only want the windows to be draggable if they are on the top level.
I tried it by using this code:
if (this._level == _root.top)
{
if ((_root._xmouse < boundsd.xMax) && (_root._xmouse > boundsd.xMin) && (_root._ymouse < boundsd.yMax) && (_root._ymouse > boundsd.yMin))
{
startDrag(_root.venstertje,false,242,250,518,268);
}
}

But somehow _root.top is undefined for the window when it is loaded. So my question is if it is possible to access a variable in my main movie from a loaded movie?

regards, goaganesha
 
Yes! But since every movie loaded has it's own _root level you can't use _root. In this case you should define your variable as _level0.top rather than _root.top.

Regards,

oldman3.gif
 
thanks for your reply, oldnewbie
But that doesn't do the trick either

this code gives me &quot;undefined&quot; in the outputconsole:

onClipEvent(load)
{
trace(_level0.top);

}

regards, goaganesha
 
Well of course, until the variable is defined or changed, it's a sure thing that it will be traced as undefined!

So each time you load a new movie on another level, the variable _level0.top has to be updated to reflect the new value, in fact the new level. So checking the value of _level0.top from anywhere, it should hold the latest value it was given, thus the last level a movie was loaded on.

Thought that was the sense of your question! Regards,

oldman3.gif
 
You were right, I was forgotten that the the movie where var top is defined also was loaded on level100 so in fact it was _level100.top
regards, goaganesha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top