Hide Old and Reveal New Script

I was talking the other day with a friend about a small challenge, having 2 images on stage with 2 ideas. 1- have the experience being user driven (in this case the mouse reveals one image while hiding the other) 2- Use XML for easy update. So we fired flash and the above is the visual and the code below...

ActionScript:
  1. var xmlLoader:XML = new XML();
  2. var firstItem:String;
  3. var secondItem:String;
  4.  
  5. xmlLoader.ignoreWhite = true;
  6. xmlLoader.onLoad = function ( success )
  7.  
  8. {
  9.    
  10.    var base    = xmlLoader.firstChild;
  11.    firstItem    = base.firstChild.firstChild.firstChild
  12.    secondItem    = base.firstChild.firstChild.nextSibling.firstChild
  13.    firstItem    = "images/" + firstItem.toString();
  14.    secondItem    = "images/" + secondItem.toString();
  15.    setImages();
  16.  
  17. }
  18.  
  19. xmlLoader.load("xml/revealer.xml");
  20.  
  21. Mouse.addListener(this);
  22.  
  23. onMouseMove = function()
  24.  
  25. {
  26.  
  27.    mask1_mc._x = _root._xmouse;
  28.  
  29. }
  30.  
  31. function setImages()
  32.  
  33. {
  34.  
  35.    var mcl1:MovieClipLoader = new MovieClipLoader();
  36.    mcl1.addListener(this);
  37.    mcl1.loadClip(firstItem, image1_mc);
  38.    
  39.    var mcl2:MovieClipLoader = new MovieClipLoader();
  40.    mcl2.addListener(this);
  41.    mcl2.loadClip(secondItem, image2_mc);
  42.  
  43. }
  44.  
  45. mask1_mc._x = 212;

One Response to “Hide Old and Reveal New Script”

  1. Gadgets » Hide Old and Reveal New Script Says:
    September 21st, 2007 at 4:30 pm

    <p>[...] Helmut wrote an interesting post today!.Here’s a quick excerptI was talking the other day with a friend about a small challenge, having 2 images on stage with 2 ideas. 1- have the experience being user driven (in this case the mouse reveals one image while hiding the other) 2- Use XML for easy … [...]</p>

Leave a Reply