Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need help with parallax site mouse restrictions.

Posted on 2008-06-17
4
Medium Priority
?
390 Views
Last Modified: 2013-11-11
Hi experts,

I have been building a site using a parallax flash extension. I want the site to be 100% windowed as I have drag-able windows.

The problem is I'm not good with Actionscript and somehow I need to limit the parallax code to the width of my site (900px). The borders of the site are marked with two vertical leave pillars.

I basically have the parallax code on each item on the stage which I wish to move, and there is a variable relating to the code on the first frame.

I have tried myself to limit the mouse movement with this code, which you will see in the snippet below. please let me know if I am way off, I have never done parallax before.

Math.max( 0, Math.min( 900, _xmouse ) )

This is the site: http://www.rpbooks.co.uk/look

And this is one variation of the parallax code on an object on the stage:
onClipEvent (enterFrame) {
	Math.max( 0, Math.min( 800, _xmouse ) )
	if (_root.mainVar == 0) {
		homeX = (-_root._xmouse*3.1)+3700;
	} else {
		homeX = (-_root.mainVar*3.1)+3700;
	}
	thisX = _x;
	diffX = homeX-thisX;
	if (_root.mainVar == 0) {
		moveX = diffX/30;
	} else {
		moveX = diffX/5;
	}
	_x = thisX+moveX;
}

Open in new window

0
Comment
Question by:Nutbeen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Expert Comment

by:SamuelRostol
ID: 21854956
Hi there,

I'm sorry to say, but this line:
Math.max( 0, Math.min( 800, _xmouse ) )

Makes "no sense" - the math is correct enough, but you don't assign the resulting value to any variable, thus you are not able to get the value later..

If you are trying to limit the movement of the mouse, it's impossible in Flash. However, you can limit the area where the mouse affects the movement.

Is this what you are trying to do?

Kindly,
Samuel
0
 

Author Comment

by:Nutbeen
ID: 21864242
Hi,

Yes thats what I'm trying to achieve. I am bascially trying to find a way to stop my flash site scrolling past the two points I wish it to stop at.

Thanks
0
 
LVL 12

Accepted Solution

by:
SamuelRostol earned 2000 total points
ID: 21873667
Well, the principle is pretty basic;

You figure out the minimum and maximum value for x each moveable object has, and for every time the object move, you check the x-position on those two values. If the x-position is above the upper value, you set the x-position to the upper value, and if it's lower than the low value, you set the x-position to that value.

That way, the clip will never get the possibility to move past the defined edges..

Kindly,
Samuel
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question