problem error 1180, called to possibly undefined rectangle method

Explorer ,
Feb 01, 2021

Copy link to clipboard

Copied

Hi, I'm trying to adapt the code for a volume slider to work from a class. The code works perfectly from my action panel, but from the class it gives me that error.
I explain the code a bit

There is a volume symbol which is an mc and named for AS3 Volume. The class is from that symbol (Volume class).
That symbol contains two movieclips with instance names knob_mc and line_mc.
This is the tutorial I have used for the slider:

https://www.youtube.com/watch?v=qMotNC40pWw&list=PL1AjQxdF0PuY3KEfJhOYnPwrGv1GnjZBP&index=5&t=743s

 

this is the code

 

 

package  {
	
	import flash.display.MovieClip;
	import flash.media.SoundTransform;
	import flash.events.MouseEvent;
	import flash.events.Event;
	import flash.media.SoundChannel;
	
	
	public class Volume extends MovieClip {
		

		
		public function Volume(myChannel:SoundChannel) {
		var v = myChannel;
			
		function volume_drag(evt:MouseEvent):void
		{
		
			knob_mc.startDrag(false, new Rectangle(0,0,line_mc.width-knob_mc.width,0));//se atrastra en esos valores
		}
		function volume_dragStop(evt:MouseEvent):void
		{
			knob_mc.stopDrag();
		}
		function volume_set(evt:Event):void
		{
			
			var vol:Number = knob_mc.x /100;
			var st:SoundTransform = new SoundTransform(vol);
			v.soundTransform = st;//identifica el sonido
}

		knob_mc.addEventListener (MouseEvent.MOUSE_DOWN, volume_drag);
		knob_mc.addEventListener (MouseEvent.MOUSE_UP, volume_dragStop);
		knob_mc.addEventListener (MouseEvent.MOUSE_OUT, volume_dragStop);
		knob_mc.addEventListener (Event.ENTER_FRAME, volume_set);
		
		knob_mc.x = 40
			
		}
	}
	
}

It's the first class I adapt, so there are sure to be some mistakes. I appreciate the patience and the help. Thank you!!

Action Script 3.0 Tutorial - Volume High Low, Sound Play Pause. Learn the process of creating Action Script programming code to manipulate the Sound and its ...

Views

35

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Feb 01, 2021

Copy link to clipboard

Copied

Hi.

 

To fix this error alone, you need to import the Rectangle class. Like this:

import flash.geom.Rectangle;

 

Importing default classes is optional when coding in timelines but it is mandatory when using class files.

 

Regards,

JC 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
joaquin5EDD AUTHOR LATEST
Explorer ,
Feb 02, 2021

Copy link to clipboard

Copied

Obrigadissimo

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more