Jump to content
Search Community

Do not know how to detect loaded image from "button" instance.---RESOLVED---

UbiAssassin test
Moderator Tag

Recommended Posts

Ok after a bit more work I have everything working except for one thing.

 

I am using this function to try and find the image that was loaded into child level 1 of the thumbnail (Level 0 = backplate, level 1 = randomly loaded thumbnail, level 2 = mouse detection plates). Once found it is compared to all 6 image variables. Itis supposed to be = to one and then fire off the correct link:

 

public function findTheImage(e:MouseEvent):void
{
trace("Check for ImageA");
var currentScreenImageOnA:DisplayObject = ScreenButtonA.getChildAt(1);
trace(currentScreenImageOnA);
if (currentScreenImageOnA == screenImageA)
{
navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_A.png"));
}
if (currentScreenImageOnA == screenImageB)
{
navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_B.png"));
}
if (currentScreenImageOnA == screenImageC)
{
navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_C.png"));
}
if (currentScreenImageOnA == screenImageD)
{
navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_D.png"));
}
if (currentScreenImageOnA == screenImageE)
{
navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_E.png"));
}
if (currentScreenImageOnA == screenImageF)
{
navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_F.png"));
}
}

 

This is my attempt to find what the random image placed into this thumbnail plate is, compare it to all six possibilities, and then link the correct larger version of the image. Sadly my code does not throw any errors, but it also does not do anything. I know that the if statements work, because they have compared and detected the correct image in previous setups where other things did not work. I assume I have done something wrong with the "var currentScreenImageOnA:DisplayObject = ScreenButtonA.getChildAt(1);" which is meant to examine the thumbnail instance on the stage "ScreenButtonA" and get the image on level 1 of this thumbplate to compare to all of the image possibilities.

 

Has anyone else tried anything like this and maybe have some advice on what I am missing? Thanks!

Link to comment
Share on other sites

Hi UbiAssassin,

 

I appreciate the time you took to explain all this. Unfortunately, I really can't wrap my head around it all. This seems like a fairly complex programming conundrum that goes a bit beyond the LoaderMax API. I don't know really what I can offer as far as working this problem out.

 

Perhaps the solution will be more clear to other's in this forum.

 

for one of your concerns:

 

2. I have to have some clever way of detecting which image is loaded on each new thumbPlate instance so when I click on it, it loads the correct large version of the image.

 

 

Each ImageLoader's ContentDisplay object (the sprite that holds the loaded asset) has a loader property which references the ImageLoader that loaded it's image. Perhaps when you click on your image you can figure out which ImageLoader loaded it, and then get some info regarding which large image to load by assesing the url, name or other properties

 

http://www.greensock...entDisplay.html

Link to comment
Share on other sites

Cool, thank you for the quick reply. I do have both class files and the test movie that I could send to you if you want to see all of it together? Sadly my explanations of what is going on are probably quite limiting. My main problem is that I don't have the best way to load images onto my thumbPlates. If I try and run that PickFromArray function without the shuffle, it will only load an image onto one instance called to the stage and spit null errors for the other instances called. I am just not as clear on array usage as I should be >.<. I would also rather keep these class files separate so that I can use the ScreenButtonScript class in multiple movies.

Link to comment
Share on other sites

After some toying I found my answer!!!

 

public function findTheImage(e:MouseEvent):void
 {
  trace("Check for ImageA");
  var currentScreenImageOnA:DisplayObject = ScreenButtonA.getChildAt(1);
  trace(currentScreenImageOnA.name);
  trace(screenImageA);
  trace(screenImageB);
  trace(screenImageC);
  trace(screenImageD);
  trace(screenImageE);
  trace(screenImageF);
  if (currentScreenImageOnA.name == "AssassImageSA")
  {
   navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_A.png"));
  }
  if (currentScreenImageOnA.name == "AssassImageSB")
  {
   navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_B.png"));
  }
  if (currentScreenImageOnA.name == "AssassImageSC")
  {
   navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_C.png"));
  }
  if (currentScreenImageOnA.name == "AssassImageSD")
  {
   navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_D.png"));
  }
  if (currentScreenImageOnA.name == "AssassImageSE")
  {
   navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_E.png"));
  }
  if (currentScreenImageOnA.name == "AssassImageSF")
  {
   navigateToURL(new URLRequest("http://levelforge.com/images/WebsiteFlash10/AssassinsCreedIII_F.png"));
  }
 }

 

So after running some traces to see what was actually showing up for comparison, I decided to compare the name strings and voila!!! I get the exact large image link perfectly on every instance comparison. Woohoo!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...