all groups > flash actionscript > november 2006 >
You're in the

flash actionscript

group:

Actionscript doubt...


Re: Actionscript doubt... Jose Guevara
11/17/2006 5:37:35 PM
flash actionscript:
if (eval(this._droptarget) == _root.area1) _root.play() ;

?

you have nothing triggering the if statement in your main timeline... (do
you?)

JG



[quoted text, click to view]

Actionscript doubt... IndioDoido
11/17/2006 7:23:23 PM
Simple question...

I have this code on a object that's on the stage:

on (press)
{
this.startDrag();
obj1 = 0;
}
on (release)
{
stopDrag();
if (eval(this._droptarget) == _root.area1)
{
this._x = _root.area1._x;
this._y = _root.area1._y;
obj1 = 1;
}
}

And this code on the main timeline of the stage:

if (obj1==1)
{
play();
}

Why doesn't the movie play?

i tryed to use _global.obj1 = 1; but it doesn't work either :-S
pleaaassseee heeeeeeelllllllpppppp!!!!
Re: Actionscript doubt... IndioDoido
11/18/2006 12:00:00 AM
hey Jose...

No, the onlything i have on the main timeline is this:

if (obj1==1)
{
play();
}

Re: Actionscript doubt... Jose Guevara
11/18/2006 11:20:15 AM
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]

Re: Actionscript doubt... IndioDoido
11/19/2006 12:17:06 AM
Thanks alot Jose...
The code works perfectly !!!!
Re: Actionscript doubt... Jose Guevara
11/19/2006 3:32:26 PM
no problems :-)


[quoted text, click to view]

AddThis Social Bookmark Button