A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [RESOLVED] Pulling down a projection screen...

  1. #1

    resolved [RESOLVED] Pulling down a projection screen...

    Hi,

    I was wondering if someone could point me in the right direction with this.

    I want to build a sort of pulled down projection screen thing using ActionScript.
    Basically the MC will come down with a picture on it.

    I have this starting code which doesn't work terribly well because it just moves the screen from top to bottom instantly.
    Code:
    on (release) {
    	do {_root.mcScreen._y+=1;
    	} while (_root.mcScreen._y<200);
    
    }
    Essentially I want the screen to smoothly scroll down into place over about half a second.

    Anybody able to point me in the direction?

    Ta

    Neil

  2. #2
    Senior Member
    Join Date
    Dec 2009
    Posts
    109

    Smile

    Code:
    on (release) {
    	if (this.dest == 200) {
    		this.dest = 0;
    	} else {
    		this.dest = 200;
    	}
    	this.onEnterFrame = function() {
    		this._y += (this.dest-this._y)/5;
    	};
    }
    You can replace the 200 and 0 with the desired y position.
    Syntax Error

  3. #3
    Thanks Adam, that is brilliant. Love the way is slows at the end. Perfect.

  4. #4
    Okay, when this code moves the MC down into place, the code is still running meaning that if I try and raise it again, the code (the EnterFrame section I would guess..) makes the MC go back down again.

    Would there be a way of stopping it in a way that would let me raise it again with a different MC button?

    Also, what does the 'dest' code do? I couldn't find reference to in the ActionScript dictionary I have here.

    Thanks..

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,518
    This code makes it go down this first time you click on it, and go up the next time you click on it...
    Code:
    on (release) {
    	if (this.dest == 200) {
    		this.dest = 0;
    	} else {
    		this.dest = 200;
    	}
    	this.onEnterFrame = function() {
    		this._y += (this.dest-this._y)/5;
    		if (Math.abs(this._y-this.dest)<1) {
    			delete this.onEnterFrame;
    		}
    	};
    }
    'dest' is just a user defined variable


    With this code on the movie clip, instance named 'myPullDown', it will go down when clicked.
    Code:
    on (release) {
    	this.dest = 200;
    	this.onEnterFrame = function() {
    		this._y += (this.dest-this._y)/5;
    		if (Math.abs(this._y-this.dest)<1) {
    			delete this.onEnterFrame;
    		}
    	};
    }
    With this code on the button (on the same level as 'myPulldown' movie clip), clicking on it makes the movie clip go up.
    Code:
    on (release) {
    	myPullDown.dest = 0;
    	this.onEnterFrame = function() {
    		myPullDown._y += (myPullDown.dest-myPullDown._y)/5;
    		if (Math.abs(myPullDown._y-myPullDown.dest)<1) {
    			delete this.onEnterFrame;
    		}
    	};
    }
    HTH

  6. #6
    Dawsonk,

    I believe what you described there nails the problem. I'll have a play about with later when parenting duties calm down.

    I did suspect that 'dest' was a variable but I only dip into ActionScript on wee occasions and I'd never seen a variable set against an object like that. Thanks.

  7. #7
    Just tried it out. Perfect. Thanks again.

    What gonna happen in the final product is that when a thumnail of an image is clicked, a larger version will get loaded into an MC in the screen and then lowered. Clicking on the button on the screen will then raise the sceen to show the thumbnails again.

Tags for this Thread

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