dcsimg
A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: [CS3] AS2 - Confused! Getting simple arrows to scroll xml content

  1. #1
    Member
    Join Date
    Jul 2001
    Location
    USA
    Posts
    78

    [CS3] AS2 - Confused! Getting simple arrows to scroll xml content

    I found a tutorial online for an xml/flash gallery. I've got it working with a scrollbar but i want to be able to scroll through the images with an up arrow & down arrow instead. I've taken a stab at the code but can't get it working. I've left the original script in just for reference purposes but am stumped as to how to get this function with just arrows. I've tried removing the dragger but nothing happens??? I've attached the files for reference. If anyone can help me out I'd really appreciate it.

    P.S - I can't post the image folder as it's too large.

    Code:
    /////////////////////////////////////////////////////////////////////
    Stage.scaleMode = "noscale";
    
    /////////////////
    // Loading XML //
    /////////////////
    myXML = new XML();
    myXML.ignoreWhite = true;
    myXML.load("portfolio.xml");
    myXML.onLoad = function(_status) {
    	if (_status) {
    		tempxml = myXML.firstChild.childNodes;
    		var path1 = myXML.firstChild.attributes.path1;
    		var path2 = myXML.firstChild.attributes.path2;
    
    		var space = 25; // Space between items you can increase this to whatever
    		for (var i = 0; i<tempxml.length; i++) {
    			
    			var item = list_mc.attachMovie("clip", "clip"+i, i); // In the library, rightclick on item and choose linkage. You'll see that our items are represented in the code the "clip" name
    			
    			item._y = (item._height+space)*i; // This places our items on y axis
    			item.title_txt.text = tempxml[i].attributes.title; // For i<total, attaches a title i to our item
    			//item.date_txt.text = tempxml[i].attributes.date; // For i<total, attaches a title i to our item
    			item.descr_txt.text = tempxml[i].attributes.description; // This attaches a description i to our item
    			//item.url_txt.text = tempxml[i].attributes.url; // And this one a url i to our item
    			
    			//item.thumbHolder.loadMovie(tempxml[i].firstChild); // Attaches thumbnails to each item
    			item.thumbHolder.loadMovie(path1 + tempxml[i].firstChild); // Attaches bw thumbnails to each item
    			item.thumbHolderC.loadMovie(path2 + tempxml[i].firstChild); // Attaches color thumbnails to each item
    			
    			item.onRollOver = function() {
    				this.alphaTo(100, 2.0, "easeOutExpo");
    				this.thumbHolder._visible = false;
    			};
    			
    			item.onRollOut = function() {
    				this.alphaTo(100, 2.0, "easeOutExpo");
    				this.thumbHolder._visible = true;
    			};
    			//item.btn.id = i;
    			//item._alpha=75; // Sets an alpha = 50 to our items. This can be increased or decreased. It serves for the fade in/fade out effect
    			//item.onRollOver = function() {
    			//	this.alphaTo(100, 1, "easeOutExpo"); // When I rollOver each item, alpha goes smoothly to 100
    			//};
    			//item.onRollOut = function() {
    			//	this.alphaTo(75, 1, "easeOutExpo"); // When I rollOut alpha goes back to 50 as it was. This value should be the same with the one above
    			//};
    			//item.onRelease = function()   {
    			//	item.btn.getURL(this.url_txt.text,"_blank"); // When I click on an item, it opens an url (wich I set in the xml for each button) in a blank window of my browser
    		//	};
    		}
    		
    		delete myXML;
    	}
    };
    ////////////////////////////
    // Setting the Arrows //
    ////////////////////////////
    _root.uparrow_mc.onRollOver = function (){
    	this.alphaTo(100, 1, "easeInExpo"); // The color code from here makes our dragger white. Change this to modify color
    }
    
    _root.downarrow_mc.onRollOver = function (){
    	this.alphaTo(100, 1, "easeInExpo"); // The color code from here makes our dragger white. Change this to modify color
    }
    
    _root.downarrow_mc.onRollOut = function (){
    	this.alphaTo(10, 1, "easeOutExpo"); // The color code makes our dragger grey as it is in fact. This should be the same as dragger's color as shape ;)
    }
    
    _root.uparrow_mc.onRollOut = function (){
    	this.alphaTo(10, 1, "easeOutExpo"); // The color code makes our dragger grey as it is in fact. This should be the same as dragger's color as shape ;)
    }
    
    _root.uparrow_mc.onPress = function(){
      this.onEnterFrame = function(){
        target_mc._y -= 1;
      }
    }
    
    _root.uparrow_mc.onRelease = function(){
      delete this.onEnterFrame;
    }
    
    _root.uparrow_mc.onPress = function(){
      this.onEnterFrame = function(){
        target_mc._y += 1;
      }
    }
    
    _root.uparrow_mc.onRelease = function(){
      delete this.onEnterFrame;
    }
    ////////////////////////////
    // Setting our scroll bar //
    // We'll call it dragger ///
    ////////////////////////////
    targY = 50;
    abstandDragger = -195; // If you resize the items, or whatever you'll have to modify this value in order to have your dragger in the right x position
    dragger._x = mask_mc._width+abstandDragger;
    
    dragger.onPress = function() {
    	startDrag(this, false, this._x, 0, this._x, mask_mc._height-this._height); // Doesn't allow our dragger to get out of some coordinates
    };
    
    dragger.onRelease = dragger.onReleaseOutside=function () {
    	stopDrag(); // Stops the mouse drag action
    };
    
    list_mc.setMask(mask_mc);
    list_mc.onEnterFrame = function() {
    	scrollAmount = (this._height-mask_mc._height)/(mask_mc._height-dragger._height);
    	targY = -dragger._y*scrollAmount;
    	this._y -= (this._y-targY)/10; // Scroll delay - Ease. Change this value to experiment
    };
    
    /////////////////////////////////////
    // Setting the mouse wheel support //
    /////////////////////////////////////
    var dragger:Object = new Object();
    dragger.onMouseWheel = function(delta) {
    	if(this._y >= 3)
    	{
        this._y -= delta;
    	}else{
    		this._y = 3;
    	}
    	if(this._y <= mask_mc._height-this._height)
    	{
    		this._y -= delta;
    		}else{
    			this._y = (mask_mc._height-this._height);
    }
    }
    Mouse.addListener(dragger);
    
    /////////
    // End //
    /////////
    Attached Files Attached Files
    Thanks!
    Leah5569

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center