I have a flash game that has the ‘drag and drop’ feature. The drag and drop works fine on the timeline (the main timeline) but the drag and drop feature that i have inside a movie clip doesnt work the same even tho the code is exactly the same. (i copied and pasted)
is this bcos it is in a movie clip? What extra coding wud I need to add to fix this issue?
this is the code that works in the timeline but not the movie clip… they are the same code used over an over
onClipEvent (load) {
origX = this._x;
origY = this._y;
}
onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.startDrag();
_root.answer1="";
}
}
onClipEvent (mouseUp) {
if (this.hitTest(_root._xmouse, _root._ymouse)) {
this.stopDrag();
_root.answer1 = "wrong";
// see if the dropZone conatins the center of this mc
if (_parent.dropZone1.hitTest(this._x,this._y,true)) {
// center it on the drop zone
this._x = _parent.dropZone1._x;
this._y = _parent.dropZone1._y;
} else {
// return it to its original location
this._x = origX;
this._y = origY;
}
}
}
Where is dropZone1 located? If it is on the main timeline you can change _parent to _root. If it is not then you’ll have to adjust the path to it. Basically all _parent does is say go up and out one timeline from where the code is written and look for the object after the “.”
sorry i dont think i explained it well enough. Ive used the same code throughout the game (for drag n drop) but wen published the whole thing works but the ‘correct’ and ‘wrong’ feature doesnt show within the movie clip) but works fine on the timeline.
Maybe I can send you the file, cos i dont think im explaining it well.
it won’t work inside a movieclip because the paths have changed. _root.something is now _root.MC1.something.
Are you familiar with the target tool? In your actionscript panel there is a button that looks like the scope on a rifle. Click it and you’ll see all the items in your file that have instance names and you’ll see how they are nested inside each other. Locate the one you want and select it and flash will automatically insert the correct path for you. You’ll notice if its different from what you have in the code.
In my game the code i use here … [COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]answer1[/COLOR] = [COLOR=#ff0000]“wrong”[/COLOR]; displays WRONG when you drop that number. Answer1 is the var name of the text box
when i use the target you mentioned i clicked on the Answer_field (this is the instance name of the text box. and i get this code come up
this._parent._parent.answer_field
now i need the text to display wrong so i made it look like this
this._parent._parent.answer_field = “wrong”
when i ran my game this didnt work. Im really confused and dont get why its not displaying the text “WRONG”.
How come i can use _root on the main timeline but It says to use this._parent._parent. within the moving clip using the target tool ??
I even tried _root.Game1_2.answer1 = “wrong” and this didnt display WRONG either. (Game1_2 is the name of my Movie Clip)
The drag and drop works fine, it just wont display the text I ask it to.