Solved

Scrolling question

Posted on 2007-04-02
6
243 Views
Last Modified: 2010-04-03
Hi, Experts
I have a script that import images from external folder. The script also create a menu on top of each image. I would like to be able to move these images and menus up and down by using scrolling function. However, it can only scroll the last image only. I think it is kind hard to explain, does anyone have idea how to make all images to scroll ? Thanks

var _loc1 = this;
//
function loadMe() {
      myX = 62;
      myY = 125;
      gap = 105;
      gap2 = 0.66;
      max = 4;
      counter = 0;
      for (n=1; n<howMany; n++) {
            mc = _loc1.createEmptyMovieClip("myTarget"+n, 20+n);
            trace("Project list n = "+n);
            picture = "netblue/"+projects[n]+".jpg";
            mc.loadMovie(picture);
            if (counter>max) {
                  counter = 0;
                  myY = myY+gap;
            }
            // end if                                                      
            mc._x = myX+gap*counter;
            mc._y = myY*gap2;
            trace("counter:"+counter);
            ++counter;
      }
      // end of for
      if (howMany>20) {
            trace("Too many!!");
            //for (i=20; i>20; i++) {
            trace("Trace n = "+n);
            //}
      }
}
// End of the function
function buildMenu() {
      myX = 62;
      myY = 125;
      gap = 105;
      gap2 = 0.66;
      max = 4;
      counter = 0;
      for (i=1; i<howMany; i++) {
            mc = _loc1.attachMovie("button", "button"+i, 50+i);
            trace("Menu list --   "+i);
            mc.i = i;
            _loc1.myName = i;
            _loc1.myName = _loc1.projects[i];
            mc.person.text = _loc1.myName;
            trace("myName --   "+myName);
            _loc1.n = i;
            if (counter>max) {
                  counter = 0;
                  myY = myY+gap;
            }
            // end if                                                      
            mc._x = myX+gap*counter;
            mc._y = myY*gap2;
            trace("counter:"+counter);
            ++counter;
      }
      // end of for
}

_loc1.upStatus = 0;
//
var myListener = new Object();
myListener.onLoadInit = function(target_mc) {
      this.imageborder = 9;
      target_mc._x = -(target_mc._width/2);
      target_mc._y = -(target_mc._height/2);
      trace("Picture width  "+target_mc._width);
      //Load white BG
      _loc1.attachMovie("whiteOutBG", "whiteOutBG", 9998);
      _loc1.whiteOutBG._width = target_mc._width+2*this.imageborder;
      _loc1.whiteOutBG._height = target_mc._height+2*this.imageborder;
      _loc1.whiteOutBG._x = 322;
      _loc1.whiteOutBG._y = 222;
};
var mcLoader = new MovieClipLoader();
mcLoader.addListener(myListener);
//Scroller part --- need fix
increment = 20;
downLimit = -112;
upLimit = 0;
down.onPress = function() {
      if (picture._y>downLimit) {
            mc._y = mc._y-increment;
      }
};
up.onPress = function() {
      if (mc._y<upLimit) {
            mc._y = mc._y+increment;
      }
};
// End of the function
#include "netblue/netblueList.as"
var scrolling = 0;
var howMany = projects.length;
var n = 1;
loadMe();
buildMenu();
var myName;
stop();
0
Comment
Question by:mingchih
  • 3
  • 3
6 Comments
 
LVL 1

Expert Comment

by:Fern2
ID: 18835327
Can you upload a ZIP file with your files, so we can take a look at it?
0
 

Author Comment

by:mingchih
ID: 18840368
Hi
Here is the Fla link http://www.brianlinstudio.com/scrollerExample.zip
Thanks
0
 
LVL 1

Accepted Solution

by:
Fern2 earned 500 total points
ID: 18842758
Replace this with your current code and try. Should work.

var _loc1 = this;
//
function loadMe() {
      myX = 62;
      myY = 125;
      gap = 105;
      gap2 = 0.66;
      max = 4;
      counter = 0;
      var ScrollMovie:MovieClip = _loc1.createEmptyMovieClip("ScrollMovie",1);
      for (n=1; n<howMany; n++) {
            mc = ScrollMovie.createEmptyMovieClip("myTarget"+n, 20+n);
            picture = "netblue/"+projects[n]+".jpg";
            eval("ScrollMovie.myTarget"+n).loadMovie(picture);
            if (counter>max) {
                  counter = 0;
                  myY = myY+gap;
            }
            // end if                                                      
            mc._x = myX+gap*counter;
            mc._y = myY*gap2;
      ++counter;
      }
}
// End of the function
function buildMenu() {
      myX = 62;
      myY = 125;
      gap = 105;
      gap2 = 0.66;
      max = 4;
      counter = 0;
      for (i=1; i<howMany; i++) {
            //mc = ScrollMovie.createEmptyMovieClip("myTarget"+n, 20+n);
            mc = ScrollMovie.attachMovie("button", "button"+i, 50+i);
            mc.i = i;
            _loc1.myName = i;
            _loc1.myName = _loc1.projects[i];
            mc.person.text = _loc1.myName;
            _loc1.n = i;
            if (counter>max) {
                  counter = 0;
                  myY = myY+gap;
            }
            // end if                                                      
            mc._x = myX+gap*counter;
            mc._y = myY*gap2;
            ++counter;
      }
      // end of for
}
_loc1.upStatus = 0;
//
var myListener = new Object();
myListener.onLoadInit = function(target_mc) {
      this.imageborder = 9;
      target_mc._x = -(target_mc._width/2);
      target_mc._y = -(target_mc._height/2);
      //Load white BG
      _loc1.attachMovie("whiteOutBG", "whiteOutBG", 9998);
      _loc1.whiteOutBG._width = target_mc._width+2*this.imageborder;
      _loc1.whiteOutBG._height = target_mc._height+2*this.imageborder;
      _loc1.whiteOutBG._x = 322;
      _loc1.whiteOutBG._y = 222;
};
var mcLoader = new MovieClipLoader();
mcLoader.addListener(myListener);
//Scroller
increment = 20;
downLimit = -112;
upLimit = 0;
down.onPress = function() {
      if (ScrollMovie._y>downLimit) {
            ScrollMovie._y = ScrollMovie._y-increment;
      }
};
up.onPress = function() {
      if (ScrollMovie._y<upLimit) {
            ScrollMovie._y = ScrollMovie._y+increment;
      }
};
// End of the function
#include "netblue/netblueList.as"
var scrolling = 0;
var howMany = projects.length;
var n = 1;
loadMe();
buildMenu();
var myName;
stop();
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:Fern2
ID: 18842802
Sorry I meant "Replace your current code with this" :(
0
 

Author Comment

by:mingchih
ID: 18846696
Cool, Thanks a lot, Fern.... I may have more Qs about this projects... do you provide info that I can send you my Q on EE ? :)
0
 

Author Comment

by:mingchih
ID: 18848678
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

791 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