Avatar billede rafix Nybegynder
19. august 2005 - 08:32 Der er 4 kommentarer og
1 løsning

Tilretning af as fil

jeg har købt simpleviewer (http://www.airtightinteractive.com/simpleviewer/) og ønsker nu at disable den automatiske resize af bredden (width) på mine billeder. er der nogen som kan gennemskue hvor det sker henne ?

jeg tror måske det sker nede i:
/////////////////////////////////////////////
// IMAGE
/////////////////////////////////////////////


.as filen:

//SIMPLE VIEWER v1.7

#include "modLoaderClass.as"
#include "tween.as"

Color.prototype.setTint = function (color_num, amount) {
   
    var r = (color_num & 0xFF0000) >> 16;
    var g = (color_num & 0x00FF00) >> 8 ;
    var b = (color_num & 0x0000FF);
   
    var trans = new Object();
    trans.ra = trans.ga = trans.ba = 100 - amount;
    var ratio = amount / 100;
    trans.rb = r * ratio;
    trans.gb = g * ratio;
    trans.bb = b * ratio;
    this.setTransform(trans);
}

function init(){

    trace("init");

    _global.gmcMain = this;
   
    //Consts
    gNextLevel = 1;   
    THUMB_WIDTH = 44;
    IMG_NAV_LEVEL = 9999;   
    THUMBMAXDIM = 44;
    TEXTLINEHEIGHT = 20;
   
    //process XML
    gXMLRoot = gImageData_xml.firstChild;
    trace(gXMLRoot);
    gImageCount = Number(gXMLRoot.childNodes.length);
   
    trace("gImageCount: " + gImageCount);
   
    //get data from XML   
    _global.gImageMaxDim = int(gXMLRoot.attributes.maxImageDimension);   
    frameColor = gXMLRoot.attributes.frameColor;   
    imageBorderWidth = gXMLRoot.attributes.frameWidth;   
    captionColor = gXMLRoot.attributes.textColor;   
    bgColor = gXMLRoot.attributes.bgColor;   
    stageGutter = Number(gXMLRoot.attributes.stagePadding);
    navPosition = gXMLRoot.attributes.navPosition;   
    thumbRowCount = gXMLRoot.attributes.thumbnailRows;   
    thumbColumnCount =     gXMLRoot.attributes.thumbnailColumns;       
    gNavDir = gXMLRoot.attributes.navDirection;       
   
    thumbnailDisplayCount = thumbRowCount * thumbColumnCount;   
    gThumbPageCount = Math.ceil(gImageCount/thumbnailDisplayCount) - 1;

    gImagePath = gXMLRoot.attributes.imagePath;   
    gThumbPath = gXMLRoot.attributes.thumbPath;   
               
    //use defaults if XMl missing
    if (gImagePath == undefined || gImagePath == ""){
        gImagePath = "images/";
    }
    if (gThumbPath == undefined || gThumbPath == ""){
        gThumbPath = "thumbs/";
    }
   
    trace ("gImagePath: " +gImagePath);
       
    if (isNaN(stageGutter)){
        stageGutter = 40;
    }
    if (isNaN(imageBorderWidth)){
        imageBorderWidth = 10;
    }
   
    //init loaders   
    thumbLoader = new com.qlod.LoaderClass();
    imageLoader = new com.qlod.LoaderClass();
       
    gaImages = new Array();
    gaThumbs = new Array();
   
    ///////////////////////////////////
    //ATTACH CLIPS
   
    gmcThumbArea = gmcMain.createEmptyMovieClip("mcThumbArea",gNextLevel++);       
    gmcThumbSlider = gmcThumbArea.createEmptyMovieClip("mcThumbSlider",gNextLevel++);
    gmcThumbSliderMask = gmcThumbArea.createEmptyMovieClip("mcThumbSliderMask",gNextLevel++);
    gmcThumbSliderMask.attachMovie("sDummy","mcMask",gNextLevel++);
    gmcThumbSlider.setMask(gmcThumbSliderMask);   
    //gmcThumbSliderMask._alpha = 50;
   
    gmcSelected = gmcThumbSlider.attachMovie("sSelected","mcSelected",gNextLevel++);

    /////////////////////////////
    //thumb navigation
    /////////////////////////////
    if (gNavDir == "LTR"){
        gmcNextThumbsBtn = gmcThumbArea.attachMovie("sBackThumbsBtn","mcNextThumbsBtn",gNextLevel++);
        gmcBackThumbsBtn = gmcThumbArea.attachMovie("sNextThumbsBtn","mcBackThumbsBtn",gNextLevel++);
    }else{
        gmcNextThumbsBtn = gmcThumbArea.attachMovie("sNextThumbsBtn","mcNextThumbsBtn",gNextLevel++);
        gmcBackThumbsBtn = gmcThumbArea.attachMovie("sBackThumbsBtn","mcBackThumbsBtn",gNextLevel++);       
    }
    gThumbPageId =0;
   
    gmcNextThumbsBtn.onRelease = function(){       
        gThumbPageId--;
        updateThumbs();
    }
   
    gmcBackThumbsBtn.onRelease = function(){       
        gThumbPageId++;
        updateThumbs();
    }
   
    updateThumbs();   
    gCurrentImageId = 0;
   
    /////////////////////////
   
    gmcDisplayArea = gmcMain.attachMovie("sDummy","mcDisplayArea",gNextLevel++);
    gmcDisplayArea._alpha = 0;
   
    //////////////////////////////////
    // Image navigation
   
    gmcImageButtons = gmcDisplayArea.attachMovie("sImageButtons","mcImageButtons",1);
   
    //flip img nav icons for LTR
    if (gNavDir == "LTR"){
        gmcImageButtons.mcBack._x = 60;
        gmcImageButtons.mcNext._x = 0;
        gmcImgNextIcon = gmcMain.attachMovie("sImgBack","mcImgNext",IMG_NAV_LEVEL);   
        gmcImgBackIcon = gmcMain.attachMovie("sImgNext","mcImgBack",IMG_NAV_LEVEL + 1);                       
    }else{
        gmcImgNextIcon = gmcMain.attachMovie("sImgNext","mcImgNext",IMG_NAV_LEVEL);   
        gmcImgBackIcon = gmcMain.attachMovie("sImgBack","mcImgBack",IMG_NAV_LEVEL + 1);           
    }
   
    gmcImgNextIcon._visible = false;
    gmcImgBackIcon._visible = false;
   
    gmcImageButtons.mcBack.useHandCursor = false;
    gmcImageButtons.mcNext.useHandCursor = false;
   
    gShownFirstImage = false;   
    gmcImageButtons.mcBack.onRollOver = function(){   
        if (gShownFirstImage){
            if (gCurrentImageId < gImageCount -1){           
                gmcImgBackIcon._visible = true;
                gmcImgBackIcon.mcArrow.gotoAndPlay(1);
            }
        }
    }
   
    gmcImageButtons.mcNext.onRollOver = function(){
        if (gShownFirstImage){
            if (gCurrentImageId > 0){
                gmcImageButtons.mcNext.useHandCursor = true;           
                gmcImgNextIcon._visible = true;
                gmcImgNextIcon.mcArrow.gotoAndPlay(1);
            }else{
                gmcImageButtons.mcNext.useHandCursor = false;           
            }
        }
    }
   
    gmcImageButtons.mcBack.onRollOut = function(){
        gmcImgBackIcon._visible = false;
    }
   
    gmcImageButtons.mcNext.onRollOut = function(){
        gmcImgNextIcon._visible = false;
    }
   
    gmcImageButtons.mcNext.onRelease = function(){
        nextId = gCurrentImageId - 1;
        if (nextId >= 0){           
            gaThumbs[nextId].onRelease();       
        }
    }
   
    gmcImageButtons.mcBack.onRelease = function(){
        nextId = gCurrentImageId + 1;
        if (nextId <= gImageCount ){
            gaThumbs[nextId].onRelease();
        }
    }
   
    /////////////////////////////////   
   
    gmcTitle = gmcMain.attachMovie("sCaption","mcTitle",gNextLevel++);
    gmcCaption = gmcMain.attachMovie("sCaption","mcCaption",gNextLevel++);   
   
    if (gShowDownloadLink){
        gmcLogo = gmcMain.attachMovie("sLogo","mcLogo",gNextLevel++);
    }
   
    gmcTitle.txtCap.htmlText = gXMLRoot.attributes.title;
    gmcTitle.txtCap.textColor = captionColor;
    gmcCaption.txtCap.textColor = captionColor;
   
    colLogo = new Color(gmcLogo);
    colLogo.setRGB(captionColor);       
   
    gmcImageLoadBar = gmcMain.attachMovie("sImageLoadBar","mcImageLoadBar",999999);
    gmcImageLoadBar._visible = false;
   
    //set colors
    barCol = new Color(gmcImageLoadBar);
    barCol.setRGB(frameColor);           
    selCol = new Color(gmcSelected);
    selCol.setRGB(frameColor);           
    nCol = new Color(gmcNextThumbsBtn);
    nCol.setRGB(frameColor);           
    bCol = new Color(gmcBackThumbsBtn);
    bCol.setRGB(frameColor);       
    inCol = new Color(gmcImgNextIcon);
    inCol.setRGB(frameColor);   
    ibCol = new Color(gmcImgBackIcon);
    ibCol.setRGB(frameColor);   
       
    /////////////////////////////////////////////
    //do one off resize calcs
    //calculate thumb area    dims   
    //-------------------
    gThumbAreaWidth = THUMBMAXDIM*thumbColumnCount+7;
    gThumbAreaHeight = THUMBMAXDIM*thumbRowCount+8;
    //add height for thumb nav
    if (gThumbPageCount >0){   
        gThumbAreaHeight +=THUMBMAXDIM;
    }
   
    //170 min width on caption for small no. of thumbs   
    var capWidth = Math.max(gThumbAreaWidth, 170);
    gmcTitle.txtCap._width = capWidth;
    gmcCaption.txtCap._width = capWidth ;
       
    gTitleHeight = gmcTitle.txtCap.textHeight;           
   
    //make mask on thumbnailDisplayCount
    gmcThumbSliderMask.mcMask._width = gThumbAreaWidth;
    gmcThumbSliderMask.mcMask._height = gThumbAreaHeight;
    gmcThumbSliderMask._y = 0;
    gmcThumbSliderMask._x = -gThumbAreaWidth;
       
    if (gNavDir == "LTR"){
        gmcBackThumbsBtn._x =  - THUMBMAXDIM;
        gmcNextThumbsBtn._x = -gThumbAreaWidth;   
       
        //dont overlap nav for 1 column
        if (thumbColumnCount == 1){
            gmcBackThumbsBtn._x +=  THUMBMAXDIM/2;
            gmcNextThumbsBtn._x -=  THUMBMAXDIM/2;
        }
       
    }else{
        gmcNextThumbsBtn._x =  - THUMBMAXDIM;
        gmcBackThumbsBtn._x = -gThumbAreaWidth ;
        //dont overlap nav for 1 column
        if (thumbColumnCount == 1){
            gmcBackThumbsBtn._x -=  THUMBMAXDIM/2;
            gmcNextThumbsBtn._x +=  THUMBMAXDIM/2;
        }
       
    }

    gmcNextThumbsBtn._y = gmcBackThumbsBtn._y = gThumbAreaHeight  - THUMBMAXDIM;       
   
    /////////////////////////////////////////////
   
    //init resize   
    doLayout();
   
    /////////////////////////////
    //thumb show/hide
    gmcThumbSlider._x = - gThumbAreaWidth;   

    //start loading thumbs
    initThumbs();   
   
   
    gmcSelected._visible = false;
    intStart = setInterval(autoShow,300);
   
   
    ///////////////
    //init Keyboard nav
   
    keyListener = new Object();
    keyListener.onKeyDown = function () {   
        if (okPress) {
            if(Key.isDown(Key.LEFT)) {
                if (gNavDir == "LTR"){
                    gmcImageButtons.mcNext.onRelease();
                }else{
                    gmcImageButtons.mcBack.onRelease();               
                }
            }else if(Key.isDown(Key.RIGHT)) {
                if (gNavDir == "LTR"){
                    gmcImageButtons.mcBack.onRelease();
                }else{
                    gmcImageButtons.mcNext.onRelease();               
                }
            }       
        }
        okPress = false;
    }
    okPress = true;
    keyListener.onKeyUp = function () {   
        okPress = true;
    }
    Key.addListener(keyListener);
       
}

function autoShow(){
   
    doLayout();
    clearInterval(intStart);
    //auto show 1st image
    gPendingImageId = 0;
    gaThumbs[0].makeCurrent();   
    gaThumbs[0].doRelease();
   
}

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

function xableImghandCursors(){
    if (gCurrentImageId  < gImageCount -1){
        gmcImageButtons.mcBack.useHandCursor = true;                   
    }else{
        gmcImageButtons.mcBack.useHandCursor = false;
    }
   
    if (gCurrentImageId > 0){
        gmcImageButtons.mcNext.useHandCursor = true;           
       
    }else{
        gmcImageButtons.mcNext.useHandCursor = false;
    }   
}


////////////////
// RESIZE
///////////////
function doLayout(){

    trace("doLayout");
       
    if (gStageWidth == undefined){   
        stageWidth = Stage.width;
        stageHeight = Stage.height;   
    }else{
        stageWidth = gStageWidth;
        stageHeight = gStageHeight;   
    }
   
    trace("stage width: " + stageWidth);
   
    //calculate display area   
    //-------------------
    if (navPosition == "left" || navPosition == "right"){        
        displayWidth = stageWidth - (stageGutter*3) - gThumbAreaWidth;
        displayHeight = stageHeight- (stageGutter*2);
    }else{
        displayWidth = stageWidth - (stageGutter*2) ;
        displayHeight = stageHeight- (stageGutter*3) - gThumbAreaHeight;       
    }
    //get min of width/height
    if (displayWidth < displayHeight){
        displayDim = displayWidth;
    }else{
        displayDim = displayHeight;
    }   
    // get min of disp dim and XML max dim   
    MaxDisplayDim = gImageMaxDim + imageBorderWidth*2;
   
    if (MaxDisplayDim < displayDim){
        displayDim = MaxDisplayDim;
    }
   
    displayDim = Math.floor(displayDim);
   
    UIWidth = displayDim+gThumbAreaWidth + stageGutter;   
    UIHeight =  displayDim+gThumbAreaHeight + stageGutter;   
   
    //set coords
    switch (navPosition) {
      case "top":
        thumbAreaY = Math.floor((stageHeight - UIHeight)/2);   
        displayAreaY = Math.floor(thumbAreaY + stageGutter + gThumbAreaHeight);
        displayAreaX = Math.floor((stageWidth - displayDim)/2);
        thumbAreaX =  Math.floor((stageWidth - gThumbAreaWidth)/2) + gThumbAreaWidth;
        break;
      case "bottom":
        displayAreaY = Math.floor((stageHeight - UIHeight)/2);   
        displayAreaX = Math.floor((stageWidth - displayDim)/2);
        thumbAreaY = Math.floor(displayAreaY + displayDim + stageGutter);
        thumbAreaX =  Math.floor((stageWidth - gThumbAreaWidth)/2) + gThumbAreaWidth;
        break;
      case "left":       
        displayAreaY = Math.floor((stageHeight - displayDim)/2);
        thumbAreaX = Math.floor((stageWidth - UIWidth)/2 + gThumbAreaWidth);   
        thumbAreaY =  Math.floor((stageHeight - gThumbAreaHeight)/2);
        displayAreaX = Math.floor(thumbAreaX + stageGutter);
        break;
      default:
        displayAreaY = Math.floor((stageHeight - displayDim)/2);
        thumbAreaX = stageWidth - Math.floor((stageWidth - UIWidth)/2);   
        thumbAreaY =  Math.floor((stageHeight - gThumbAreaHeight)/2);
        displayAreaX = Math.floor(thumbAreaX -( stageGutter+displayDim+ gThumbAreaWidth));
    }
       
    gmcThumbArea._x = thumbAreaX;
    gmcThumbArea._y = thumbAreaY;

    gmcDisplayArea._x = displayAreaX;
    gmcDisplayArea._y = displayAreaY;
    gmcDisplayArea._width = displayDim;
    gmcDisplayArea._height = displayDim;

    //set gmcImageLoadBar posn
    gmcImageLoadBar._x =  Math.floor(displayAreaX + gmcDisplayArea._width/2);
    gmcImageLoadBar._y =  Math.floor(displayAreaY + gmcDisplayArea._height/2);               
                       
    //Caption pos - captions go under thumbs
    gmcCaption._x = thumbAreaX + 4 - gThumbAreaWidth;
    gmcCaption._y = thumbAreaY + gThumbAreaHeight;
       
    gmcTitle._x = thumbAreaX + 4 - gThumbAreaWidth;
    gmcTitle._y = thumbAreaY - gTitleHeight;
       
    gaImages[gCurrentImageId].centerImage();
       
    //move logo
    gmcLogo._x = Math.floor (stageWidth  - gmcLogo._width - 10);
    gmcLogo._y = Math.floor (stageHeight  - gmcLogo._height - 10);
   
}

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

function updateThumbs(){
   
    if (gNavDir == "LTR"){
        gThumbGotoX = - gThumbAreaWidth*gThumbPageId - gThumbAreaWidth;   
    }else{
        gThumbGotoX = gThumbAreaWidth*gThumbPageId - gThumbAreaWidth;
    }
   
    if (gThumbGotoX != gmcThumbSlider._x){
        doTween(gmcThumbSlider,20, "_x", gThumbGotoX)
    }

    if(gThumbPageId == 0){
        gmcNextThumbsBtn._visible = false;
    }else{
        gmcNextThumbsBtn._visible = true;
    }
   
    if (gThumbPageId == gThumbPageCount){
        gmcBackThumbsBtn._visible = false;
    }else{
        gmcBackThumbsBtn._visible = true;
    }
   
}

/////////////////////////////////////////////
// THUMB
/////////////////////////////////////////////


function initThumbs(){

    //load garbage
    gmcMain.createEmptyMovieClip("mcBodge", -1);   
    gmcMain.mcBodge._visible = false;       
    gmcMain.mcBodge._alpha = 0;       
    bodgeId = thumbLoader.load(gmcMain.mcBodge,  gThumbPath + gXMLRoot.firstChild.firstChild.firstChild.nodeValue);       
           
    gNextLevel++;
    // create a thumb for each image   
    for (var i = 0;i<gImageCount;i++){
        gaThumbs[i] = gmcThumbSlider.attachMovie("sThumb","thumb"+i,gNextLevel++,{id:i});
        gaThumbs[i]._y = THUMBMAXDIM* (i%thumbRowCount);
       
        if (gNavDir == "LTR"){
            gaThumbs[i]._x = THUMBMAXDIM * Math.floor(i/thumbRowCount);                       
        }else{
            gaThumbs[i]._x = gThumbAreaWidth - THUMBMAXDIM * (Math.floor(i/thumbRowCount)+1);       
        }
    }   
}

function Thumb(){
    trace("creating Thumb:" + this.id);
    this.XMLData = gXMLRoot.childNodes[this.id];
               
    this.createEmptyMovieClip("mcThumbListener", 1);       
    this.mcThumbListener.onEnterFrame = function(){
       
        var loadclip = this._parent.mcThumb.mcThumb.mcThumb;   
        var total = loadclip.getBytesTotal();
        var kLoaded = loadclip.getBytesLoaded();   
        var p = Math.floor((kLoaded/total)*100);
       
        //display load progress bar   
        if (kLoaded > 16 && kLoaded >= total && loadclip._width > 1){
            this.onEnterFrame = undefined;
            //do on loaded
            this._parent.onThumbLoaded();
        }
    }
    this.thumbLoaded = false;   
    this.imageLoaded = false;
    this.mcThumb._visible = false;
    this.mcViewed._visible = false;
   
    //start loading in thumb
    this.thumbLoadId = thumbLoader.load(this.mcThumb.mcThumb.mcThumb, gThumbPath+this.XMLData.firstChild.firstChild.nodeValue);       

    colFrame = new Color(this.mcThumb.mcFrame);
    colFrame.setRGB(frameColor);
    colBar = new Color(this.mcThumb.mcBar);
    colBar.setRGB(frameColor);
    colViewedBar = new Color(this.mcViewed);
    colViewedBar.setRGB(frameColor);
    colSquare = new Color(this.mcSquare);
    colSquare.setRGB(frameColor);
}

Thumb.prototype = new MovieClip();

Object.registerClass("sThumb", Thumb);

Thumb.prototype.onThumbLoaded = function(){
    trace("thumb loaded: " + this.id);
    //resize thumbImage to fit thumb
    this.mcThumb._visible = true;
    this.centerThumb();       
    this.gotoAndPlay("thumbLoaded");   
    this.loadImage();   
    this.thumbLoaded = true;
   
    this.onRollOver = this.doRollOver;
    this.onRollOut = this.doRollOut;
    this.onRelease = this.doRelease;       
}

Thumb.prototype.doRollOver = function(){
    if (this.thumbLoaded){
        this.gotoAndPlay("_over");   
        //show this caption
        gmcCaption.txtCap.htmlText = this.XMLData.childNodes[1].firstChild.nodeValue;       
        gmcCaption.txtCap.textColor = captionColor;
    }
}

Thumb.prototype.doRollOut = function(){
    if (this.thumbLoaded){
        //show this caption
        gmcCaption.txtCap.htmlText = gaThumbs[gCurrentImageId].XMLData.childNodes[1].firstChild.nodeValue;
        gmcCaption.txtCap.textColor = captionColor;
    }
}

Thumb.prototype.doRelease = function(){
           
    this.enabled = false;
    gaThumbs[gCurrentImageId].enabled = true;
   
    if (this.thumbLoaded){
        if (!this.imageLoaded){   
            this.makeCurrent();
        }else{
            //do transition to new image
            gaImages[this.id].showImage();               
        }
    }
    gmcSelected._x = this._x;
    gmcSelected._y = this._y;
   
    //slide thumbs?   
    gThumbPageId = Math.floor(this.id / thumbnailDisplayCount);
    updateThumbs();

}

Thumb.prototype.makeCurrent = function(){       
   
    imageLoader.makeCurrent(this.imageLoadId);   
    //show image loader over current image       
    gmcImageLoadBar.mcBar._width = 0;
    gmcImageLoadBar._visible = true;
    gPendingImageId = this.id;
    ////////////
    gmcImageLoadBar.onEnterFrame = function(){       
        //display load progress bar           
        this.mcBar._width =  gaThumbs[gPendingImageId].mcImageListener.p * 106/100;
           
        if (this.p == 100){
            this.onEnterFrame = undefined;
        }
    }
    ////////////
   
}

Thumb.prototype.loadImage = function(){
    //create image mc
    //gaImages[this.id] = gmcDisplayArea.mcImage.attachMovie("sImage","image"+this.id,gNextLevel++);
    gaImages[this.id] = gmcMain.attachMovie("sImage","image"+this.id,gNextLevel++,{id:this.id});

    gaImages[this.id]._visible = false;
   
    //create image load listener
    this.createEmptyMovieClip("mcImageListener", 2);
    gaImages[this.id].mcImage.createEmptyMovieClip("mcLoader", 1);
    //gaImages[this.id].mcImage.attachMovie("sImageHolder","mcLoader", 1);
               
    this._parent.mcThumb.mcDark._width =  this._parent.mcBkgnd._width;
   
    this.mcImageListener.onEnterFrame = function(){
       
        var loadclip = gaImages[this._parent.id].mcImage.mcImage;                   
        var total = loadclip.getBytesTotal();
        var kLoaded = loadclip.getBytesLoaded();   
        this.p = Math.floor((kLoaded/total)*100);
                       
        if (total < 16){
            this.p =0;
        }
       
        //display load progress bar           
        this._parent.mcThumb.mcShadow._width =  THUMB_WIDTH * (100 - this.p)/100;
        this._parent.mcThumb.mcBar._width =  THUMB_WIDTH * this.p/100;

        this._parent.txtLoad.text = this.p;
       
        if (loadclip.getBytesLoaded() == loadclip.getBytesTotal() && loadclip.getBytesLoaded() > 16){
           
        //if (kLoaded > 16 && kLoaded >= total  && loadclip._width > 1){       
            this.onEnterFrame = undefined;
            //do on loaded
            this._parent.imageLoaded = true;
            gaImages[this._parent.id].onImageLoaded();
            this._parent.mcThumb.mcBar._visible = false;
        }
       
       
    }
   
    //start loading in image   
    this.imageLoadId = imageLoader.load(gaImages[this.id].mcImage.mcImage, gImagePath+this.XMLData.firstChild.firstChild.nodeValue);
   
}


Thumb.prototype.centerThumb = function(){

    mcOuter = this;
    mcInner = this.mcThumb.mcThumb.mcThumb;
    mcBorder = this.mcThumb.mcBkgnd;
    mcDark = this.mcThumb.mcDark;
    borderWidth = thumbBorderWidth;
   
    //no resizing
    mcInner._x = mcOuter._width - mcInner._width;
    mcInner._y = mcOuter._height - mcInner._height;
   
}

/////////////////////////////////////////////
// IMAGE
/////////////////////////////////////////////

function Image(){
   
    colFrame = new Color(this.mcImage.mcBkgnd);
    colFrame.setRGB(frameColor);   
   
}

Image.prototype = new MovieClip();

Object.registerClass("sImage", Image);

Image.prototype.fadeOut = function(){
    //trace("FADE OUT");
    this.gotoAndPlay("fadeOut");
   
}

Image.prototype.onFadeOutDone = function(){
    //trace("FADE OUT DONE");
    this._visible = false;
   
}

Image.prototype.fadeIn = function(){
    //trace("FADE In");
    this._visible = true;
    this.gotoAndPlay("fadeIn");
   
}

Image.prototype.onImageLoaded = function(){
       
    //if this is current image than show it
    if (gPendingImageId == this.id){
        this.showImage();       
    }       
}

Image.prototype.showImage = function(){
   
    TRACE("SHOWIMAGE");
    gaImages[gCurrentImageId].fadeOut();
    this.fadeIn();   
    gCurrentImageId = this.id;
    gmcImageLoadBar._visible = false;
    gaThumbs[this.id].mcViewed._visible = true;
    gPendingImageId = -1;
    //show this caption
    gmcCaption.txtCap.htmlText = gaThumbs[gCurrentImageId].XMLData.childNodes[1].firstChild.nodeValue;
    gmcCaption.txtCap.textColor = captionColor;
    this.centerImage();
       
    xableImghandCursors();   
    //if mouse already over img on first show image - show next icon
    if (!gShownFirstImage){       
    gShownFirstImage = true;
        if (gmcImageButtons.mcBack.hitTest(gmcMain._xmouse,gmcMain._ymouse)){
              gmcImageButtons.mcBack.onRollOver();
        }
        if (gmcImageButtons.mcNext.hitTest(gmcMain._xmouse,gmcMain._ymouse)){
              gmcImageButtons.mcNext.onRollOver();
        }
        //only show 1st selected after thumb is loaded
        gmcSelected._visible = true;
       
    }
    else{
        //hide img nav icons
        gmcImgBackIcon._visible = false;
        gmcImgNextIcon._visible = false;
    }
   
}

Image.prototype.centerImage = function(){
   
    mcOuter = gmcDisplayArea;
    mcInner = this.mcImage.mcImage;
    mcBorder = this.mcImage.mcBkgnd;
    mcShadow = this.mcImage.mcShadow;
    borderWidth = imageBorderWidth;
           
    //centers an MC relative to parent
    //and proporpionally scales it to fit parent
   
    mcInner._xscale = 100;
    mcInner._yscale = 100;
    if (mcInner._width > mcInner._height){

        //fat
       
        //only scale down
        if (mcInner._width >= mcOuter._width){
            var oldWidth = mcInner._width;
            mcInner._width = mcOuter._width - borderWidth*2;
            mcInner._height = mcInner._height*mcInner._width/oldWidth;
        }
           
    }else{
        //skinny   
        if (mcInner._height >= mcOuter._height){
            var oldHeight = mcInner._height;
            mcInner._height = mcOuter._height - borderWidth*2;
            mcInner._width = mcInner._width*mcInner._height/oldHeight;       
        }           
                       
    }
    //center
    mcInner._y = Math.floor((mcOuter._height - mcInner._height)/2);
    mcInner._x = Math.floor((mcOuter._width - mcInner._width)/2);
   
    trace("centerImage WIDTH: " + mcInner._width);   
    mcBorder._x = mcInner._x - borderWidth;
    mcBorder._width = mcInner._width + borderWidth*2;
    mcBorder._y = mcInner._y - borderWidth;
    mcBorder._height = mcInner._height+ borderWidth*2;

    this._x =displayAreaX;
    this._y =displayAreaY;
   
    //place img nav icons
    if (gNavDir == "LTR"){
        gmcImgBackIcon._x = this._x  + mcInner._x + mcInner._width - THUMB_WIDTH;
        gmcImgNextIcon._x = this._x  + mcInner._x;                   
    }else{
        gmcImgNextIcon._x =this._x  + mcInner._x + mcInner._width - THUMB_WIDTH;
        gmcImgBackIcon._x = this._x  + mcInner._x;   
    }
    gmcImgNextIcon._y = gmcImgBackIcon._y = this._y  + mcInner._y + mcInner._height - THUMB_WIDTH;       
}

init();
Avatar billede jakwag Nybegynder
19. august 2005 - 14:41 #1
åhr nej. ikke den igen... LOL

Prøv at slette denne bid nede i bunden. Har ikke testet det så det er kun et gæt:

if (mcInner._width > mcInner._height){

        //fat
       
        //only scale down
        if (mcInner._width >= mcOuter._width){
            var oldWidth = mcInner._width;
            mcInner._width = mcOuter._width - borderWidth*2;
            mcInner._height = mcInner._height*mcInner._width/oldWidth;
        }
           
    }else{
        //skinny   
        if (mcInner._height >= mcOuter._height){
            var oldHeight = mcInner._height;
            mcInner._height = mcOuter._height - borderWidth*2;
            mcInner._width = mcInner._width*mcInner._height/oldHeight;       
        }           
                       
    }
Avatar billede rafix Nybegynder
19. august 2005 - 15:03 #2
hehe - ja den er dræber!

Tak. det prøver jeg lige
Avatar billede rafix Nybegynder
19. august 2005 - 17:09 #3
sådan der jakwag
jeg skulle bare fjerne 2 af linierne i //only scale down

tak for hjælpen

skylder dig point
Avatar billede jakwag Nybegynder
23. august 2005 - 09:42 #4
lucky shot! :D
Avatar billede rafix Nybegynder
13. september 2005 - 13:59 #5
;)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester