简体   繁体   中英

I'm trying to create a sliding gallery in AS3 in Flash CS5, but I get these errors: does it have something to do with AS3 ?

Scene 3, Layer 'AS', Frame 1, Line 1 1119: Access of possibly undefined property onEnterFrame through a reference with static type flash.display:DisplayObject. Scene 3, Layer 'AS', Frame 1, Line 2
1119: Access of possibly undefined property _ymouse through a reference with static type flash.display:DisplayObject. Scene 3, Layer 'AS', Frame 1, Line 3 1120: Access of undefined property myVar. Scene 3, Layer 'AS', Frame 1, Line 5 1119: Access of possibly undefined property _ymouse through a reference with static type flash.display:DisplayObject. Scene 3, Layer 'AS', Frame 1, Line 6
1120: Access of undefined property myVar. Scene 3, Layer 'AS', Frame 1, Line 8 1119: Access of possibly undefined property _xmouse through a reference with static type flash.display:DisplayObject. Scene 3, Layer 'AS', Frame 1, Line 8 1120: Access of undefined property myVar. Scene 3, Layer 'AS', Frame 1, Line 17 1119: Access of possibly undefined property _xmouse through a reference with static type flash.display:DisplayObject. Scene 3, Layer 'AS', Frame 1, Line 17 1120: Access of undefined property myVar. Scene 3, Layer 'AS', Frame 1, Line 24 1119: Access of possibly undefined property _xmouse through a reference with static type flash.display:DisplayObject. Scene 3, Layer 'AS', Frame 1, Line 24 1119: Access of possibly undefined property _xmouse through a reference with static type flash.display:DisplayObject. Scene 3, Layer 'AS', Frame 1, Line 24
1119: Access of possibly undefined property _xmouse through a reference with static type flash.display:DisplayObject.**

the code is:

 enter code here
    root.onEnterFrame = function() {
    if(root._ymouse<601){
        myVar=false;
    }
    if(root._ymouse>600){
        myVar=true;
    }
    if(root._xmouse<100 && myVar==true)
    {
        imgBar.prevFrame();
        imgBar.prevFrame();
        imgBar.prevFrame();
    }
    else{
        imgBar.play;
    }
    if(root._xmouse>600 && myVar==true){
        imgBar.nextFrame();
        imgBar.nextFrame();
    }
    else{
        imgBar.play;
    }
    if(root._xmouse>100 && root._xmouse<600 && myVar==true){
    imgBar.stop();

    }
    }

Your code is in AS2. in AS3, objects use the addEventListener property instead of constructs like onEnterFrame .

Change the targeting of your project to AS2, or you can just revise the top line of code like so:

root.addEventListener(Event.ENTER_FRAME, function() {

   ... // your code

 })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM