Copy link to clipboard
Copied
Hi!, sooo anyone knows how to change as3 from a class file to normal? (on stage not on a .as file)
This is the class file:
package
{
import flash.display.Sprite;
import fl.events.SliderEvent;
public class Main extends Sprite
{
public function Main():void
{
//Listen for slider movement
slider.addEventListener(SliderEvent.CHANGE, changeFPS);
}
private function changeFPS(e:SliderEvent):void
{
//Change the frame rate using the slider value
stage.frameRate = e.value;
}
}
}
Taken from this guy: (ALL RIGHTS OF HIM)
OK, you're being much too cryptic in your responses. Here's a small change to your original code, this may work better for you.
In this version the event listener is added without calling a function.
------------
import flash.display.Sprite;
import fl.events.SliderEvent;
slider.addEventListener(SliderEvent.CHANGE, changeFPS);
function changeFPS(e:SliderEvent):void
{
//Change the frame rate using the slider value
stage.frameRate = e.value;
}
--------------
Copy link to clipboard
Copied
I think this is what you're asking about.
----------
import flash.display.Sprite;
import fl.events.SliderEvent;
function Main():void
{
//Listen for slider movement
slider.addEventListener(SliderEvent.CHANGE, changeFPS);
}
function changeFPS(e:SliderEvent):void
{
//Change the frame rate using the slider value
stage.frameRate = e.value;
}
---------------
Essentially you need to remove the class definition and the enclosing curly braces. Then you need to remove any "public" or "private" declarations on the functions and/or variables.
Finally, you will need to call the initial function from somewhere.
Copy link to clipboard
Copied
Well no errors BUT it doesn't work, the slider doesn't change the frame rate on the go.
Copy link to clipboard
Copied
Do you call the function Main(); somewhere? If you did, try adding a trace command in the changeFPS() function to see if the function is ever called.
Copy link to clipboard
Copied
It´s just the code you transcribed. Never called the function.
Copy link to clipboard
Copied
So you called the function and it all works now?
Copy link to clipboard
Copied
Nope. mmmm maybe something's missing?
Copy link to clipboard
Copied
OK, you're being much too cryptic in your responses. Here's a small change to your original code, this may work better for you.
In this version the event listener is added without calling a function.
------------
import flash.display.Sprite;
import fl.events.SliderEvent;
slider.addEventListener(SliderEvent.CHANGE, changeFPS);
function changeFPS(e:SliderEvent):void
{
//Change the frame rate using the slider value
stage.frameRate = e.value;
}
--------------
Copy link to clipboard
Copied
Beautiful bro!! thanks so much Thanks for the contribution to music.
Copy link to clipboard
Copied
You're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now