A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: movie clips on different t/lines

  1. #1
    Junior Member
    Join Date
    Jan 2007
    Posts
    3

    movie clips on different t/lines

    Can anyone help! I am trying to get a movie clip to play on my cars.swf page. If I remove the stop() action from the first frame the movie loads ok
    BUT I want the movie to load when I press a button
    I have place stop() action on the 1st and last frame. This is the code on the button:

    on (release) {
    this.audi.Mc.play(2);
    }
    I have also tried, onreleaseGoTo

    and an instance of audi.MC on the cars.swf timeline

  2. #2
    Busy doing nothing Boris the Frog's Avatar
    Join Date
    Jan 2001
    Location
    Derby, UK
    Posts
    305
    Do you want the movieClip audi to play when your button is pressed?
    Is the movieClip already on the timeline?
    --------------------------------------------------
    ‘There is no emoticon to express how I am feeling’ - Comic Book Guy
    There's an effective, simple solution to carbon sequestration... it's called 'coal', so leave it alone!
    There's an effective, simple solution to carbon capture....it's called 'trees', so plant some!

  3. #3
    Junior Member
    Join Date
    Jan 2007
    Posts
    3
    Hi
    yes I want the movieclip audi to play when I press the button
    and the audi mc is on its own timeline
    I also have buttons an mC for bmw, toyota etc, each in their own timeline
    that I want to load into the cars.swf
    thanks

  4. #4
    Busy doing nothing Boris the Frog's Avatar
    Join Date
    Jan 2001
    Location
    Derby, UK
    Posts
    305
    OK, you have your file cars.swf containing a button the stage with the instance name: "btn_audi"
    On the main movie timeline add a layer and call it "actions"
    write this code in the actions panel:
    btn_audi.onRelease = function(){
    showCar("audi");
    }
    you can then reuse this code for your other buttons
    btn_toyota.onRelease = function (){
    showCar("toyota");
    }
    etc

    now write a function called "init" this will set up a blank movieClip to show the car clips in
    function init(){
    this.createEmptyMovieClip("mc_showCar", this.getNextHighestDepth());
    }

    Now write a function called "showCar" to display the car clip in the empty clip
    function showCar(carType:MovieClip){
    mc_showCar.attachMovie(carType, "mc_car", this.getNextHighestDepth());
    }

    Now write the following command at the bottom of all the code:
    init();

    Now in your library right click your audi movieClip and click Linkage, select "export for ActionScript" and type in the name "audi" as the indentifier.

    Code should look like this:
    //
    function init() {
    this.createEmptyMovieClip("mc_showCar", this.getNextHighestDepth());
    mc_showCar._x = 100; //position the clip
    mc_showCar._y = 100;
    }
    //
    function showCar(carType:String) {
    this.removeMovieClip();
    mc_showCar.attachMovie(carType, "mc_car", this.getNextHighestDepth());
    }
    init();
    btn_audi.onRelease = function (){
    showCar("audi");
    }
    btn_toyota.onRelease = function (){
    showCar("toyota");
    }
    --------------------------------------------------
    ‘There is no emoticon to express how I am feeling’ - Comic Book Guy
    There's an effective, simple solution to carbon sequestration... it's called 'coal', so leave it alone!
    There's an effective, simple solution to carbon capture....it's called 'trees', so plant some!

  5. #5
    Junior Member
    Join Date
    Jan 2007
    Posts
    3
    Hi
    wrote: btn_audi.onRelease = function(){
    showCar("audi");
    }
    but keeps coming up with:
    Scene=Scene 1, Layer=Layer 28, Frame=6: Line 1: Statement must appear within on handler
    btn_audi.onRelease = function(){
    I am a bit lost with second part of script function "init"
    thanks for your help,as you can guess I'm still new to Flash

  6. #6
    Busy doing nothing Boris the Frog's Avatar
    Join Date
    Jan 2001
    Location
    Derby, UK
    Posts
    305
    On the main movie timeline add a layer and call it "actions"
    write the following code in the actions panel. (I have added comments to explain it)
    !!!This code should NOT be added to the actions of a movieClip or button etc.!!!

    //
    function init() {
    //create an empty movieClip on the stage with the instance name "mc_showCar"
    this.createEmptyMovieClip("mc_showCar", this.getNextHighestDepth());
    //change the position of the clip to (100,100) - you can change this to a better position
    mc_showCar._x = 100; //position the clip
    mc_showCar._y = 100;
    }
    //
    function showCar(carType:String) {
    //this function is called by the different buttons
    //first it removes any movieclip attached to mc_showCar
    this.removeMovieClip();
    //now it attaches the clip (identified by the variable 'carType' to mc_showCar
    //it calls this clip "mc_car"
    mc_showCar.attachMovie(carType, "mc_car", this.getNextHighestDepth());
    //this means that a clip in your library ("audi" or "toyota" etc will be displayed on the stage in the clip mc_showCar
    }
    init(); //call the init function to initialise the movieClip for showing the cars
    //
    btn_audi.onRelease = function (){
    //calls the showCar function and sends it the name of the clip in the library to show
    //the name "audi" refers to the linkage identifier set for the clip in the library
    showCar("audi");
    }
    btn_toyota.onRelease = function (){
    showCar("toyota");
    }

    If you get stuck - just ask
    --------------------------------------------------
    ‘There is no emoticon to express how I am feeling’ - Comic Book Guy
    There's an effective, simple solution to carbon sequestration... it's called 'coal', so leave it alone!
    There's an effective, simple solution to carbon capture....it's called 'trees', so plant some!

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