Copy link to clipboard
Copied
Hi,
I am completely new to Flas and AS3. I am trying to create an opacity slider using the slider component. I foudn a similar tutorial and tried to alter it to fit my opacity needs. In line 8 (function opacityChange (event:SliderEvent):void{) I get the error message 1046. When I test it in Flash the slider flickers on and off very rapidly too. Though I have searched, I am clueless as to what the problem is.
Any help will be appreciated.
Thanks!!
importfl.events.SliderEvent;
percent_txt.text = "Opacity %:0";
slider.value = 0;
slider.addEventListener(SliderEvent.CHANGE,opacityChange);
function opacityChange (event:SliderEvent):void{
percent_txt.text = "Opacity %: " + event.target.value;
logo.alpha = event.target.value;
}
that should be:
import fl.events.SliderEvent
(and you need a slider component in your library or you'll trigger and 1172 error:
1172: Definition fl.events:SliderEvent could not be found. |
Copy link to clipboard
Copied
that should be:
import fl.events.SliderEvent
(and you need a slider component in your library or you'll trigger and 1172 error:
1172: Definition fl.events:SliderEvent could not be found. |
Copy link to clipboard
Copied
Awesome. That was it. All the difference a space makes. Really appreciate your help!
Copy link to clipboard
Copied
Note that if you start typing SliderE... where you are using SliderEvent and press Ctrl-Space, Flash or Flash Builder (whichever you are using) will automatically add the import statement where it's needed, using correct syntax.
Copy link to clipboard
Copied
I am trying to duplicate the slider event for additional sliders and run into a 5000: The class ... must subclass 'flash.display.MovieClip'
Any advice? (I know I need to take a class)
And thanks again.
import fl.events.SliderEvent;
skinPercent_txt.text = "Opacity %:100";
skinSlider.value = 1;
skinSlider.addEventListener(SliderEvent.CHANGE,opacityChange);
function opacityChange (event:SliderEvent):void{
skinPercent_txt.text = "Opacity %: " + event.target.value*100;
skinLayer.alpha = event.target.value;
}
superfPercent_txt.text = "Opacity %:100";
superfSlider.value = 1;
superfSlider.addEventListener(SliderEvent.CHANGE,opacityChange);
function opacityChange (event:SliderEvent):void{
superfPercent_txt.text = "Opacity %: " + event.target.value*100;
superfLayer.alpha = event.target.value;
}
Copy link to clipboard
Copied
The error suggests the code is in a Class, but the code you posted looks like timeline code.
Often if there is an error somewhere, you'll get the above error for Classes that are not related to the error. Start with the error at the very top of the errors list. Usually getting rid of that one will get rid of the other errors like the one you posted.
Copy link to clipboard
Copied
you're welcome.