Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    705
    Thanks
    8
    Thanked 17 Times in 16 Posts

    Seperate AS file in zip.

    Hey guys, I am wondering why is there a seperate as file in a zip I downloaded?

    There are the files slider.as and slider.fla.

    There is only one frame in the fla file and I was wondering if I can combine the fla and as file to make it work, since I will be combining it with another file.

    This is the Slider.as file:
    Code:
    package {
    	import flash.display.MovieClip;
    	import flash.events.MouseEvent;
    	
    	public class Slider extends MovieClip {
    		public static var SLIDE_ALIGN_LEFT:int = 1;
    		public static var SLIDE_ALIGN_RIGHT:int = 2;
    		public static var SLIDE_ALIGN_CENTER:int = 3;
    		
    		private var mSlideOffset:Number;
    		private var mSlidebarOffsetLeft:Number;
    		private var mSlidebarOffsetRight:Number;
    		private var mSlidebarEffectiveWidth:Number;
    		private var mSlidebarEffectiveX:Number;
    		
    		public function Slider():void {
    			slide.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    			addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    			addEventListener(MouseEvent.MOUSE_OUT, mouseUpHandler);
    			slidebar.addEventListener(MouseEvent.CLICK, mouseMoveHandler);
    			
    			// Assume alignment of left.
    			mSlideOffset = 0;
    			
    			// Initialize the slidebar assuming no offsets.
    			mSlidebarOffsetLeft = 0;
    			mSlidebarOffsetRight = 0;
    			updateSlidebarEffectiveValues();
    		}
    		
    		public function get value():Number { 
    			return (slide.x-mSlidebarEffectiveX+mSlideOffset)/mSlidebarEffectiveWidth;
    		}
    		
    		public function set value(n:Number):void { 
    			slide.x = mSlidebarEffectiveWidth * n - mSlideOffset + mSlidebarEffectiveX;
    		}
    		
    		public function set slideAlign(alignment:int):void { 
    			if(alignment == SLIDE_ALIGN_RIGHT)
    				mSlideOffset = slide.width;
    			else if(alignment == SLIDE_ALIGN_CENTER)
    				mSlideOffset = slide.width/2;
    			else
    				mSlideOffset = 0;
    		}
    		
    		public function set slidebarOffset(offset:Number):void { 
    			mSlidebarOffsetLeft = offset; 
    			mSlidebarOffsetRight = offset;
    			updateSlidebarEffectiveValues();
    		}
    		
    		public function set slidebarOffsetLeft(offset:Number):void { 
    			mSlidebarOffsetLeft = offset; 
    			updateSlidebarEffectiveValues();
    		}
    		
    		public function set slidebarOffsetRight(offset:Number):void { 
    			mSlidebarOffsetRight = offset; 
    			updateSlidebarEffectiveValues();
    		}
    		
    		private function updateSlidebarEffectiveValues():void {
    			mSlidebarEffectiveWidth = slidebar.width-mSlidebarOffsetRight-mSlidebarOffsetLeft;
    			mSlidebarEffectiveX = slidebar.x+mSlidebarOffsetLeft;
    		}
    		
    		private function mouseDownHandler(event:MouseEvent):void {
    			addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
    		}
    		
    		private function mouseUpHandler(event:MouseEvent):void {
    			trace(event);
    			if(event.relatedObject != this && event.relatedObject != slide && event.relatedObject != slidebar)
    				removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
    		}
    		
    		private function mouseMoveHandler(event:MouseEvent):void {
    			if(slidebar.mouseX < mSlidebarOffsetLeft)
    				slide.x = slidebar.x+mSlidebarOffsetLeft-mSlideOffset;
    			else if(slidebar.mouseX > slidebar.width-mSlidebarOffsetRight)
    				slide.x = slidebar.x+slidebar.width-mSlidebarOffsetRight-mSlideOffset;
    			else
    				slide.x = this.mouseX - mSlideOffset;
    		}
    	}
    }
    When I try to copy that code, and paste it into the first frame of the Slider.fla to the action script its giving me an error that it cant be nested.

    This is the fla file: http://uppit.com/v/AMTTEXHM


    If someone can combine it to make it work off of one file named slider.fla would be great.
    MY MSN: Sith717@Hotmail.com
    PHP, HTML, and CSS Coding, Logo and Web Design - Professionally done.
    PM me anytime for HTML, PHP or web design help. I will be glad to help you out.

  • #2
    New to the CF scene
    Join Date
    Feb 2010
    Location
    Guildford,UK
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Basically the seperate .as file is a class associated with the slider object in the library. To fix this simply put the .as in the same folder and test the movie. If you're worried about the stuff that apears on the bottom then don't. It means everything is working well(there are "trace" thingys in the class).


  •  

    Posting Permissions

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