Copy link to clipboard
Copied
var mc_Dog1:WagDog = new WagDog();
addChild(mc_Dog1);
//mc_Dog1.x = 50; I have this in my ENTER_FRAME event handler)
mc_Dog1.y = 20;
mc_Dog1.width = 140;
mc_Dog1.height = 120;
addEventListener(Event.ENTER_FRAME, dogMove);
function dogMove(event:Event):void
{
if (mc_Dog1.x < (stage.stageWidth+25)) {
mc_Dog1.x += 2;
//myCursor.mouseEnabled=false; The commented custom cursor is also a movie clip, I need this format as in my animated quiz I am also using drag and drop)
//Mouse.hide();
//myCursor.x = root.mouseX;
//myCursor.y = root.mouseY;
}else{
mc_Dog1.x = -25;
}
}
you can use one or two enterframe listeners. eg,
a) 1 listener
this.addEventListener(Event.ENTER_FRAME,f)
function f(e:Event):void{
f1();
f2();
}
b) 2 listeners
this.addEventListener(Event.ENTER_FRAME,f1);
this.addEventListener(Event.ENTER_FRAME,f2)
Copy link to clipboard
Copied
you can use one or two enterframe listeners. eg,
a) 1 listener
this.addEventListener(Event.ENTER_FRAME,f)
function f(e:Event):void{
f1();
f2();
}
b) 2 listeners
this.addEventListener(Event.ENTER_FRAME,f1);
this.addEventListener(Event.ENTER_FRAME,f2)
Copy link to clipboard
Copied
okay cool I will try this out, thank you for your prompt reply.
I am so near the end of my assignment, just need this and a couple of other things to work and it's finished.
Cheers
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
this.addEventListener(Event.ENTER_FRAME, f);
function f (event:Event):void{
//TypeError: Error #1009: Cannot access a property or method of a null object reference.
// at Pet_Intelligence_QuizV15_fla::MainTimeline/f2()
// at Pet_Intelligence_QuizV15_fla::MainTimeline/f()
/*
at Pet_Intelligence_QuizV15_fla::MainTimeline/frame4()[Pet_Intelligence_QuizV15_fla.MainTimeline::frame4:151] |
at flash.display::MovieClip/gotoAndStop()
at Pet_Intelligence_QuizV15_fla::MainTimeline/Begin()[Pet_Intelligence_QuizV15_fla.MainTimeline::frame2:42]
Debug session terminated.
*/
f1();
f2();
}
function f1():void
{
if (mc_Dog1.x < (stage.stageWidth+25)) {
mc_Dog1.x += 2;
}else{
mc_Dog1.x = -25;
}
}
myCursor.mouseEnabled=false;
// hide the real mouse
Mouse.hide();
// show where the function we made when we made our event listener
function f2():void {
// make our custom cursor's position equal the real mouse's position
myCursor.x = root.mouseX;
myCursor.y = root.mouseY;
}
I have tired in so many different ways to get these two enter frames to work together on the one frame. somewhere between frame 2, my login screen and frame 4 my question screen.
I have a go to and play from frame two and then the error then stops when my xml is to be loaded, if I don't bother with my custom cursor it works fine, go figure..lol However I need the custom cursor on all frames for a pass at the least.
Have tried even as my lecturer has suggested and that is no better.
Can you see if I have made any fundamental errors in the code above?
Cheers
Copy link to clipboard
Copied
if that code is on the main timeline remove the root reference. otherwise use MovieClip(root)
Copy link to clipboard
Copied
Have tried both of your suggestions, still not working. Will give it a break and try my lecturer again tomorrow... there is definitely something to do with the one the location and two possible the placing of the code in that frame.
Very interesting problem.
Copy link to clipboard
Copied
Hello again, I forgot to give my custom cursor an instance name for this frame of myCursor, my bad.
MovieClip(root) makes it work perfectly.
All I need to do now is how the custom cursor be on top of all the objects rather than underneath my drag and drop movie clips.
Is there another step?
Thank you so much for your help this at least gets me a pass for my assignment
Copy link to clipboard
Copied
you're welcome.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now