Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Aug 2003
    Posts
    194
    Member #
    2782
    Hi Everyone,

    I am new to complex Actionscripting. I found a script online that uses the fading squares to transition between pictures, and it works great. However, when it first starts, it begins halfway in the middle of one image, and I would like for it to start on one image in its entirety. Can any knowledgeable person look at the following script and tell me what needs to be done for it to work?

    Thanks.

    Code:
    image = {Width:770, Height:380, total:3};
    segmentCount = 100;
    cols = 12;
    rows = 3;
    fadeAmount = 5;
    maskTotal = cols*rows;
    maskWidth = image.Width/cols;
    maskHeight = image.Height/rows;
    addSegmentNow = true;
    fadeNow = true;
    container = [];
    faders = [];
    time = {stamp:0, delay:120};
    bottomNum = 1;
    this.createEmptyMovieClip("top", 3);
    this.createEmptyMovieClip("bottom", 1);
    bottom.attachMovie("allImages", "image", 2);
    bottom.image.gotoAndStop(bottomNum);
    function createSegments() {
    	for (var i = 0; i<cols; i++) {
    		for (var j = 0; j<rows; j++) {
    			var b = top.createEmptyMovieClip("segment"+segmentCount, segmentCount);
    			b.image = b.attachMovie("allImages", "image"+segmentCount, 5000+segmentCount);
    			b.image.gotoAndStop(3);
    			b.mask = b.attachMovie("mask", "mask"+segmentCount, 10000+segmentCount);
    			b.image.setMask(b.mask);
    			b.mask._width = maskWidth;
    			b.mask._height = maskHeight;
    			b.mask._x = (maskWidth*i);
    			b.mask._y = maskHeight*j;
    			b.faded = false;
    			container.push(b);
    			segmentCount++;
    		}
    	}
    }
    createSegments();
    top._x = bottom._x=maskes._x=25;
    top._y = bottom._y=maskes._y=25;
    time.stamp = getTimer();
    function checkTime() {
    	if (getTimer()>=time.stamp+time.delay) {
    		time.delay = 30;
    		time.stamp = getTimer();
    		addSegment();
    	}
    }
    function addSegment() {
    	if (addSegmentNow) {
    		if (container.length>0) {
    			var ranRow = random(container.length);
    			faders.push(container[ranRow]);
    			container.splice(ranRow, 1);
    		} else {
    			addSegmentNow = false;
    		}
    	}
    }
    function newImage() {
    	for (var i = 0; i<maskTotal; i++) {
    		faders[i]._alpha = 100;
    		faders[i].image.gotoAndStop(bottomNum);
    		faders[i].faded = false;
    		container.push(faders[i]);
    	}
    	if (bottomNum == image.total) {
    		bottomNum = 1;
    	} else {
    		bottomNum++;
    	}
    	faders.splice(0, maskTotal);
    	bottom.image.gotoAndStop(bottomNum);
    	fadeNow = true;
    	addSegmentNow = true;
    	time.stamp = getTimer();
    	time.delay = 2000;
    }
    function fadeSegments() {
    	for (var j = 0; j<faders.length; j++) {
    		if (!faders[j].faded) {
    			if (faders[j]._alpha<0) {
    				faders[j].faded = true;
    			} else {
    				faders[j]._alpha -= fadeAmount;
    			}
    		}
    		if (faders[maskTotal-1]._alpha<0) {
    			fadeNow = false;
    		}
    	}
    }
    function checkFade() {
    	if (!fadeNow) {
    		newImage();
    	} else {
    		fadeSegments();
    	}
    }
    this.onEnterFrame = function() {
    	checkFade();
    	checkTime();
    };

  2.  

  3. #2
    Senior Member Tomaszewski's Avatar
    Join Date
    Oct 2006
    Location
    Exton, PA
    Posts
    194
    Member #
    14132
    probably what's happening is flash is positioning the center of the image at the left edge of the mask.

    Go up an look at b.image._x and add to it's current value 1/2 the width of the image in quesion. That may solve the problem.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:36 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com