#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Posts
    5
    Rep Power
    0

    ActionScript 3 - Making Multiple Scripts Work Together


    I am creating a Flash header for class and two things need to happen - One, it needs a stop and start button, and 2 it has to be clickable.

    I have the code for each one and they do work separately, but when I try to apply both, only one will work. Here are the codes that I am using:

    For Stop and Start
    Actionscript Code:
    start_btn.addEventListener(MouseEvent.CLICK, startMove);
    stop_btn.addEventListener(MouseEvent.CLICK, stopMove);
     
    function startMove(e:MouseEvent):void {
    	play(); 
    }
    function stopMove(e:MouseEvent):void {
    	stop(); 
    }


    For Clickable Link
    Actionscript Code:
    var movieContainer:MovieClip;
     
    var movieLoader:Loader = new Loader();
     
    movieLoader.load(new URLRequest("header.swf"));
     
    movieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
    movieLoaded_fn);
    function movieLoaded_fn(e:Event): void {
     
    movieContainer = movieLoader.content as MovieClip;
     
    addChild(movieContainer);
     
    movieContainer.x = 100;
     
    movieContainer.addEventListener(MouseEvent.CLICK, callFunction_fn);
     
    }
    function callFunction_fn(e:MouseEvent): void {
     
    navigateToURL(new URLRequest("url is here"));
     
    };


    I have tried reversing them in the actions panel but to no avail. Any help would be greatly appreciated.
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,675
    Rep Power
    3164
    It's because you are making the entire clip clickable so that means that whenever the stop and start buttons are pressed it is also counted as a click against the movie clip as a whole. An easy way to get around this is to create a large block in the same clip as the start and stop buttons, place it behind the stop and start buttons. Make the large block a MovieClip and then make that clickable instead of the whole clip as you currently are. That way the start and stop buttons will be on top so the larger click won't be triggered.
    Quis custodiet ipsos custodes?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Posts
    5
    Rep Power
    0
    Thank you so much for responding, I will try what you suggested and report back. Thanks again
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Posts
    5
    Rep Power
    0
    All is good now, everything is working as it should. Thank you again, I really appreciate it.

IMN logo majestic logo threadwatch logo seochat tools logo