A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Can't go to frame 2

Hybrid View

  1. #1
    Senior Member QBA's Avatar
    Join Date
    Feb 2001
    Location
    Toronto, Canada
    Posts
    312

    Can't go to frame 2

    Hi

    I have a Movieclip called "Button" with two frame inside, frame 1 and 2. I want that in rollover the button go to play it's frame 2 but is not working.

    On rollover the movie "Button", the mouse arrow changed to the hand but nothing happend.

    This is the script I'm using:

    this.Button.onRollOver = function() {
    gotoAndPlay(2);

    }

    Any ideas?

    Thanks

    Alex

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    You shouldn't use Button as the instance name.
    It's the name of a Class, and starts with upper case.

    Use lowercase instead. Something like my_btn.

    You need to specify the movie clip you want to control:
    code:

    my_mc.gotoAndPlay(2);


    In this case you use the keyword this:
    code:

    my_btn.onRollOver = function() {
    this.gotoAndPlay(2);
    }


    which is the same as:
    code:

    my_btn.onRollOver = function() {
    my_btn.gotoAndPlay(2);
    }


  3. #3
    Senior Member QBA's Avatar
    Join Date
    Feb 2001
    Location
    Toronto, Canada
    Posts
    312
    Thanks nunomira, it works

    I did what you told me and it works and I tried something else that works too:

    Button1.onRollOver = function() {
    this.gotoAndPlay(2);
    }

    or

    _root.Button1.onRollOver = function(){

    this.gotoAndPlay(2);
    }


    Thanks


    nunomira, now I want to do it a little bit more complicated but is not working


    I have the movie clip "Button1" inside a swf that is loading on level 4, and I want to have the script this time on level0 or the main swf but is not working

    _root.level4.Button1onRollOver = function () {
    this.gotoAndPlay("R_Over");

    }

    any other ideas?

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    That would be:
    code:

    _level4.Button1.onRollOver = function () {
    this.gotoAndPlay("R_Over");
    }


    but this has to be defined after the movie loads on _level4, and Button1 exists.

    I suggest you read understanding target paths.

    Don't use _root, use relative notation instead whenever possible.

  5. #5
    Senior Member QBA's Avatar
    Join Date
    Feb 2001
    Location
    Toronto, Canada
    Posts
    312
    Thanks nunomira, for some reason is not working:

    _level4.Button1.onRollOver = function () {
    this.gotoAndPlay(2)
    }

    I attached the small test file for you to take a look if you have a sec.

    By the way thanks for the link "understanding target paths" I'm reading it right now
    Attached Files Attached Files

  6. #6
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Like I said, that has to be defined after the movie loads on _level4, and Button1 exists. This means you have to preload the external movie.
    code:

    // preload the external movie using MovieClipLoader Class
    // create MovieClipLoader Object and Listener Object
    var mcl:MovieClipLoader = new MovieClipLoader();
    var mcll:Object = new Object();
    // when the movie finishes loading
    mcll.onLoadInit = function(mc:MovieClip)
    {
    // mc is the target, _level4 in this case
    mc.Button1.onRollOver = function()
    {
    this.gotoAndPlay(2);
    };
    };
    // add the Listener Object mcll to the MovieClipLoader Object
    mcl.addListener(mcll);
    // load the movie TestMenu1.swf, and _level4 is the target
    mcl.loadClip("TestMenu1.swf", 4);



    Read loading movies now

  7. #7
    Senior Member QBA's Avatar
    Join Date
    Feb 2001
    Location
    Toronto, Canada
    Posts
    312
    Thanks alot nunomira I works !!!

    I'm printing both tutorials right now

  8. #8
    Senior Member QBA's Avatar
    Join Date
    Feb 2001
    Location
    Toronto, Canada
    Posts
    312
    nunomira, I created that simple testMain.fla just to get it to work so I could add the working script to my working file. but now I can't get it to work


    this is my script that will load diferent movies on my working file, everything is working but I can't target the "menu.swf" on level 4. this script is similar to the one you did.


    var MasterLoader:MovieClipLoader = new MovieClipLoader();
    //----Creating a variable "MasterListener" (Object) That will listen or check....\\
    //-------for what is heppening with the movie being load----------\\
    var MasterListener:Object = new Object();
    MasterLoader.addListener(MasterListener);
    // when the movie starts loading, stop it, and hide it
    MasterListener.onLoadStart = function(target_mc) {
    target_mc._visible = false;
    target_mc.stop();
    };

    // when the movie has loaded, play and show it
    MasterListener.onLoadInit = function(target_mc) {
    target_mc._visible = true;
    target_mc.play();
    };

    This is the function you made I just change the movie label name and "mc" for "targer_mc" but is not working. Everything in this code works fine but this part, and I can't still get to target the level 4 "HomeBtn"

    Code:
       	   target_mc.homeBtn.onRollOver = function()
    	{
    		this.gotoAndPlay("R_Over");
    	};
    //---Loading external swf----\\

    MasterLoader.loadClip("Menu.swf", 4);
    Last edited by QBA; 07-11-2006 at 11:27 AM.

  9. #9
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    I'm not sure if I follow...

    You've just changed the name of the objects, right?

    In your code, you place
    code:

    target_mc.homeBtn.onRollOver = function()
    {
    this.gotoAndPlay("R_Over");
    };


    outside the onLoadInit(). It should be inside!

  10. #10
    Senior Member QBA's Avatar
    Join Date
    Feb 2001
    Location
    Toronto, Canada
    Posts
    312
    nunomira I tried placing the code inside onLoadInit(). and outside and is not working either.


    Code:
    var MasterLoader:MovieClipLoader = new MovieClipLoader();
    //----Creating a variable "MasterListener" (Object) That will listen or check....\\
    //-------for what is heppening with the movie being load----------\\
    var MasterListener:Object = new Object();
    MasterLoader.addListener(MasterListener);
    // when the movie starts loading, stop it, and hide it
    MasterListener.onLoadStart = function(target_mc) {
    	target_mc._visible = false;
    	target_mc.stop();
    };
    // when the movie has loaded, play and show it 
    //function swfLoaded(nextSWF, target_mc) {
    	MasterListener.onLoadInit = function(target_mc) {
    		target_mc._visible = true;
    		target_mc.play();
    		
    	            target_mc.homeBtn.onRollOver = function()
    	{
    		this.gotoAndPlay("R_Over");
    	};
       };
    
     MasterLoader.loadClip("Menu.swf", 4);
    Any ideas why I can't control the "homeBtn" moviclip that in on "Menu.swf" level 4 ?
    Last edited by QBA; 07-12-2006 at 12:59 PM.

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