Copy link to clipboard
Copied
Hi! I'm having a problem with getting this code working, basically I want to drag and drop two things onto another the things dissapear then it moves onto a new page, the first item works properly but then the second item wont dissapear and remains stuck to the cursor. Heres the code I'd be greatful of any help.
import flash.events.MouseEvent;
import fl.motion.MotionEvent;
stop();
Back6_btn.addEventListener(MouseEvent.CLICK, onBack6Click)
function onBack6Click(event:MouseEvent):void{
gotoAndPlay("Bedroom2");
}
Forward6_btn.addEventListener(MouseEvent.CLICK, onForward6Click)
function onForward6Click(event:MouseEvent):void{
gotoAndPlay('Brother bit');
}
var inGran:Number=0;
Gin.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
Tonic.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
function dragOn(event:MouseEvent):void {
event.target.startDrag(false);
}
{
stage.addEventListener(MouseEvent.MOUSE_UP, dragOff);
}
function dragOff(event:MouseEvent):void {
event.target.stopDrag();
if (event.target.dropTarget!=null&&event.target.dropTarget.parent==Gran) {
event.target.visible=false;
inGran++;
}
stage.removeEventListener(MouseEvent.MOUSE_UP, dragOff);
}
function checkPage(e:Event):void {
if (inGran==2) {
gotoAndPlay("Bedroom1");
}
}
Copy link to clipboard
Copied
try:
import flash.events.MouseEvent;
import fl.motion.MotionEvent;
stop();
Back6_btn.addEventListener(MouseEvent.CLICK, onBack6Click)
function onBack6Click(event:MouseEvent):void{
gotoAndPlay("Bedroom2");
}
Forward6_btn.addEventListener(MouseEvent.CLICK, onForward6Click)
function onForward6Click(event:MouseEvent):void{
gotoAndPlay('Brother bit');
}
var inGran:Number=0;
Gin.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
Tonic.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
function dragOn(event:MouseEvent):void {
event.currentTarget.parent.addChild(event.currentTarget);
event.target.startDrag(false);
}
{
stage.addEventListener(MouseEvent.MOUSE_UP, dragOff);
}
function dragOff(event:MouseEvent):void {
event.target.stopDrag();
if (event.target.dropTarget!=null&&event.target.dropTarget.parent==Gran) {
event.target.visible=false;
inGran++;
}
stage.removeEventListener(MouseEvent.MOUSE_UP, dragOff);
}
function checkPage(e:Event):void {
if (inGran==2) {
gotoAndPlay("Bedroom1");
}
}
Copy link to clipboard
Copied
Hi, thanks again for the quick reply but this code is just doing the same as the original
Copy link to clipboard
Copied
you have some mismatched brackets, change your target properties to currentTarget (and i'm not sure you're dropping onto the correct target) but, try:
import flash.events.MouseEvent;
import fl.motion.MotionEvent;
stop();
Back6_btn.addEventListener(MouseEvent.CLICK, onBack6Click)
function onBack6Click(event:MouseEvent):void{
gotoAndPlay("Bedroom2");
}
Forward6_btn.addEventListener(MouseEvent.CLICK, onForward6Click)
function onForward6Click(event:MouseEvent):void{
gotoAndPlay('Brother bit');
}
var inGran:Number=0;
Gin.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
Tonic.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
function dragOn(event:MouseEvent):void {
event.currentTarget.parent.addChild(event.currentTarget);
event.target.startDrag(false);
stage.addEventListener(MouseEvent.MOUSE_UP, dragOff);
}
function dragOff(event:MouseEvent):void {
event.target.stopDrag();
if (event.target.dropTarget!=null&&event.target.dropTarget.parent==Gran) {
event.target.visible=false;
inGran++;
}
stage.removeEventListener(MouseEvent.MOUSE_UP, dragOff);
}
function checkPage(e:Event):void {
if (inGran==2) {
gotoAndPlay("Bedroom1");
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now