Results 1 to 6 of 6

Thread: button problems

  1. #1
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default button problems

    Hello. I'm fairly new to the world of actionscript so let me try to explain what I'm trying to do in details. In scene one I have 2 movie clips (homepage (2) musicpage (3)). Inside the homepage movieclip is another movie clip(bckground2) with my animations. at the end of the last frame in the timeline my button pops up (musicbutton). So the idea is when a user clicks the button they navigate back to musicpage (frame3) in the main scene. I tried using this code "_root.gotoAndPlay(3) but is doesn't work properly. can someone help me come up with a code?

  2. #2
    Join Date
    Oct 2006
    Location
    New York, NY, USA
    Posts
    258
    Thanks
    42
    Thanked 24 Times in 24 Posts

    Default copy code from Movie Explorer

    Quote Originally Posted by drosster View Post
    _root.gotoAndPlay(3)
    Looks like ActionScript 2 or 1. In what they referred to as ActionScript 1, code was placed on the button (object on Stage). ActionScript 2 used anonymous functions in timeline. The symbol instances need to be named so you can "talk" to them with ActionScript, and you need to specify the event --
    Code:
    e.g., for AS 1
    on(press) { gotoAndPlay(3); } 
    or for AS 2
    this.blue_mc.onPress = function () 
    { gotoAndStop(2); }
    The keyword this would reference the current timeline so you could use dot syntax to address nested movie clips -- this.blue_mc.nested_mc.onPress =

    Referencing the main timeline (_root or root) from within nested movie clips can be tricky. A simple solution would be to have buttons on Stage. What version Flash are you using?

    It's hard to visualize what you are doing. Open Window>Movie Explorer and copy the code to clipboard and then paste that into a post so we might see what you have.

  3. The Following User Says Thank You to auntnini For This Useful Post:

    drosster (11-24-2011)

  4. #3
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    thank you auntnini from replying. I'm using cs 5.5. The code worked Thanks so much!!
    Last edited by drosster; 11-24-2011 at 06:46 AM.

  5. #4
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    I just bumped into a new problem. the code worked just fine but now I added a preloader scene. now when you press the button instead of navigating to the laboratory page it goes to the preloader scene. what additional code would I need to navigate to scene 2?
    Last edited by drosster; 11-24-2011 at 07:36 AM.

  6. #5
    Join Date
    Oct 2006
    Location
    New York, NY, USA
    Posts
    258
    Thanks
    42
    Thanked 24 Times in 24 Posts

    Default if/else logic needed

    It is safer to create a LABEL for frames because numbers may change if you add/delete frames. Click frame in timeline and enter LABEL info in Properties panel. You should have some IF/ELSE logic when bytesLoaded -- bytesTotal to go back to and repeat preloader frame or proceed on to animation frame.

    With FLASH CS 5.5 you can choose between creating an ActionScript 2.0 or ActionScript 3.0 document. The two versions are not compatible. AS3.0 is more complicated but worth learning if you are serious about working with Flash.

    Here is AS3.0 sample preloader code
    Code:
    Scene 1
    Actions for Frame 1
    stop();
    this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoading);
    this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
    function onLoading(evt:ProgressEvent):void {
    var loaded:Number = evt.bytesLoaded / evt.bytesTotal; 
    percent_txt.text = (loaded*100).toFixed(0) + "%";
    };
    function onComplete(event:Event):void { 
    this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoading);
    this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
    gotoAndStop(2); 
    };

  7. #6
    Join Date
    Oct 2006
    Location
    New York, NY, USA
    Posts
    258
    Thanks
    42
    Thanked 24 Times in 24 Posts

    Default old code

    Here's some OLD ActionScript 2.0 code referencing (_level0.dummy_mc._framesloaded == _level0.dummy_mc._totalframes)

    Code:
    Scene 1
    Actions for Frame 1
    //_level0.dummy_mc.content._lockroot = true; _root.onEnterFrame = function() {
    //loadMovieNum("preloader.swf", 2);
    loadText = Math.round((dummy_mc.getBytes.Loaded() / dummy_mc.getBytesTotal())*100) + " % Loaded";
    };
    
    
    /*var percent = Math.round(_level0.dummy_mc.getBytesLoaded() / _level0.dummy_mc.getBytesTotal())*100;
    _level0.loadText = (percent) = " % loaded";
    }; */
    
    
    start_btn.onPress = function() {
    loadMovieNum("preloader.swf", 2);
    loadMovie("slideLoad.swf", dummy_mc);
    };
    _level0.onEnterFrame = function() {
    if (_level0.dummy_mc._framesloaded == _level0.dummy_mc._totalframes) {
    unloadMovieNum(2);
    _level0.load_txt._visible = false;
    }
    };
    stop_btn.onPress = function() {
    unloadMovieNum(2);
    unloadMovie(dummy_mc);
    };
    Actions for Frame 5
    stop();
    
    
    loaderMC
    Loader, ‹dummy_mc›
    circleBUTTON, ‹start_btn›
    circleBUTTON, ‹stop_btn›
    (empty), (loadText), ‹load_txt›

  8. The Following User Says Thank You to auntnini For This Useful Post:

    drosster (12-07-2011)

Bookmarks

Posting Permissions

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