Well, lets assume that all you are doing is on frame # 12. Your mc that you
drag is instanced on frame # 12. When the playhead reaches frame #12 it is
going to execute your code on the main time line once:
if (obj1==1)
{
play();
}
at this point obj1 is not declared yet. Then when the user does the drag and
drop, you execute your other code where you declare obj1, and that's it.
finished.
If you put some trace statement you will see the order of execution, ie:
main timeline:
trace("timeline 1: " + obj1) ;
if (obj1==1)
{
trace("timeline 2: " + obj1) ;
play();
}
trace("timeline 3: " + obj1) ;
your object:
on (press)
{
trace("startDrag: " + this._name) ;
this.startDrag();
obj1 = 0;
}
on (release)
{
trace("stopDrag: " + this._name) ;
stopDrag();
if (eval(this._droptarget) == _root.area1)
{
this._x = _root.area1._x;
this._y = _root.area1._y;
obj1 = 1;
trace("stopDrag droptarget: " + obj1) ;
}
}
you will get in the output:
timelime 1: undefined
timelime 3: undefined
startDrag: yourobjectname
stopDrag: yourobjectname
stopDrag droptarget: 1
Now lets assume that obj movieclip is on the main stage and not nested in
another movieclip, what happens also is that you declare obj1 under your
object so _root.obj.obj1 is different from _root.obj1
You need to do two things.
1:
on your object when you declare obj1, you should declare it like,
_root.obj1, so that it gets created in the timeline your object is. Then
call a function like _parent.checkObj()
code for obj:
on (press)
{
this.startDrag();
_root.obj1 = 0; //CHANGE
}
on (release)
{
stopDrag();
if (eval(this._droptarget) == _root.area1)
{
this._x = _root.area1._x;
this._y = _root.area1._y;
_root.obj1 = 1; //CHANGE
_parent.checkObj(); //ADDITION
}
}
and in the timeline your code should look like:
function checkObj() {
if (obj1==1)
{
_root.play();
}
}
[quoted text, click to view] "IndioDoido" <webforumsuser@macromedia.com> wrote in message
news:ejmsq9$114$1@forums.macromedia.com...
> hey Jose...
>
> No, the onlything i have on the main timeline is this:
>
> if (obj1==1)
> {
> play();
> }
>
> What do i need to do, trigger the if statement in my main timeline?
> :confused;