PDA

View Full Version : Conveyer Belt Display


Sean611
07-24-2006, 03:11 AM
Hi guys, here is my problem again. i wanna create a flash look like this ( http://www.dynamicdrive.com/dynamici...rightslide.htm ), but i tried many thing and it doesn't works.
i had tried using the setInterval and also using time delay like getTime(). i think mayb i was wrongly wrote the script. If can i hope some expertise can post up some sample coding which is full. Tx guys !

xeno439
07-24-2006, 05:38 AM
Page doesn't work. I am real curious to see that though. I had an idea about a conveyor belt that I wanted to use also.

Sean611
07-24-2006, 05:50 AM
Sorry ... this is the site
http://www.dynamicdrive.com/dynamicindex14/leftrightslide.htm

mapvnfx
07-24-2006, 12:13 PM
is this similar to what you want? :D (see attachment)

some of my steps to do this:
-create a MovieClip named "mc"
-place the movie (which you want to scroll) and its copy into "mc". named the copied movie as "the_copy" and put it next to the original movie.
-code at the main timeline:

mc.speed = (mc._width / 200); // 200 steps
mc.destination = -mc.the_copy._x;
mc._x = 0;

mc.onEnterFrame = function() {
this._x -= this.speed;
if (mc._x <= mc.destination) {
mc._x = 0;
}
}

in each button inside the scroll movie:

on (press) {
getURL("http://");
}
on (rollOver) {
_root.mc.speed = 0;
}
on (rollOut) {
_root.mc.speed = _root.mc._width / 200;
}

it's easy, right? ;)

Sean611
07-25-2006, 02:11 AM
mapvnfx , thanks for your time :) . I had downloaded your attachment but the fla file i cant open. It said unexpected format. :rolleyes:

The number of mc is it precreate? If yes then very sorry for not stated clearly. Actually the number of mc is follow my database which means if inside the database got 7 pictures it will create 7 mc to put them in.

The output is like what you had created just the number of mc will not be fixed.:D

mapvnfx
07-25-2006, 03:32 AM
Hi :D

my fla file was saved in Flash8 format, maybe you're using a lower version of Flash

if you want to create the mc dinamically, just load the variables from database and use some scripts to create & put it into main movie instead of placing it into the stage manually (hic, sorry for my poor English)

i can only load variables from text file or XML file (have no experience working with database like MySQL, Access,...) so i can't help :rolleyes:
but if you've loaded all the needed variables and passed it into flash, maybe i can help to create the conveyor belt :D

this is a fla file in FMX2004 format (if you still need it :p )

Sean611
07-25-2006, 06:23 AM
mapvnfx , u r brilliant !! just a few coding and u can make the belt run smoothly.:eek:

i tried to modify ur fla to suit my task but i had failed :( . I try to change the size of mc and canvas size then evrything seem stop there.

Then i try to copy ur code and place it into my fla , it doesn't works. This is a copy of my conveyer belt which under fmx 2004.

In there i got a original mc, so is it possible that i use for loop to create a numbers of mc and move like what u done? :confused:

mapvnfx
07-25-2006, 09:02 AM
this is another example :)

