Solved

Scrolling question

Posted on 2007-04-02
6
248 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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…
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…
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 how to how to load their YouTube profile onto Flash Media Live Encoder.

680 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