Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / July 2008



Tip: Looking for answers? Try searching our database.

onRelease function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BobMelnyk - 31 Jul 2008 17:48 GMT
I have set up a number of loader objects and set up locations of the images I
want to load and link urls I want assigned to each image using loops like this:

  for (var j = 1; j<url_XML.firstChild.childNodes.length/2+1; j++) {
    images[j]=this.createClassObject(mx.controls.Loader, "myLoader"+j, j);
    images[j].scaleContent = false;
  }
 
  for (var i=0; i<url_XML.firstChild.childNodes.length; i++) {
        if (i < url_XML.firstChild.childNodes.length/2) {
         urls[i] = url_XML.firstChild.childNodes[i].childNodes;
         }
        else {
          links[i-(url_XML.firstChild.childNodes.length/2)] =
url_XML.firstChild.childNodes[i].childNodes;
          }
    }

This worked great, and then I used a loop to assign each image to the page
like this:
 
  for (var i=0; i<urls.length; i++) {
  images[i+1].contentPath = urls[i];
  images[i+1]._x = i*320;
  images[i+1]._y = 0;
  }

This also worked great, but when I used the following loop to set up a link
url for each image, the link does not work:

  for (k=0; k<links.length; k++) {
  images[k+1].onRelease = function() {
  getUrl(links[k]);}  
  }
}

When I just used this it worked fine for the one function:
var k = 0;
images[k+1].onRelease = function() {
  getUrl(links[k]);}

But I can not get the loop to work so I actually create all functions.  Any
ideas what I'm doing wrong and what I can do to make it work?  Thanks for any
help!

Bob
kglad - 31 Jul 2008 23:12 GMT
use the attach code option to display code in this forum.

and when images[k+1] is released, it doesn't know it has any relationship to
the value that k has when your onRelease is defined.  assign a property of
images[k+1] to store the value of k and use that property in you onRelease
handler.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.