it loads data from a TXT file: data.txt which contents the number of the pictures and paths of these pictures.
&total=5&list=image1.jpg,image2.jpg,image3.jpg,image4.jpg,i mage5.jpg
you can use PHP, ASP or other languages to get variables from database and save to this file. (there must be many better ways to get variables directly from database but i haven't tried yet :rolleyes: )

there's only one masked (empty) mc on the stage named: "mc" and here's all the code (it could be longer and more complex, depends on the pictures will be loaded):

// load variables
loadVariablesNum("data.txt", 0);
// wait for data to be loaded
itv=setInterval(function(){ if (total!=undefined) dataLoaded(); }, 10);
function dataLoaded() {
clearInterval(_root.itv);
li = list.split(",");
loadPictures();
}
// load pictures into main movie
function loadPictures() {
_root.mc._visible = false;
_root.count = 0; // how many pic has been loaded?
var mcl:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
mcl.addListener(listener);
listener.onLoadInit = function() {
if (++_root.count >= total*2) {
initBeforeMove();
letsMove();
}
}

_root.mc.createEmptyMovieClip("origin", 0);
_root.mc.createEmptyMovieClip("the_copy", 1);
for (var i=0; i<total; i++) {
pic_mc=_root.mc.origin.createEmptyMovieClip("pic" + i, i);
mcl.loadClip(li[i], pic_mc);
pic_mc=_root.mc.the_copy.createEmptyMovieClip("pic" + i, i);
mcl.loadClip(li[i], pic_mc);
}
}
// init before move
function sortMC(the_mc: MovieClip) {
for (var i=0; i<total; i++) {
// rearrange pictures
if (i>0)
the_mc["pic"+i]._x = the_mc["pic"+(i-1)]._x + the_mc["pic"+(i-1)]._width;
// set actions
the_mc["pic"+i]._height = _root.mc._height;
the_mc["pic"+i].onRollOver = function() {
_root.mc.speed = 0;
}
the_mc["pic"+i].onRollOut = function() {
_root.mc.speed = _root.mc._width / 200;
}
the_mc["pic"+i].onRelease = function() {
getURL("http://www.vnfx.com","_blank");
}
}
}
function initBeforeMove() {
_root.mc._visible = true;
sortMC(_root.mc.origin);
sortMC(_root.mc.the_copy);
_root.mc.the_copy._x = _root.mc.origin._width;
}
// start moving
function letsMove() {
_root.mc.speed = (_root.mc._width / 200); // 200 steps
_root.mc.destination = -_root.mc.the_copy._x;
_root.mc._x = 0;

_root.mc.onEnterFrame = function() {
this._x -= this.speed;
if (this._x <= this.destination) {
this._x = 0;
}
}
}


too long, right? :D

Sean611
07-25-2006, 10:15 AM
mapvnfx , thanks to u again. You are the man !!! :eek: :eek:

Thanks man !

Sean611
07-26-2006, 03:19 AM
Here me again mapvnfx, if i need to add onRollover and onRollOut picture how am i going to write ?
is it like this ?

mcl.loadClip(li[i],the_mc["pic"+i]);
:confused: :confused:

mapvnfx
07-26-2006, 04:35 AM
hi, you want to add more pictures? :D

change the content of the file data.txt :

&total=5&list=image1.jpg,image2.jpg,image3.jpg,image4.jpg,i mage5.jpg

&total=5 -> 5 pictures to load
&list=pics/image1.jpg,picture/image2.jpg -> paths of the pictures, separated by a comma "," (there's no more blank spaces before and after a comma, or you must change the code to make it run :D)

you can do it using some server-side languages to load variables from your database and than write these variables to this file (this I can't help! I haven't studied PHP, ASP,... yet)

or you can do it manually: just change the variables in data.txt as you want

ah, besides, if there's any error loading a pictures, the conveyer will not run because the number of pictures loaded doesn't matches with the "total" defined in data.txt. (i should add some more lines of code to fix this :D)

and if you want each picture to have a difference link, put them all into data.txt and change the code again

this is belt1.zip with a little change. enjoy :)

Sean611
07-26-2006, 08:14 AM
Here is my files ... and thanks you so much ...
Your attachment works perfectly ... but now i hope can make the picture got the effect like onMouseOver and onMouseOut.

mapvnfx
07-26-2006, 09:19 AM
oh i misunderstood your idea :D

now i did another sample and here's your files:

Sean611
07-26-2006, 10:00 AM
OMG !! :eek:
You are my life saver ... :D

mapvnfx
08-01-2006, 03:20 AM
try this example to load the belt into another movie :)

Sean611
08-01-2006, 04:06 AM
Here is my look-a-like index. Thanks for your time! :D

mapvnfx
08-01-2006, 04:24 AM
:)

it's very simple to create the index.swf to load the belt:

create an empty mc named "advert" and then use this code to load the movie:
loadMovie("belt2.swf", _root.advert);

all the things we should consider about was put in the belt2.swf :rolleyes:

Sean611
08-01-2006, 04:37 AM
Actually the problem is .... when i load the belt into the index. The picture wont display out. Now i going yo try delete the bottom part and recreate again. Now i just know the "advert" is a empty movie clips :p

