# Horizontal MC Scroll

**URL:** https://forum.kirupa.com/t/horizontal-mc-scroll/33479
**Category:** flash
**Created:** [October 20, 2003, 2:47am UTC](https://forum.kirupa.com/t/horizontal-mc-scroll/33479 "2003-10-20T02:47:03Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 23, 2003, 4:07pm UTC](https://forum.kirupa.com/t/horizontal-mc-scroll/33479/21 "2003-10-23T16:07:13Z")

</div>

Well, here’s the way ive set up my fla:  
[AS]stageW = Stage.width;  
stageH = Stage.height;  
space = 5;  
speed = 3;  
holder\_mc.loadMovie(“rocket.jpg”);  
this.createEmptyMovieClip(“temp”, 100);  
this.createEmptyMovieClip(“temp2”, 101);  
temp.onEnterFrame = function() {  
if (holder\_mc.\_width\>0) {  
step = holder\_mc.\_width/3;  
mask\_mc.\_x = stageW/2-step/2;  
mask\_mc.\_y = stageH/2-holder\_mc.\_height/2;  
mask\_mc.\_width = step;  
mask\_mc.\_height = holder\_mc.\_height;  
holder\_mc.\_x = mask\_mc.\_x;  
holder\_mc.\_y = mask\_mc.\_y;  
start = mask\_mc.\_x;  
a = holder\_mc.\_x-space;  
b = holder\_mc.\_y-space;  
c = holder\_mc.\_x+mask\_mc.\_width+space;  
d = holder\_mc.\_y+holder\_mc.\_height+space;  
with (this) {  
lineStyle(2, 0x333333, 100);  
moveTo(a, b);  
lineTo(c, b);  
lineTo(c, d);  
lineTo(a, d);  
lineTo(a, b);  
}  
rew\_btn.\_y = ff\_btn.\_y=d+space;  
rew\_btn.\_x = a;  
ff\_btn.\_x = a+ff\_btn.\_width+space;  
delete this.onEnterFrame;  
}  
};  
scroll = function () {  
temp2.onEnterFrame = function() {  
if (Math.abs((start-n_step)-holder\_mc.\_x)\<1) {  
trace(“done”);  
delete this.onEnterFrame;  
} else {  
trace(“scrolling”);  
holder\_mc.\_x += ((start-n_step)-holder\_mc.\_x)/speed;  
}  
};  
};  
ff\_btn.onPress = function() {  
n\>=2 ? n=2 : (n++, scroll());  
};  
rew\_btn.onPress = function() {  
n\<=0 ? n=0 : (n–, scroll());  
};  
[/AS]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 23, 2003, 4:17pm UTC](https://forum.kirupa.com/t/horizontal-mc-scroll/33479/22 "2003-10-23T16:17:15Z")

</div>

Im giving you a tip 😉  
Look how ive setup my functions and youll see that the onEnterFrame is only called when you press the buttons, and after its not necessary anymore, its deleted.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 23, 2003, 4:31pm UTC](https://forum.kirupa.com/t/horizontal-mc-scroll/33479/23 "2003-10-23T16:31:11Z")

</div>

maybe something like this

```auto
_global.portfolioSection = function() {
	path = _root.sectionMC_03.folioClip;
	maxWidth = path.section_mc._width-529;
	velocity = 4;
	targetX = 527;
	path.section_mc.onEnterFrame = function() {
		if (Math.abs(targetX-this._x)<1) {
			trace("done");
			delete this.onEnterFrame;
		} else {
			trace("scrolling");
			this._x += (targetX-this._x)/velocity;
		}
	};
	// Forward Button
	path.forward_btn.onRelease = function() {
		if (targetX>-(maxWidth-370)) {
			targetX -= 370;
		}
	};
	// Back Button
	path.back_btn.onRelease = function() {
		if (targetX<527) {
			targetX += 370;
		}
	};
};

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 24, 2003, 11:06pm UTC](https://forum.kirupa.com/t/horizontal-mc-scroll/33479/24 "2003-10-24T23:06:44Z")

</div>

Hello All,

I finally got this thing working. If y’all could check it out, I have one final question having to do with this piece. Would there be a way to substitute an MC or a textlink in place of an element in the array? sometimes i might want to include more than just text.

[AS]

portfolioSection(["", “section1”, “section2”, “section3”, “section4”]);

[/AS]

[Previous page](https://forum.kirupa.com/t/horizontal-mc-scroll/33479.md?page=1)
