all groups > flash actionscript > december 2005 >
You're in the

flash actionscript

group:

eval and _droptarget


eval and _droptarget Popeye the Sailorman
12/18/2005 3:01:23 PM
flash actionscript:
Can anyone explaying me why the following three examples result in the
corresponding output? In the documentation is stated that eval convert from '/'
notation to dot notation. In example 1 this is not the case. Only if I add
"_root" the conversion is what I expect it to be. Short explanation: hotbar is
a movieclip with parent mcTitle. mcTitle is a movieclip on _root.

1. trace(eval(mcTitle._droptarget));
2. trace(eval("_root" + mcTitle._droptarget));
3. trace(eval("_root"+ eval(mcTitle._droptarget))._name)

gives as output:

1. /mcTitle/hotbar
2. _level0.mcTitle.hotbar
3. _level0.mcTitle.hotbar

Re: eval and _droptarget kglad
12/18/2005 6:30:56 PM
Re: eval and _droptarget Popeye the Sailorman
12/18/2005 7:52:47 PM
I am dropping MovieClips. The clips are to be used as a kind of menu with a
title bar 'mcTitle'. This title bar has a child, a movieclip called 'hotbar'
has the onPress and onRelease event. I was just surprised by the different
outputs of the trace. I have the draggin and dropping working.
Re: eval and _droptarget kglad
12/18/2005 9:55:13 PM
Re: eval and _droptarget Popeye the Sailorman
12/18/2005 10:01:35 PM
Re: eval and _droptarget kglad
12/19/2005 12:34:11 AM
i agree with jeckyl. your trace statements, output and description of what
you're doing don't make sense.

if mcTitle.hotbar is being dragged and dropped, why are you checking the
_droptarget of mcTitle (which would be undefined)?
Re: eval and _droptarget Jeckyl
12/19/2005 9:43:37 AM
[quoted text, click to view]

You won't get that output from the script you've shown .. the 2 and 3
examples produce invalid paths (because there will be no '.' between the
_root and the clip name)

Please show us EXACTLY the code you were using and the output you got ..
because the output you show here could not have come from the script you
show.
--
Jeckyl

Re: eval and _droptarget Popeye the Sailorman
12/19/2005 10:29:07 AM
OK, you are right. I am dragging movieclip mcTitle. The hotbar is a child
movieclip. I checked the statements again and now copied them (and checked
them) literally.

1. trace(eval(mcTitle._droptarget));
2. trace(eval("_root" + mcTitle._droptarget));
3. trace(eval("_root")+ eval(mcTitle._droptarget));

produces as output

1. /container5/mcTitle/hotbar
2. _level0.container5.mcTitle.hotbar
3. _level0/container5/mcTitle/hotbar

output 1: I would expect the '/' notation not to be present as described in
the documentation


Re: eval and _droptarget Popeye the Sailorman
12/19/2005 10:33:26 AM
And below a larger portion of the package code

import MenuP.*;
class MenuP.ContainerTitle {
private var barison:Boolean;
private var baron, baroff, boxOpen, boxClose, tekst:MovieClip;
private var mcTitle:MovieClip;
private var owner:Object;
public function ContainerTitle(mc:MovieClip, ow:Object) {
var obj:Object = this;
mcTitle = mc;
boxOpen = mcTitle.boxOpen;
boxClose = mcTitle.boxClose;
owner = ow;
barison = true;
boxOpen.onPress = function () {obj.onBoxPress()};
boxClose.onPress = function () {obj.onBoxPress()};
mcTitle.hotbar.onPress = function () {obj.startDragging()};
mcTitle.hotbar.onRelease = function () {obj.stopDragging()};
toon();
}
public function startDragging() {
mcTitle.startDrag(false, -9999, 0, 9999, 0);
}
public function stopDragging() {
var targetIndex:Number, mc:MovieClip;
mcTitle.stopDrag();
mc = eval("_root" + mcTitle._droptarget);
trace(eval(mcTitle._droptarget));
trace(eval("_root" + mcTitle._droptarget));
trace(eval("_root")+ eval(mcTitle._droptarget));


mc._parent._parent._y += 200;
}
}
AddThis Social Bookmark Button