A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Movie Clip help

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    9

    Movie Clip help

    So this is a weird error that I am getting because I have four movie clips on my frame that I have running back and forth across the screen in a frogger like game. Three of them work and the fourth one does not even though I have the same code basically for all of them. Why would I get an error for one, but not the other 3? Here is my code:

    PHP Code:
    if((chris.laneOne) >= && !turn1){
        
    chris.scaleX 1;
        
    chris.-= laneOne;
        
    turn1 false;
    }else{
        
    turn1 true;
    }
    if((
    chris.laneOne) <= 500 && turn1){
        
    chris.scaleX = -1;
        
    chris.+= laneOne;
        
    turn1 true;
    }else{
        
    turn1 false;
    }
    //Lane 2
    if((kate.laneTwo) >= && !turn2){
        
    kate.scaleX 1;
        
    kate.-= laneTwo;
        
    turn2 false;
    }else{
        
    turn2 true;
    }
    if((
    kate.laneTwo) <= 500 && turn2){
        
    kate.scaleX = -1;
        
    kate.+= laneTwo;
        
    turn2 true;
    }else{
        
    turn2 false;
    }
    //Lane 3
    /*if((seth.x - laneThree) >= 0 && !turn3){
        seth.scaleX = 1;
        seth.x -= laneThree;
        turn3 = false;
    }else{
        turn3 = true;
    }
    if((seth.x + laneThree) <= 500 && turn3){
        seth.scaleX = -1;
        seth.x += laneThree;
        turn3 = true;
    }else{
        turn3 = false;
    }*/
    //Lane 4
    if((mel.laneFour) >= && !turn4){
        
    mel.scaleX 1;
        
    mel.-= laneFour;
        
    turn4 false;
    }else{
        
    turn4 true;
    }
    if((
    mel.laneFour) <= 500 && turn4){
        
    mel.scaleX = -1;
        
    mel.+= laneFour;
        
    turn4 true;
    }else{
        
    turn4 false;

    Seth is the one that doesn't work, but basically this makes these movie clips of running characters look like they are running back and forth and the lanes is the speed at which they go and the turns are just to make sure that they go all the way to the side.

    That is my first question.

    My second question is I have a character on the same frame and I want to move him via the keyboard and I am using senocular's keyObject class and it doesn't work unless if I minimize the screen and then re-open the screen. Once I re-open the screen it works just fine.

    I have a hunch that both of these problems are related to a movie clip not being fully loaded, but I am new to flash and as3 so any help would be greatly appreciated. Also if more clarification is needed please ask for it so I can get some help cause I have had this problem for about 2 days now and still can't figure it out!

  2. #2
    Senior Member
    Join Date
    Apr 2009
    Posts
    117
    should work :s make sure all variables are set properly and re write the whole of the seth part, you might come across an error thats hidden away :P copy mel part and then paste it in and replace mel with seth and change the numbers etc.. also make sure the MC is given the correct instance name

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    9
    haha thanks, I guess I will try rewriting the seth part. However what could cause my second question? I have to minimize the screen before my main character moves with the keyboard, but only when I minimize it and it is not I have to wait 10 seconds I can do it right away or wait 30 seconds and then my main character will move.

    Also I tried re-writing the seth part, but got the same error which I forgot to mention is: #1009 cannot access a property or method of null object reference.
    Last edited by csnader; 07-19-2010 at 02:07 PM.

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    What is the error you are getting?
    How are you loading movie clips, (on-stage, from library, from class, external)?

    Is the key problem occuring when you are testing the file in the IDE ( with 'Disable Keyboard Shortcuts' selected ) or in the HTML file?

  5. #5
    Junior Member
    Join Date
    Jul 2010
    Posts
    9
    My error message is right above your post and I am loading them in from the library, I know it should be from a class, but I am just trying to get something the works currently.

    Also I am testing in the IDE.

  6. #6
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Can you post a stripped down version of your .fla (CS4 or lower) here?

  7. #7
    Junior Member
    Join Date
    Jul 2010
    Posts
    9
    here is slimmed down version of the game. I created it in CS4.
    Attached Files Attached Files

  8. #8
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Give the instance of 'seth_run' on frame 2 an instance name, example 'demo_seth'.

    In frame 2, added line 'play_button.mouseChildren=false;' below line 'play_button.setLabel("Play");' (I don't have the code for setLabel, so I commented out that line.)


    Added import statement on frame 3, 'import com.senocular.utils.KeyObject;'
    Last edited by dawsonk; 07-29-2010 at 08:52 AM.

  9. #9
    Junior Member
    Join Date
    Jul 2010
    Posts
    9
    Quote Originally Posted by dawsonk View Post
    Give the instance of 'seth_run' on frame 2 an instance name, example 'demo_seth'.

    In frame 2, added line 'play_button.mouseChildren=false;' below line 'play_button.setLabel("Play");' (I don't have the code for setLabel, so I commented out that line.)


    Added import statement on frame 3, 'import com.senocular.utils.KeyObject;'
    Thanks a lot dawsonk, yeah that did it for some reason. I did the same thing with kate that I had done with seth so I am not really sure what was going on, but I still don't have an answer for the second question.

  10. #10
    :
    Join Date
    Dec 2002
    Posts
    3,518
    After I made the changes, I wasn't having any problems with key controls...

  11. #11
    Junior Member
    Join Date
    Jul 2010
    Posts
    9
    well alrighty... then I am not sure what is going on because I am still getting the same error with the keyboard movements. I am not sure why, but I guess I will troubleshoot it. Maybe it has to do with the Dynamic Button class from the previous scene?

  12. #12
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Can you post the class?

  13. #13
    Junior Member
    Join Date
    Jul 2010
    Posts
    9
    Okay here is my class in a text file.

    I got this from a tutorial online somewhere, so I just assumed it would work correctly.
    Attached Files Attached Files

  14. #14
    :
    Join Date
    Dec 2002
    Posts
    3,518
    This class combined with your code results in a problem, commenting out all the code on frame 2, as the keys work fine.
    Last edited by dawsonk; 07-19-2010 at 06:18 PM.

  15. #15
    Junior Member
    Join Date
    Jul 2010
    Posts
    9
    I have now moved away from using a class and just using a simple button, now correct me if I am wrong, but the below code should work, well actually it does, but I still get the error I was getting with the class.
    Here is the code I am using:

    PHP Code:
    stop();
    playGame.addEventListener(MouseEvent.CLICKbuttonClicked);
    var 
    clicked:Boolean false;
    function 
    buttonClicked(event:MouseEvent){
        
    clicked true;
        
    this.gotoAndStop('start');


    Any thoughts why this may be?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center