A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Scroller MC problem

  1. #1
    Senior Member
    Join Date
    Oct 2006
    Posts
    114

    Scroller MC problem

    Hi,
    I'm trying to understand this scroller and make it so I can click on an image and it'll animate getting bigger and then some text appearing. The animation isn't a problem it's just understanding the code and getting it to work as I need.

    I had a go at putting a button on a MC and trying to tell it to jump the root/main timeline to frame 5 but it didn't seem to work. I also had a go at trying to make it jump to frame 5 of the movie clip but this also didn't work. It appears the code is stopping me from doing anything with this as it opens a large version of the img u click on underneath which is not what I need.

    I have two files here. 1 is the problem I'm talking about above the other is a scroller which I just need to know how to loop continuasly.


    code
    first file code on main timeline
    PHP Code:
    /*
    / * HORIZONTAL SCROLL CONTINUOUS Flash 
    is not necessary to redimensionar imagenes, are 
    autoajustan. To mount each image in a MC for 
    attach and to tie them with names MC1, MC2, 
    MC3...... etc. To define the beginning 
    variables seg?necesidad.
    */
    Nmcs 11;// number of MC.s for scrolling
    espacio 10;//space that is left between the photos
    Xc 5;//coordinate x of the box of scroll
    Yc 5;//coordinate y of the box of scroll
    Xo 10;// co-ordinated x origin viewfinder
    Yo 135;// co-ordinated y origin viewfinder
    Xf 797;// co-ordinated extreme x viewfinder (wide Xo +)
    Yf 570;// coordinate and end viewfinder (high I =)
    alturamax 90;//in order to reescalar if the image is but high
    anchmax 793;//in order to reescalar if the image is but high
    velo velobase=1;//speed bases pos or neg
    ajuste false;//true: it equals the stops to alturamax
    aleatorio true;// false: nonrandom loading
    bandapelicula true// false to clear cinema band
    //end of beginning variable
    fondo._visiblefalse;
    cl=new Array(0x000000,0x0000ff,0xff0000,0xffffff);
    barajar(Nmcs);
    examples();// delete this line to use the application
    function examples() {// delete this line to use the application
    createEmptyMovieClip("imgMC"1);
    imgMC._y Yc;
    actual 0;
    anchomas 0;
    altomas 0;
    mc = [];
    Nmcs*2;
    for (
    k=0k<Ak++){
        
    mc[k] = imgMC.attachMovie("MC"+bar[k%Nmcs],"MC"+bar[k%Nmcs],100+k);
        
    with (mc[k]){
            
    _x actual;
            
    _y15;
            if (
    _height>alturamax || ajuste){
                
    _yscale alturamax*100/_height;
                
    _xscale _yscale;
            }
            
    _width>anchomas anchomas=_width null;
            
    _height>altomas altomas=_height null;
            
    actual += _width+espacio;
        }
    }
    actual/2>anchmax anchura=anchmax anchura=actual/2;
    mc[A] = createEmptyMovieClip("m",0);
    marco(A,Xo,Yo,Xf,Yf,5,cl[0],cl[0],8);
    mc[A+2]=imgMC.createEmptyMovieClip("mascara",199);
    marco(A+2,0,0,anchura,altomas+30,5,0,cl[3],20);
    imgMC._x Xc-anchomas;
    bandapelicula bandafilm(): null;
    imgMC.mascara._x anchomas;
    imgMC.setMask(imgMC.mascara);
    onEnterFrame = function (){
        for (
    k=0k<Nmcs*2k++){
            
    with (mc[k]){
                
    _x += velo;
                
    _x-actual>=velo _x -= actual null;
                
    _x<=_x += actual null;
                
    condicion(k) ? borde(k) : mc1.removeMovieClip();
            }
        }
        
    mc[A+5]._x=(mc[A+5]._xvelo)%25 ;
    }
    function 
    borde(k) {
        
    mc[A+3]=mc[k].createEmptyMovieClip("mc1"201);
        
    marco(A+3,5,5,mc[k]._width-5,mc[k]._height-5,2,0xfff00,0xff0000,10);
        
    mc[A+3]._xscale 10000/mc[k]._xscale;
        
    mc[A+3]._yscale 10000/mc[k]._yscale;
        
    activo k;
    }
    function 
    mmin() {
        
    velo 0;
        
    xm _xmouse;
        
    imgMC.mascara.onMouseMove = function() {
            if (
    Math.abs(xm-_xmouse)>30) {
                
    velo = (Xc+imgMC.mascara._width/2-_xmouse)/20;
                
    actpress false;
            }
        };
    }
    function 
    condicion(k) {
        
    with (mc[k]) {
            return (
    _width*100/_xscale>_xmouse && _xmouse>
                    
    && _height*100/_yscale>_ymouse && _ymouse>
                    
    && imgMC.mascara._width>imgMC.mascara._xmouse 
                    
    && imgMC.mascara._xmouse>0);
        }
    }
    imgMC.mascara.onPress = function() {
        
    velo 0;
        
    entra true;
        
    actpress && condicion(activo) ? openimg(activo) : null;
        
    delete imgMC.mascara.onMouseMove;
    };
    imgMC.mascara.onRelease = function() {
        
    mmin();
        
    entra false;
        
    actpress true;
    };
    imgMC.mascara.onRollOut = function() {
        
    velobase velo>=velo=velobasevelo=-velobase;
        
    delete imgMC.mascara.onMouseMove;
    };
    imgMC.mascara.onRollOver = function() {
        
    mmin();
    };
    }
    //aim of examples delete this line to use the application

    function barajar(clips) {
        
    bar = [];
        for (var 
    0m<clipsm++) {
            
    bar[m] = m;
        }
        if (
    aleatorio) {
            for (var 
    clips-1i>0i--) {
                
    alea Math.floor(i*Math.random());
                var 
    temp bar[i];
                
    bar[i] = bar[alea];
                
    bar[alea] = temp;
            }
        }
    }


    function 
    openimg(k) {
        if (
    entra) {
            
    _root.attachMovie("MC"+(bar[k%Nmcs]), "vista"220);
            
    boton.enabled false;// delete to use the application
            
    boton._visible false;// delete to use the application
            
    vista._width Xf-Xo-3;
            
    vista._yscale vista._xscale;
            if (
    vista._height>Yf-Yo-3) {
                
    vista._height Yf-Yo-3;
                
    vista._xscale vista._yscale;
            }
            
    vista._x Xo+(Xf-Xo-vista._width)/2;
            
    vista._y Yo+(Yf-Yo-vista._height)/2;
            
    vista.onPress = function() {
                
    vista.removeMovieClip();
                
    boton.enabled true;// delete to use the application
                
    boton._visible true;// delete to use the application
            
    }
        }
        !
    entra ? (vista.removeMovieClip()): null;
    }


    function 
    marco(kXoYoXfYf,lacolorcolor2alpha) {
        
    with (mc[k]) {
            
    lineStyle(lacolor90);
            
    beginFill(color2alpha);
            
    moveTo(XoYo);
            
    lineTo(Xf,Yo);
            
    lineTo(XfYf);
            
    lineTo(Xo,Yf);
            
    lineTo(XoYo);
            
    endFill();
        }
    }


    function 
    bandafilm(){
        
    mc[A+5]=imgMC.createEmptyMovieClip("banda",5);
        
    marco(A+5,anchomas-250,anchomas+anchura+25altomas+300cl[0], cl[0], 80);
            for (
    b=0b<=anchura+50b+=25){
               
    marco(A+5,-25+b+anchomas,4,-25+b+10+anchomas 110,cl[3],cl[3], 80);   
               
    marco(A+5,-25+b+anchomasaltomas+19,-25+b+10+anchomas 26+altomas0,cl[3],cl[3], 80);
            }
    }


    //delete the following function to use the application
    boton.onPress = function() {
        
    mc[A].removeMovieClip();
        
    texto._visible false;
        
    Nmcs 1+random(11);
        
    espacio random(30);
        
    Xc 10*random(15);
        
    Yc 10*random(15);
        
    alturamax 30+10*random(20);
        
    anchmax 190+20*random(30);
        
    velo velobase=2+random(2);
        
    Xo Xc;
        
    Yo alturamax+Yc+35;
        
    Xf 795-Xc;
        
    Yf 595;
        
    ajuste = !ajuste;
        
    bandapelicula true*(random(5)>=2)
        
    barajar(11);
        
    examples();
        
    cl[3]=0xffffff;
        
    cl[0]=0x000000;
        
    fondo._visiblefalse;
        if (
    random(5)==1){ cl[0]=0xffffff;cl[3]=0x000000;fondo._visibletrue;}
        if (
    random(5)==1){ cl[0]=0x0000ff;cl[3]=0xffffff;fondo._visibletrue;}
    };
    /*
    In order to use the application to erase or to 
    pass to commentaries the indicated lines. To 
    eliminate layer 2 of the scene and the 
    button of the library.
    */

    stop(); 
    and on my 2nd file on the image/MC that scrolls...
    PHP Code:
    onClipEvent (enterFrame) {
        if (
    _root.mainVar == 0) {
            
    homeX = (-_root._xmouse*2)+1050;
        } else {
            
    homeX = (-_root.mainVar*2)+1050;
        }
        
    thisX _x;
        
    diffX homeX-thisX;
        if (
    _root.mainVar == 0) {
            
    moveX diffX/30;
        } else {
            
    moveX diffX/5;
        }
        
    _x thisX+moveX;

    I just need to get one of these files working so any help massivly appreciated!!!
    Stefan
    Attached Files Attached Files
    Last edited by stefancostain; 05-08-2008 at 05:34 AM.

  2. #2
    Senior Member
    Join Date
    Oct 2006
    Posts
    114
    Ignore... New Post Made. Can't Seem To Delete This Post

  3. #3

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