Jump to content
Search Community

Fullscreen Scroll with ThrowPropsPlugin and BlitMask

artlover test
Moderator Tag

Recommended Posts

hi,

 

its work test but

it is work in my web page one time and when it resize, it duplicate to my mc

 

import com.greensock.*; 
import com.greensock.easing.*;
import com.greensock.plugins.*;
import flash.geom.Rectangle;
import flash.utils.getTimer;
import flash.events.MouseEvent;
import flash.text.*;
import flash.display.*;

TweenPlugin.activate([ThrowPropsPlugin,MotionBlurPlugin]);

var bounds:Rectangle = new Rectangle(0, 100, stage.stageWidth, stage.stageHeight-100);
var t1:uint, t2:uint, y1:Number, y2:Number;
var currentPage:MovieClip=new MovieClip();
var blitMask:BlitMask= new BlitMask(currentPage, bounds.x, bounds.y, bounds.width, bounds.height, false);
var mcArray:Array=new Array();
var _mc:MovieClip;

for (var s:int=0; s<5; s++)
{
_mc=new mc();
_mc.name="_mc"+s;
mcArray.push(_mc);
mcArray[s].alpha=0;
mcArray[s].y=100;
addChild(mcArray[s]);
}

currentPage=mcArray[0];
currentPage.alpha=1;

scrollMc.scrollButton.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);

function mouseDownHandler(event:MouseEvent):void {
TweenLite.killTweensOf(scrollMc.scrollButton);
y1 = y2 = scrollMc.scrollButton.y;
t1 = t2 = getTimer();
scrollMc.scrollButton.startDrag(false, new Rectangle(0, 0, 0, scrollMc.bg.height-scrollMc.scrollButton.height));
scrollMc.scrollButton.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
scrollMc.scrollButton.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}

function enterFrameHandler(event:Event):void {
y2 = y1;
t2 = t1;
y1 = scrollMc.scrollButton.y;
t1 = getTimer();
}

function mouseUpHandler(event:MouseEvent):void {
scrollMc.scrollButton.stopDrag();
scrollMc.scrollButton.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
scrollMc.scrollButton.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
var time:Number = (getTimer() - t2) / 1000;
var yVelocity:Number = (scrollMc.scrollButton.y - y2) / time;
var yOverlap:Number = Math.max(0, scrollMc.bg.height - scrollMc.scrollButton.height);
ThrowPropsPlugin.to(scrollMc.scrollButton, {throwProps:{y:{velocity:yVelocity, max:yOverlap, min:0, resistance:300}},
											ease:Strong.easeOut,onUpdate:update}, 10, 0.3, 1);
}

function update():void
{
var numY:Number=-((currentPage.height-bounds.height)*(scrollMc.scrollButton.y/(scrollMc.bg.height-scrollMc.scrollButton.height)));
TweenMax.to(currentPage,0,{y:numY+100, motionBlur:true});
blitMask.update(null, true);
}

Link to comment
Share on other sites

i'm having a very difficult time understanding.

 

are you familiar with RESIZE event? take a look here: http://www.kirupa.com/developer/as3/res ... ng_as3.htm

 

that should be very helpful.

 

i think when the RESIZE happens you need to readjust your bounds and the size of the blitmask. you can use width / height or blitMask.setSize() : http://www.greensock.com/as/docs/tween/ ... l#setSize()

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...