I just notice that when i open your belt i can see the pictures moving. But mine i cant see anything when i open its flash. I only can see the pictures is when i open the ASP file (which load the flash out).

Here is my "road" for the flash to get picture.

Index.swf load belt.swf then belt.swf call variable from the ASP file call advert.asp then flash.asp get the value from the database.

mapvnfx
08-01-2006, 04:51 AM
it works fine in your ASP file?

well then, i think when you run the flash file outside your ASP site, that flash movie does not have permission to access the database. so you may have to export movie and test it in your browser :D

Sean611
08-04-2006, 07:11 AM
now im going to make the belt from bottom to top

so is it the way i correct the action script ?

// init before move
function sortMC(the_mc: MovieClip) {
for (var i=0; i<total; i++) {
// rearrange pictures
if (i>0) {
the_mc["pic"+i]._y = the_mc["pic"+(i-1)]._y + the_mc["pic"+(i-1)]._height + 50;
the_mc["hover"+i]._y = the_mc["pic"+i]._y;
}
the_mc["pic"+i]._height = _root.mc._height;
the_mc["hover"+i]._height = _root.mc._height;
the_mc["hover"+i]._width = the_mc["pic"+i]._width;
the_mc["hover"+i]._visible = false;

// set actions
the_mc["pic"+i].onRollOver = function() {
_root.mc.speed = 0;
this._visible = false;
this._parent["hover" + this._name.slice(3)]._visible = true;
}
the_mc["hover"+i].onRollOut = function() {
_root.mc.speed = (_root.mc._height / 400);
this._visible = false;
this._parent["pic" + this._name.slice(5)]._visible = true;
}
if (st[i] == "on"){
alink =lin[i];
the_mc["hover"+i].onRelease = function() {
getURL(alink,"_blank");
}
}
}
}

function initBeforeMove() {
_root.mc._visible = true;
sortMC(_root.mc.origin);
sortMC(_root.mc.the_copy);
_root.mc.the_copy._y = _root.mc.origin._height+50;
}

// start moving
function letsMove() {
_root.mc.speed = (_root.mc._height / 400);
_root.mc.destination = _root.mc.the_copy._y;
_root.mc._y = 0;

_root.mc.onEnterFrame = function() {
this._y += this.speed;
if (this._y <= this.destination) {
this._y = 0;
}
}
}

but something very funny happen ... the picture not loaded (mayb it is the path problem) the funniest thing is ... when i onRollOver the belt doesn't stop there ... the MC's are created and move from bottom to top but the speed seem like i cant modify it .... no matter how many step i devide it seem run at same speed. Any idea ?:D

mapvnfx
08-04-2006, 07:52 AM
hi :D

i found some mistakes in your code. this is my modification :)

change:
the_mc["pic"+i]._height = _root.mc._height;
the_mc["hover"+i]._height = _root.mc._height;
the_mc["hover"+i]._width = the_mc["pic"+i]._width;
the_mc["hover"+i]._visible = false;
to:
the_mc["pic"+i]._width = _root.mc._width;
the_mc["hover" + i]._width = _root.mc._width;
the_mc["hover" + i]._height = the_mc["pic" + i]._height;
the_mc["hover" + i]._visible = false;

change:
the_mc["hover"+i].onRollOut = function() {
_root.mc.speed = (_root.mc._height / 400);
this._visible = false;
this._parent["pic" + this._name.slice(5)]._visible = true;
}
to:
the_mc["hover"+i].onRollOut = function() {
_root.mc.speed = -(_root.mc._height / 400);
this._visible = false;
this._parent["pic" + this._name.slice(5)]._visible = true;
}

chage:
function letsMove() {
_root.mc.speed = (_root.mc._height / 400);
_root.mc.destination = _root.mc.the_copy._y;
_root.mc._y = 0;
....

to:
function letsMove() {
_root.mc.speed = -(_root.mc._height / 400);
_root.mc.destination = -_root.mc.the_copy._y;
_root.mc._y = 0;
....
}

and the speed is changeable. just change the number of steps in -(_root.mc._height / 400);. i tested and it works :D

good luck!
___________
this is a sample. i just made the belt to go from bottom to top. some other things (such as: link, onRelease,...) i got from a old file and have no time to renew the code ^^