Why is it better to use classes in AS3

I do not like external files. Most developers prefer this and claim it is better. Explain why it's best to use classes in ActionScript 3.0.

My ActionScripts are different. I remove the classes and paste them into the Flash IDE. 9 out of 10 times works great. My question is Socrates, but I really feel ignorant about this because there is less code for what I'm trying to do. Enjoy it.

Here's a tutorial that I reviewed - “Keyboard Output Testing Example”

//AFTER
//remove curly brackets and "outer shell of class definitions"
//remove class function "don't need it"
//function at bottom, remove "public", make sure it has a body {}
var _time_scale:Number = .25; 
var _frames_elapsed:int = 0; 
var _clip:MovieClip; 

function handleEnterFrame(e:Event):void { 
_frames_elapsed++; 
_clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale)); 
}

//BEFORE
package { 
    import flash.display.MovieClip; 
    import flash.display.Sprite; 
    import flash.events.Event; 

    public class Main extends Sprite { 

        private var _time_scale:Number = .25; 
        private var _frames_elapsed:int = 0; 
        private var _clip:MovieClip; 

        public function Main():void { 
            _clip = new SomeClip; 
            addEventListener(Event.ENTER_FRAME, handleEnterFrame); 
        } 

        private function handleEnterFrame(e:Event):void { 
            _frames_elapsed++; 
            // we multiply the "real" time with our timescale to get the scaled time 
            // we also need to make sure we give an integer as a parameter, so we use Math.round() to round the value off 
            _clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale)); 
        } 

    } 
}

There can be no answer, but there must be a definite explanation that makes sense.

+3
source share
5 answers

2 :

1) , Flash IDE (CS4)? -, Flash IDE . , .

-, , .

-, ( , ?), .

2) ? - . -, . , , : http://www.alagad.com/blog/post.cfm/what-does-object-oriented-programming-do-for-me

+1

, . , - / , , . ActionScript . / , ..

, , .

+1

. +1

, -. CamelCase , under_score? , , . varA , thisVariableThatShallDescribeTheLetterA, , .

, . , , , , . , AS , , , , .

0
  • .
  • Object Orientated. , #, Java, Objective-C, AS3 - .
  • OO , (), , .
  • , IDE .

. , , - . 40

0

: " ". , , .

- , 50 ( , ).

1) - :

  • . , , . Flash-, .
  • /: , , , , .

2) , Flash . , , - .

3) -, , . .

, , flash, , .

, , - (FLA) , . , FLA Movie Clips . / _time_scale, , , FLA. , 10 . , , , FLA.

, 90% , , . 10% - - , - - , navigateToURL (getURL)... ..

0
source

Source: https://habr.com/ru/post/1731266/


All Articles