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!!
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
Copy link to clipboard
Copied
Obrigadissimo
Find more inspiration, events, and resources on the new Adobe Community
Explore Now