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

x
?
Solved

Import external images relate question

Posted on 2007-04-05
2
Medium Priority
?
219 Views
Last Modified: 2010-04-03
Hi, experts

I have the following code that import external images and it works pretty good. First, you click on small image then a bigger image will pop up... then click on pop up image and it will be gone..... however, the small image click earlier did not go back to the original size..... I wonder how to solve the problem. Thanks

Code

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);
            //mcLoader.loadClip(picture, eval("ScrollMovie.myTarget"+n));
            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
      mask_mc = _loc1.attachMovie("bg", "mask_mc", _loc.getNextHighestDepth());
      mask_mc._x = bg._x;
      mask_mc._y = bg._y;
      ScrollMovie.setMask(mask_mc);
      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 = ScrollMovie.attachMovie("button", "button"+i, 50+i);
            // Add the following to make rollOver works
            mc.btn.onRollOut = buttonOut;
            mc.btn.onRollOver = buttonOver;
            mc.btn.onRelease = buttonClick;
            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
}
// End of the function
function buttonOver() {
      _loc1 = this._parent._parent;
      trace("which one is roll over now --  "+this._parent);
      this._parent.gotoAndStop(6);
      _loc1.myName = _loc1.projects[i];
      mc = _loc1["myTarget"+this._parent.i];
      mc._xscale = mc._yscale=120;
      prev_width = this._parent._width;
      this._parent._xscale = this._parent._yscale=120;
      after_width = this._parent._width;
      this._parent.buffer = (after_width-prev_width)/2;
      this._parent._x -= this._parent.buffer;
      this._parent._y -= this._parent.buffer;
      mc._x -= this._parent.buffer;
      mc._y -= this._parent.buffer;
      mc.swapDepths(120);
      this._parent.swapDepths(121);
}
// End of the function
function buttonOut() {
      mc = _loc1["myTarget"+this._parent.i];
      mc._xscale = mc._yscale=100;
      this._parent._x += this._parent.buffer;
      this._parent._y += this._parent.buffer;
      mc._x += this._parent.buffer;
      mc._y += this._parent.buffer;
      this._parent._xscale = this._parent._yscale=100;
      this._parent.gotoAndStop(1);
}
function buttonClick() {
      _loc1 = this._parent._parent._parent;
      //
      _loc1.createEmptyMovieClip("zoomMC12", 9999);
      _loc1.zoomMC12._x = 322;
      _loc1.zoomMC12._y = 222;
      trace("Click on button  "+this);
      zoomMC = _loc1.zoomMC12.createEmptyMovieClip("myTarget", 9999);
      trace(" import Project bigger image n = "+this._parent.i);
      zoomPicture = "netblue/zoom/"+String(_loc1.projects[this._parent.i])+".jpg";
      //After roll over status
      for (i=1; i<20; i++) {
            mc._alpha = 30;
      }
      ///////////////////////////////////////////////
      _loc1.mcLoader.loadClip(zoomPicture, zoomMC);
      _loc1.zoomMC12.onPress = function() {
            unloadMovie(this);
            unloadMovie(whiteOutBG);
      };
}
_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
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
Comment
Question by:mingchih
[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 Comments
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 18862688
I made changes in following function:

buttonOver()
buttonOut()
buttonClick()

------------
HERE is the FIXED CODE:
-------------
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);
            //mcLoader.loadClip(picture, eval("ScrollMovie.myTarget"+n));
            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
      mask_mc = _loc1.attachMovie("bg", "mask_mc", _loc.getNextHighestDepth());
      mask_mc._x = bg._x;
      mask_mc._y = bg._y;
      ScrollMovie.setMask(mask_mc);
      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 = ScrollMovie.attachMovie("button", "button"+i, 50+i);
            // Add the following to make rollOver works
            mc.btn.onRollOut = buttonOut;
            mc.btn.onRollOver = buttonOver;
            mc.btn.onRelease = buttonClick;
            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
}
// End of the function
function buttonOver()
{
      _loc1 = this._parent._parent;
      trace("which one is roll over now --  "+this._parent);
      this._parent.gotoAndStop(6);
      _loc1.myName = _loc1.projects[i];
      var mc = _loc1["myTarget"+this._parent.i];
      mc._xscale = mc._yscale=120;
      prev_width = this._parent._width;
      this._parent._xscale = this._parent._yscale=120;
      after_width = this._parent._width;
      this._parent.buffer = (after_width-prev_width)/2;
      this._parent._x -= this._parent.buffer;
      this._parent._y -= this._parent.buffer;
      mc._x -= this._parent.buffer;
      mc._y -= this._parent.buffer;
      mc.swapDepths(120);
      this._parent.swapDepths(121);
}
// End of the function
function buttonOut()
{
      _loc1 = this._parent._parent;
      var mc = _loc1["myTarget"+this._parent.i];
      mc._xscale = mc._yscale=100;
      this._parent._x += this._parent.buffer;
      this._parent._y += this._parent.buffer;
      mc._x += this._parent.buffer;
      mc._y += this._parent.buffer;
      this._parent._xscale = this._parent._yscale=100;
      this._parent.gotoAndStop(1);
}
function buttonClick()
{
      _loc1 = this._parent._parent._parent;
      //
      _loc1.createEmptyMovieClip("zoomMC12", 9999);
      _loc1.zoomMC12._x = 322;
      _loc1.zoomMC12._y = 222;
      trace("Click on button  "+this);
      zoomMC = _loc1.zoomMC12.createEmptyMovieClip("myTarget", 9999);
      trace(" import Project bigger image n = "+this._parent.i);
      zoomPicture = "netblue/zoom/"+String(_loc1.projects[this._parent.i])+".jpg";
      //After roll over status
      this._parent._parent["myTarget"+this._parent.i]._alpha = 30;
      _loc1.lastClicked = this;
      this.enabled = false;
      // this.onRollOut();
      ///////////////////////////////////////////////
      _loc1.mcLoader.loadClip(zoomPicture, zoomMC);
      _loc1.zoomMC12.onPress = function()
      {
            unloadMovie(this);
            unloadMovie(whiteOutBG);
            _loc1.lastClicked.enabled = true;
            _loc1.lastClicked.onRollOut();
      };
}
_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
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();
--------------

- Aneesh Chopra
0
 

Author Comment

by:mingchih
ID: 18862764
Hello, Aneesh

Thanks for the speedy reply :) It works prefect

Brian @ San Francisco
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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 select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

670 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