Pagina 2 di 3 primaprima 1 2 3 ultimoultimo
Visualizzazione dei risultati da 11 a 20 su 28
  1. #11
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Originariamente inviato da and80
    ho provato ad adattare il codice dell'esempio per MTASC, su flash, ma il resize non avviene comunque :master:
    forse ce l'ho fatta... ora qualcosa funziona

    Codice PHP:
    import com.bumpslide.util.*;
    import com.bumpslide.ui.ResizableImage;

    var 
    border_mc:MovieClip;
    var 
    image_mc:ResizableImage;

    var 
    BORDER_WIDTH 1;
    var 
    PADDING 50;
    var 
    imagePath '';

    // create border
    createEmptyMovieClip('border_mc',1);

    // create resizable image
    image_mc ResizableImage.create('image_mc'this);
    image_mc.addEventListener(ResizableImage.EVENT_IMAGE_LOADED,this);

    image_mc.loadImage(imagePath+'myimage.jpg');
    onMouseDown toggleSmoothing;

    // use white for message text
    _message_txt.textColor 0xffffff;

    message('Click to toggle smoothing.');

    function 
    toggleSmoothing() {
        
    image_mc.applySmoothing = !image_mc.applySmoothing;
        
    clearMessage();
        
    message("Smoothing is "+(image_mc.applySmoothing "ON" "OFF"));
    }
    function 
    onStageResize() {
        
    image_mc.setSize(Stage.width-BORDER_WIDTH*2-PADDING*2,Stage.height-BORDER_WIDTH*2-PADDING*2);
        
    Align.middle(image_mc);
        
    Align.center(image_mc);

        
    border_mc.clear();
        
    Draw.box(border_mc,image_mc.width+BORDER_WIDTH*2,image_mc.height+BORDER_WIDTH*2,0xffffff,100);
        
    border_mc._x image_mc._x-BORDER_WIDTH;
        
    border_mc._y image_mc._y-BORDER_WIDTH;

    }
    function 
    onImageLoaded() {
        
    onStageResize();
    }

    var 
    l:Object = {};
    l.onResize onStageResize;
    Stage.addListener(l); 

  2. #12
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    54
    Grande!!!
    Adesso funziona... anche se non perfettamente...
    Certo che se riesci a farlo funzionare perfettamente sarebbe il massimo!!!

    Anche se poi non riesco a capire perchè non funziona facendo come c'è scritto in quella pagina! Mah..

  3. #13
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    54
    Stavo cercando di rifare l'effetto resize e smoothing senza usare queste librerie...
    And80 non è che mi fai capire perchè quello che ho fatto ha un po' di problemi con il resize?

    Eccolo:

    Codice PHP:
    import flash.display.*;

    Stage.align "TL";
    Stage.scaleMode "noScale";

    var 
    PADDING 50;

    //////smoothing/////

    function loadBitmapSmoothed(url:Stringtarget:MovieClip) {
        var 
    bmc:MovieClip target.createEmptyMovieClip("bmc"target.getNextHighestDepth());
        var 
    listener:Object = new Object();
        
    listener.tmc target;
        
    listener.onLoadInit = function(mc:MovieClip) {
            
    mc._visible false;

            var 
    bitmap:BitmapData = new BitmapData(mc._widthmc._heighttrue);

            
    this.tmc.attachBitmap(bitmap,this.tmc.getNextHighestDepth(),"auto",true);

            
    bitmap.draw(mc);
        };
        var 
    loader:MovieClipLoader = new MovieClipLoader();
        
    loader.addListener(listener);
        
    loader.loadClip(url,bmc);
    }

    /////////////

    createEmptyMovieClip("my_image",getNextHighestDepth());
    loadBitmapSmoothed("myimage.jpg",my_image);

    stageListener = new Object();
    stageListener.onResize = function() {
        var 
    imageAspectRatio my_image._width/my_image._height;
        var 
    stageAspectRatio Stage.width/Stage.height;
        
    my_image._x = (Stage.width-my_image._width)/2;
        
    my_image._y = (Stage.height-my_image._height)/2;
        if (
    stageAspectRatio>=imageAspectRatio) {
            
    my_image._xscale my_image._yscale;
            
    my_image._height Stage.height-PADDING;
        } else {
            
    my_image._yscale my_image._xscale;
            
    my_image._width Stage.width-PADDING;
        }

    };
    Stage.addListener(stageListener); 
    C'è qualcosa che non va quì, sul posizionamento sullo Stage... AspectRatio... boh..
    Chissà se anche questa volta m'illumini...

  4. #14
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    54
    Bene, con l'aiuto di rempox dovrei aver risolto in questo modo:

    Codice PHP:
    import flash.display.*;

    Stage.align "TL";
    Stage.scaleMode "noScale";

    var 
    PADDING 50;

    //////smoothing///// 

    function loadBitmapSmoothed(url:Stringtarget:MovieClip) {
        var 
    bmc:MovieClip target.createEmptyMovieClip("bmc"target.getNextHighestDepth());
        var 
    listener:Object = new Object();
        
    listener.tmc target;
        
    listener.onLoadInit = function(mc:MovieClip) {
            
    mc._visible false;

            var 
    bitmap:BitmapData = new BitmapData(mc._widthmc._heighttrue);

            
    this.tmc.attachBitmap(bitmap,this.tmc.getNextHighestDepth(),"auto",true);

            
    bitmap.draw(mc);
        };
        var 
    loader:MovieClipLoader = new MovieClipLoader();
        
    loader.addListener(listener);
        
    loader.loadClip(url,bmc);
    }

    ////////////////

    createEmptyMovieClip("my_image",getNextHighestDepth());
    loadBitmapSmoothed("myimage.jpg",my_image);

    stageListener = new Object();
    stageListener.onResize = function() {
        
    my_image._xscale my_image._yscale=100;
        
    my_image._width;
        
    my_image._height;
        
    MaxW Stage.width-PADDING;
        
    MaxH Stage.height-PADDING;
        
    MaxP MaxH*100/MaxW;
        
    theW W;
        
    theH H;
        
    theP theH*100/theW;
        if (
    W>MaxW) {
            if (
    H>MaxH) {
                if (
    theP<=MaxP) {
                    
    theW MaxW;
                    
    theH MaxW*theP/100;
                } else {
                    
    theW MaxH/theP*100;
                    
    theH MaxH;
                }
            } else {
                
    theW MaxW;
                
    theH MaxW*theP/100;
            }
        } else {
            if (
    H>MaxH) {
                
    theW MaxH/theP*100;
                
    theH MaxH;
            } else {
                
    //theW = W;
                //theH = H;
            
    }
        }
        
    theW Math.floor(theW);
        
    theH Math.floor(theH);
        
    my_image._width theW;
        
    my_image._height theH;
        
    my_image._x = (MaxW-my_image._width+PADDING)/2;
        
    my_image._y = (MaxH-my_image._height+PADDING)/2;
    };
    Stage.addListener(stageListener); 
    Anche se c'è ancora qualcosa da rivedere perchè l'immagine non mi compare subito ridimensionata e nella posizione centrale ma lo fa solo dopo che ridimensiono la finestra...
    Qualche idea per sistemare il codice...?

  5. #15
    non puoi metterlo dentro

    listener.onLoadInit

  6. #16
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    54
    Cioè?

  7. #17
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    54
    Rempox, l'ho fatto! Poi ho capito!
    Sembra vada bene adesso.. anche se quel codice bisogna metterlo sia su onLoadInit che su StageListener.onResize (se c'è un altro modo ditemelo perchè così il codice diventa lunghissimo! )

    Comunque la parte che ho aggiunto è questa:
    Codice PHP:
    listener.onLoadInit = function(mc:MovieClip) {
            
    mc._visible false;
            var 
    bitmap:BitmapData = new BitmapData(mc._widthmc._heighttrue);
            
    this.tmc.attachBitmap(bitmap,this.tmc.getNextHighestDepth(),"auto",true);
            
    bitmap.draw(mc);
            
    //////////////   da quì   ///////////////////
            
    target._xscale target._yscale=200;
            
    target._width;
            
    target._height;
            
    MaxW Stage.width-PADDING;
            
    MaxH Stage.height-PADDING;
            
    MaxP MaxH*100/MaxW;
            
    theW W;
            
    theH H;
            
    theP theH*100/theW;

            if (
    W>MaxW) {
                if (
    H>MaxH) {
                    if (
    theP<=MaxP) {
                        
    theW MaxW;
                        
    theH MaxW*theP/100;
                    } else {
                        
    theW MaxH/theP*100;
                        
    theH MaxH;
                    }
                } else {
                    
    theW MaxW;
                    
    theH MaxW*theP/100;
                }
            } else {
                if (
    H>MaxH) {
                    
    theW MaxH/theP*100;
                    
    theH MaxH;
                } else {
                }
            }
            
    theW Math.floor(theW);
            
    theH Math.floor(theH);
            
    target._width theW;
            
    target._height theH;
            
    target._x = (MaxW-target._width+PADDING)/2;
            
    target._y = (MaxH-target._height+PADDING)/2;
            
        };
            
    /////////////////////////////// 

  8. #18
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    54
    Scusate.. Mi rispondo da solo!
    In effetti basta metterlo solo su onLoadInit.. è che mi piaceva l'idea del ridimensionamento dell'immagine quando si cambiava la dimensione dello Stage (come avviene con la libreria che cercavo di utilizzare all'inizio), però in effetti in un sito non si modifica la finestra e quindi è una cosa in più..
    In teoria (e in pratica! ) si può cancellare la parte finale che va da stageListener in poi..


  9. #19
    dico una assurità!

    Se cei un onEnterFrame che controlla le dimensioni dello Stage ?? al variare chiami una funzione di rimensionamento ??

  10. #20
    Provo a scriverlo in ITALIANO.

    Dico un'assurdità!

    Se crei un onEnterFrame ?? che controlla le dimensioni dello Stage ?? al variare dello STage chiami una funzione di rimensionamento ?? (da creare)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.