Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

class as3 to normal

New Here ,
Jan 14, 2016 Jan 14, 2016

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)

http://code.tutsplus.com/tutorials/quick-tip-change-the-frame-rate-at-runtime-using-actionscript-3--...

TOPICS
ActionScript
574
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 16, 2016 Jan 16, 2016

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;

        }

--------------

Translate
LEGEND ,
Jan 14, 2016 Jan 14, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2016 Jan 14, 2016

Well no errors BUT it doesn't work, the slider doesn't change the frame rate on the go.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 14, 2016 Jan 14, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2016 Jan 14, 2016

It´s just the code you transcribed. Never called the function.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 14, 2016 Jan 14, 2016

So you called the function and it all works now?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 15, 2016 Jan 15, 2016

Nope. mmmm maybe something's missing?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 16, 2016 Jan 16, 2016

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;

        }

--------------

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 16, 2016 Jan 16, 2016

Beautiful bro!! thanks so much Thanks for the contribution to music.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 16, 2016 Jan 16, 2016
LATEST

You're welcome.

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