Special text blocks. Macromedia Flash MX - first steps


Lecture materials, homework and tests
distance course “Electronic school Macromedia Flash MX”
Russian weekly methodological newspaper for computer science teachers. Publishing house "First of September" No. 42 (2003)
“An analogue of the “Rule” program from the “Hits of Robotland” package
in the Macromedia Flash environment."

Printed publications

ELECTRONIC SCHOOL MACROMEDIA FLASH MX
III course: Fundamentals of programming in Macromedia Flash MX
Module IV: The with Command. Program "Rule"
ActionScript language

Express module plan:
  • with command
  • Flash duplicate of the “Rule” program from the “Hits of Robotland” package.

with command

When using objects in program code (script), it is easy to notice that even in a small script block the name of the same object is repeated repeatedly. Such repetitions occur especially often when using some individual objects, for example objects Math, belonging to the upper level. For example, the following code is quite common:

A = Math.PI * r * r; x = r * Math.cos(Math.PI); y = r * Math.sin(Math.PI/2);

Here is the object Math occurs repeatedly, which makes the script difficult to understand. This entry can be greatly simplified if the script block is enclosed in parentheses using the with command. Then, within this script block, the ActionScript interpreter will access the specified object. Now the code can be rewritten as follows:

With (Math) ( a = PI * r * r; x = r * cos(PI); y = r * sin(PI/2); )

Let's take a look at the general command format:

with (object) (
statement(s);
}

object— an instance of an ActionScript object or Movie Clip.

statement(s)- a command or group of commands enclosed in curly braces.

Let's look at another example, in which the object is used MovieClip named someOtherMovieClip:

With (someOtherMovieClip) ( _x = 50; _y = 100; gotoAndStop(3); )

The following script excerpt shows how the previous example can be written without using the with command:

SomeOtherMovieClip._x = 50; someOtherMovieClip._y = 100; someOtherMovieClip.gotoAndStop(3);

It is possible to use nested with commands to access information in many contextual areas.

Flash duplicate of the “Pravilka” program from the “Hits of Robotland” package

When programming the buttons, we will actively use the branching operator: if and if else. We will also organize the operation of a counter that adds points to the user in case of a correct answer and subtracts points in the event that, without correcting an error or making incorrect corrections, the user presses the “Next” button.

We will organize the work of a Movie Clip (priz), in which the “Prize Fund” will be placed. If the user scores 10 points, his prize will be a basket of delicious fruits. If the user has 9 or 8 points as a prize, he will receive a piece of cheese, if the user is “lucky” to score 6 or 7 points, he will receive a pumpkin, but if he scores 5 or less than 5 points, he will get a tomato!

For those who like a five-point rating, let’s translate the above into a language accessible to the school magazine:

Fruit basket - 5 ;
Piece of cheese - 4 ;
Pumpkin - 3 ;
Tomato - 2 .

When accessing Movie Clip we will use the with command.

Our scene will use 11 frames. The first 10 frames will be “worksheets” on which phrases with grammatical errors (Input Text) will be placed. Usually the input fields are left blank, but in our case they should work! Each sheet will be programmed with a dynamic field. If the user does not correct the grammatical error, the text will be displayed: “You did not correct the error!”

This program uses two layers. The bottom layer is the background, it contains the static text “Program Correct” and a graphic symbol with a hat.

If you absolutely want to use some exotic font installed on your machine in the program to write the title, do not forget to use the Break Apart procedure from the Modify menu for this text. In other words, turn text into graphics. And then your text won’t turn into gobbledygook on a machine that doesn’t have this font!

Now everything is in order. Let's write a script for frame 1:

Stop(); fscommand("showmenu", "false"); i = 0;

When playing a video, you must disable the “Menu”. This way we will not allow the user to take a “step back”. And we also “turn on” the counter.
Let's write the action for frames 2-10:

Let's look at how the buttons work using the first frame as an example. You can program the remaining buttons yourself.

On (release) ( if (t1=="White Chrysanthemum") ( i++; gotoAndPlay(2); ) else ( i--; z1 = "You didn't fix the error!"; ) )

Now we will form the “Prize Fund”. Let's create new symbol type Movie Clip with name prize in which 5 frames will work. We will write a promotion for all frames of the clip:

The first frame of the clip will be blank.

In the second frame we will place a basket of fruits and give the frame a label: five.
In the third frame we will place a piece of cheese and assign a label to the frame: four.
Let's place a pumpkin in the fourth frame and assign a label to the frame: three.
Let's place a tomato in the fifth frame and assign a label to the frame: two.

In this program, all this “food variety” was imported from the ClipArt97 collection (wmf files). However, you can create your own “Prize Fund”, it all depends solely on your imagination.

Let's return to the stage and on the last 11th frame we will place the clip we created with prizes. Don't forget to spell it out on stage. Instance Name: prize. We will write a script to this frame that will, by analyzing the contents of the counter, “give” the user a prize:

Stop(); sh = i; with (_root.priz) ( if (i

Test the video. And if necessary, debug it.

To simplify the testing process, create a dynamic text field on the last frame with the name sh and display the counter data in this field. To do this, add the second line to the 11th frame script:

After completing the debugging process, delete this field and the line you entered.

Homework: Basics of programming in Macromedia Flash MX

Oh, how many wonderful discoveries we have
Prepare the spirit of enlightenment
And experience, the son of difficult mistakes,
And genius, friend of paradoxes,
And chance, God the inventor.
Alexander Sergeevich Pushkin, “Eugene Onegin”

Your task is to create a video duplicating the material presented in this lecture. You can choose the phrases yourself.

You can find the illustrative material used to form the “prize fund” of the video in the archive accompanying the lecture material. This archive contains files in wmf format. If this prize pool does not satisfy your requirements, feel free to get creative and use your own library.

Submit your completed assignment as a file in fla format (if the file size exceeds 150 KB, please archive the file) and send it to your teacher.

I wish you success in learning Macromedia Flash MX on your own!

Sections on this page:

Now let's talk about the so-called special text blocks, that is, about text blocks that perform special functions. At the moment, however, they will not be useful to us, but they will be needed when we start writing programs in the Flash environment (programming is dedicated to part IV this book).

Input fields

Entry field - This is a kind of small text editor placed in a Windows program window and designed for entering single or multi-line text. At the same time, Windows itself manages text input: we simply type characters, use the arrow keys, , , select the text, use the clipboard, as in any “big” text editor. Microsoft programmers have worked hard to make standard Windows input fields truly convenient.

To create an input field in Flash, you first need to place a regular text block on your worksheet and select it with the arrow tool (you don't have to enter any text into the text block). Next, find in the upper left corner of the panel Properties a small drop-down list (see Fig. 7.4) and select the item in it InputText. If after this we open the resulting text block, we will see what is shown in Fig. 7.9.


So what do we see? And we see a complete set of resizing markers (they will be saved even if we close the input field). This means that we can also change the vertical size of the resulting input field. And the rectangular marker from the upper right corner will move to the lower right - this is a sign that we have an input field in front of us.

Panel view Properties after selecting the input field is shown in Fig. 7.10. As we see, they appeared there additional elements controls that need to be considered.


First of all, right below the list that we just used, a field appeared in which we will need to specify a unique Name, identifying the Flash input field we created. Each input field created on a worksheet must have a unique name. This name can contain letters of the Russian and Latin alphabet, numbers and underscores, and it must begin with either a letter or an underscore.

Below the tracking task input field is another drop-down list. Use it to select the type of input field. There are four items available in this list:

? Single Line- regular single line input field;

? Multiline- multiline input field(in other words, the editing area);

? Multiline no wrap- a multi-line input field that will not automatically break a line (although the user can still break a line manually by pressing the key );

? Password- password entry field. Similar to a regular single-line input field, but hides the text entered into it, displaying a string of asterisks instead.

To the right of this list is a set of three switch buttons. The first of them is already familiar to us - it allows the user to select text in the input field:


As can be seen in Fig. 7.10, this button is pressed and disabled, i.e. it cannot be disabled.

The second switch button, when enabled, instructs Flash to process all HTML tags encountered in the text:


So, if we enclose a piece of text in a tag<В>.. , Flash will highlight it in bold. If this button is disabled, Flash displays the text "as is", along with any HTML tags that are specified there.

Generally speaking, this feature is only useful if we're specifying the contents of an input field from an ActionScript script, so it's described here ahead of time. Detailed support information HTML tags Input fields and dynamic text blocks can be found in the Flash online help.

The third toggle button, when enabled, causes Flash to show a border around the input field, making it resemble a standard Windows input field:


If it is disabled, the input field has a “flat” appearance.

If the input field we created is to be part of the original interface, it is best to leave this button disabled. If we want to make the input field more familiar to the user or more visible, we can enable this button.

To the right of these three buttons is an input field Var. This field specifies the name of the ActionScript variable into which the text entered into the input field we created will be placed. A variable is a kind of “storage cell” of data created in the computer’s memory and has a unique name by which it can be uniquely identified. We can refer to this variable by name, extract data from it, or put a new value into it. Variables will be discussed in detail in Chapter 19.

In the input field Maximum characters sets the maximum number of characters that the user can enter into it. If we do not want to limit this number, then we will enter the value 0 there (this, by the way, is the default value of the field).

Now let's return to the topic of implementing fonts, but in relation to input fields (more precisely, to all special text blocks). The thing is that in this case no embedding is performed - Flash only stores the names of the fonts used. When you play a finished image, Flash Player first looks for these fonts on the client's computer and, if present, uses them to display text. If a suitable font is not found, the player uses the closest similar font to the desired one, which may cause the image to be distorted. And this is not always acceptable.

But we can still force Flash to embed descriptions of selected characters of the font specified for a given input field into the resulting Shockwave/Flash file. Now we will see how this is done.

Selecting font characters to embed is done in the dialog box Character Embedding(Fig. 7.11). This window will appear on the screen after pressing the button Embed panels Properties(see Fig. 7.10).


The large list of this window will allow us to select entire groups of symbols that should be embedded in the resulting Shockwave/Flash file. It contains quite a few items; the same ones that are guaranteed to be useful to us are given below:

? All (39477 glyphs)- all characters of this font in the amount of 39,477. This item is provided for informational purposes only; in reality, hardly anyone will use it;

? Uppercase (27 glyphs)- capital Latin letters (27 characters);

? Lowercase (27 glyphs)- small Latin letters (also 27 characters);

? Numerals (11 glyphs)- Arabic numerals (11 characters);

?Punctuation [!@#$%…] (52 glyphs)- punctuation marks and special designations (52 characters);

?Basic Latin (95 glyphs)- letters of most European languages ​​(95 characters);

?Cyrillic (499 glyphs)- Cyrillic letters (499 characters). Perhaps the most important point in our case.

As a rule, several items are highlighted on this list at once (that’s right - who needs letters without numbers!). To do this, first click on the first item from the set of those that we want to select, then press the key and, holding it, click on the remaining items until we select everything. After this you can release the key .

Below the list of fonts there is an input field Include these characters. In it we can manually enter the characters that need to be embedded. This method is useful if we want to embed only certain characters in a font. And if we press the button Auto Fill, Flash itself will substitute in this input field all the characters that we used in the text of the selected input field.

At the very bottom of the window Character Options there is a small text field Total number of glyphs, showing how many characters we have already selected for embedding. So we can stop in time.

Button Don't Embed will allow you to quickly remove all the characters that we have chosen for implementation. When you click on it, the input field will be cleared Include these characters, and in a large list, the selection of the items we have selected will disappear.

By setting font embedding options in the dialog box Character Embedding, button should be pressed OK, to apply them. If you need to cancel these settings, click the button Cancel.

Dynamic text blocks

Often, instead of showing plain, unchanging text, you want to display the output of an ActionScript script in text form. For example, such a script could extract news from the Compulents website, a weather forecast from the Aporta website, and exchange rates from the Rambler website, add the current time to the extracted data, and display all this as text on the screen. (By the way, interesting idea...)

It is precisely for displaying text that is the result of the script that they are used. dynamic text blocks.(Regular text blocks are often called static.) Perhaps the need for such dynamic text blocks arises more often than for input fields.

A dynamic text block is created in much the same way as an input field. Create a regular text block, select it with the arrow tool and find it in the upper left corner of the panel Properties a small drop-down list (see Figure 7.4). You just need to select an item from this list Dynamic Text.

A selected dynamic text block is similar to an input field (see Fig. 7.9), and the panel Properties will look approximately the same as shown in Fig. 7.10. Therefore, we will not give a description of the controls contained in it, but will limit ourselves to pointing out the existing differences.

The same variables are used to display text in a dynamic text block. The ActionScript script places the output text in such a variable, and the Flash player performs the output. The name of this variable is entered into the same input field that is located under the list, with the help of which we just turned a regular text block into a dynamic one.

Now about the differences. There is actually only one difference in terms of interface and, in addition, it is already familiar to us. Switch button:


Including the ability to highlight and copy text placed in a dynamic text block is now available, and we can disable it if we wish.

The difference in terms of capabilities is that a dynamic text block can be made scrollable. An ordinary dynamic block must certainly have such dimensions that it can contain all its contents. For a scrollable block, this is not necessary: ​​similar to areas Windows editing, it can "scroll" the text it contains. To control scrolling, we will have to write appropriate ActionScript scripts - a scrollable text block does not contain scroll bars.

To make a dynamic text block scrollable, you must first select it. After this, you should turn on the switch Scrollable menu Text or the text block context menu item of the same name. If a text block is currently open, you can double-click the square handle located in the lower right corner of the selection rectangle while holding down . The finished scrollable text block is shown in Fig. 7.12; Note that the marker we clicked took the form of a black square.


Under the title "Macromedia Flash 8: a course for a young fighter", dedicated to this wonderful software product and Flash technologies. Starting today, the topics we talk about Flash will become more focused. Therefore, from now on I will omit the words “young fighter course” in the title. However, this circumstance will not at all affect the way the material is presented, the main goal of which is to answer many questions that novice flash designers have and give food for thought to experienced ones.

So, today on the agenda are the user interface components of Macromedia Flash Professional 8, as well as how to customize them.


Standard Flash 8 Components

The latest version of the powerful graphics package Macromedia Flash 8, in addition to a bunch of tools, methods and timeline effects designed to create high-quality animation, contains a full-fledged object-oriented programming language ActionScript 2.0 and numerous components (built-in program blocks like Movie).

Why do we need components at all? In many cases, they greatly simplify the process of developing an interactive application. Using data entry fields and various switches on websites, registration forms can be easily created, using loaders you can control the loading of text and multimedia data from various sources, etc. Today we will get acquainted with one of the component classes in Flash 8 - user interface elements (User Interface - UI).

The most popular object in Flash is, of course, the button. It is present in Flash both as a symbol type and as a UI element. The components RadioButton, CheckBox, MenuBar, etc. are used less frequently, but they are by no means less important. The components window is called up by pressing Ctrl+F8 or from the Window -> Components menu. See the table for the main UI components.

Component Description
Accordion Form navigator
Alert Text message
Button Simple button
CheckBox Checkbox
ComboBox Combo list
List List
Loader Loader container
RadioButton Selector switch
TextArea Text area
Window Container in the form of a window

Today, using the example of setting the parameters of a user interface element called Alert, we will look at the principles of working with component styles.


Presetting component properties

The Alert component allows you to organize a small dialogue between the user and the computer. Let's imagine something similar to the Alice talking program, created in the 60s and possessing a small artificial intelligence that made it possible to carry on a conversation with a person using his answers to previously asked questions.

First, let's change the labels on the buttons and write a handler for their clicks. Depending on which button the user clicked, a special message will appear. This is all achieved without using styles. So, let’s drag the Alert window onto a blank sheet from the Components panel and provide it with all the necessary settings. Let us remember that in any Flash fla file there is a library (called by pressing Ctrl+"L"), in which instances of components are stored. The Alert window also fits here. Since we don't want it to always hang around in the workspace, we can remove it from there (from the artboard, of course). Alert will remain in the library.

Now select the first frame on the timeline, go to the Actions section (F9) and write the following program code: “import mx.controls.Alert” (for more details, see the listing). Many of the required settings can only be set using ActionScript. The Alert window is called by the procedure Alert.show ("text", "window title", "buttons used", "window", "click handler", "selected button") with many parameters specified in parentheses. For the buttons used, “Alert.YES | Alert.NO” is indicated in single quotes (there are also “OK” and “Cancel” buttons), and for the event handler - the “buttonclick” function, which we will write a little later. Now let's change the labels on the "YES" and "NO" buttons using the Alert component properties "yesLabel" and "noLabel". Then set the required dimensions (“buttonWidth” and “buttonHeight”). To select the optimal parameters, it is useful to run the video for testing - "Enter" + Ctrl keys. The logic of the “buttonclick” function is as follows: when the “Wonderful” button is pressed, the message “Keep it up!” pops up, when “So-so” - “Keep your nose up!” For the changes to take effect, the description of this function and the settings of the Alert component must precede the call to the Alert.show procedure, as shown in the listing:

Import mx.controls.Alert; Alert.buttonWidth=150; Alert.buttonHeight=25; Alert.yesLabel="Wonderful"; Alert.noLabel="So-so..."; buttonclick = function(evt)(if (evt.detail == Alert.YES) (Alert.show("Keep it up!", "Macromedia Flash 8");) if (evt.detail == Alert.NO) (Alert .show("Keep your nose up!", "Macromedia Flash 8");)) Alert.show("What's up, buddy?", "Macromedia Flash 8", Alert.YES | Alert.NO, this, buttonclick, Alert .YES);

In a similar way, you can organize a more complex dialogue with the user.


Working with styles

What are styles used for? I'll explain now. Any component in Flash has a certain color scheme, font size, etc. But if you are developing, for example, your own website, then in order not to violate the integrity of the picture, you will have to “adjust” the components to the site. I think I won’t be mistaken if I say that every flash designer strives to create his videos in a special manner that is unique to him. With styles and themes in Flash 8, you can make each component unique. But let's not get carried away and focus on styles for now.

The formatting application programming interface (Styles API) provides the user with properties and methods that can be used to change the color of a component and format the text contained on it. Usually this is enough. Flash 8 ships with two styles with a set of parameters: "Halo" and "Sample", which are located in the files HaloTheme.fla and SampleTheme.fla, respectively. The figure shows their location in Windows 2000/XP. It should be noted that the “Sample” theme has many more properties, so it is more advisable to use it to modify components. And this is done as follows:

  1. The command File -> Import -> Open External Library is called and the file SampleTheme.fla is specified in the dialog box. Then, in the imported library panel, select Flash UI Components2 -> Themes -> MMDefault. Then from this window you need to drag the folder with the resources of the desired component (assets) into the symbol library window of the current document.
  2. Using the setStyle (parameter, value) and getStyle (parameter) methods, you can set or get the value of a particular parameter of the selected style.

Since we are working with the Alert component, we will drag the "Alert Assets" folder into the symbol library of our document. Then we will use the standard properties of the “Sample” theme (see listing).

Global.styles.Alert.setStyle("color", "red"); _global.styles.Alert.setStyle("themeColor", "haloBlue"); _global.styles.Alert.setStyle("backgroundColor", "0xE0C5FE"); _global.styles.Alert.setStyle("fontFamily", "times new novel"); _global.styles.Alert.setStyle("fontSize", "15");

The Alert dialog box's color is now purple (0xE0C5FE) and its text is now blue, with the font set to 15-point Times New Roman. It should be noted that the Alert symbol was modified in this way, so the changes will affect all its instances. A description of all Halo and Samlpe theme properties can be found in Flash 8 Help.


What if this is not enough for me?

If, even with styles, the appearance of the components does not meet your aesthetic requirements, then you can try writing your own theme. To do this, just edit or replace the shells of the necessary components in one of the standard themes. To do this, save the file HaloTheme.fla or SampleTheme.fla under a unique name, load it, go to the symbol library window (Window -> Library or Ctrl+L), select the required component and select the "Edit" option in the context menu. Some UI elements consist of many parts, so they can be easily transformed by redrawing or re-creating each part. Such components are Button, CheckBox, ComboBox, DataGrid, RadioButton, etc. Other shells are drawn programmatically. In this case, to change appearance component will need to modify the source code. This is, for example, the Alert component. Since creating a custom theme is a time-consuming process, we won't cover it in detail. At least for now. That's all.

The management set the task: it needs to be kept up to date Flash Player. Scale: ~15,000 computers, half of which actually need FP.

It would seem that what the problem is - we create a domain policy, push in the MSI package and rejoice... But that’s not the case! The company structure is highly distributed, i.e. In remote locations with a channel of ~1 Mbps on 20 computers, pushing even 15 Mb by politicians is already a problem - in the morning employees turn on the computer and wait half an hour for it to load until everything is downloaded and installed (or simply falls off due to a timeout). Not to mention the fact that computers in such offices have the unpleasant property of periodically falling out of the domain.

We needed another solution that would work regardless of policies, not strain the user in any way, and use the channel minimally (at least so that not everyone downloads at the same time). Options with scripts were also not suitable for obvious reasons.

Google came to the rescue, as usual: it turned out that you can install an internal update server and configure the built-in FP updater on it. In this case, you will only need to distribute the settings file to clients. Details under the cut.

Setting up an update server

1. We get license agreement

Adobe requires a license agreement to distribute its software. Let's not violate the terms of use and get a license (fortunately, it's not difficult at all): FlashPlayer: Adobe Runtimes / Reader Distribution License Agreement. The license is issued for a period of one year. After expiration, you can send the request again.

2. Raising the web server

The platform does not matter; in my case, I run the Nth site on IIS under Win2012. It consumes practically no resources even though ~3000 computers are already configured for this server.

Server settings:

  • Access via ports 80, 443 (http, https respectively).
    The first one is needed, in fact, for downloading, the second FP will go for the XML version of the current version.
  • Valid https certificate.
    I issued a certificate based on the corporate root one, which is present on all machines by default.
  • Directory listing.
    I didn’t check the work without it - the documentation asks, I decided to do it as written.
I won’t go into detail about setting up the server.

For clarity, let's call the server FlashPlayerUpdate.domain.local.

3. Download resources and upload them to the server

We create a directory tree in the root of the web server: /pub/flashplayer/update/current/sau/ .

Directory tree on my server:

If you requested a license in the first step, then in response you should receive a letter with a link from where to download FlashPlayer - follow this very link. If you haven’t received it or haven’t requested it, then go here: https://www.adobe.com/products/flashplayer/distribution3.html and download the archive from the link " Download Background Update Resources":

Extended Support Release or Public Release

A remark needs to be made here. There are 2 download options on the page: standard (Public) and Extended Support Release. In my case, stability is important and new features are not needed, so the ESR option was chosen. At the same time, I added a certain amount of hemorrhoids to myself: the public version can be directly downloaded by script from the Macromedia website. I still haven’t googled how to download ESR, so in my case the content on the internal server is updated in manual mode.

At the end of the article I have attached 2 PowerShell scripts: for automatic update(only for the standard version; easily ported to bash), to check for updates and notify by e-mail (for any version, including ESR).


Unpack the downloaded archive into the /pub/flashplayer/update/current/sau/ folder on the server.

4. Distributing the configuration file to clients

Depending on the system capacity:

  • 32-bit: C:\Windows\ System32\Macromed\Flash\mms.cfg
  • 64-bit: C:\Windows\ SysWOW64\Macromed\Flash\mms.cfg
You can distribute it in any way. I used a combination of domain policy and an antivirus administration server (for computers that left the domain).

In the file, we enable silent auto-update, specify the update interval (in days), the path to our server, and, just in case, logging to make it easier to diagnose problems if they arise:

AutoUpdateDisable=0 SilentAutoUpdateEnable=1 AutoUpdateInterval=2 SilentAutoUpdateServerDomain=FlashPlayerUpdate.domain.local SilentAutoUpdateVerboseLogging=1
If everything was done correctly, then Flash Player on client machines should start updating according to a schedule (according to the file above - once every 2 days). Typically, the Adobe update service runs once an hour to check the update conditions - at this time Updater should see the configuration file, reconfigure the updates according to the specified settings and go to new server check version.

That is, about an hour after distributing the configuration file, you can look at the logs on the server for requests to check the version.

Automation

As a classic representative of the IT fraternity, I hate routine manual work and simply could not help but automate the verification and downloading process new version. However, as noted above, I have not yet found a way to download ESR versions from the Macromedia website, so I only use the script to check for updates. Suggestions are welcome.
Script for automatically downloading updates
Only for public version!

Logic of operation: the script stupidly downloads update files directly from Macromedia for versions 11,15,16,17,18,19 (if some version has already been removed from the site, the script will simply swear that it could not download and will skip it) and puts it with replacement with an update server. No version checking. At the testing stage, I used this script: I ran it through the scheduler on the server at night.

If you wish, you can cross this script and the next one and get full automation with version checking, notifications and downloading only if there are updates.

Script parameters:

  • *FPRoot- path to the root folder of the update server. Local or network. Naturally, the user from whom the script will be launched must have write rights to this folder.
  • FPDownloadRoot- path on the Macromedia website. This is set by default, but can be changed if necessary.
  • DownloadProxy http:// proxy.domain.local.
  • ProxyCredits
  • UserAgent
  • Force
* - required parameter

Usage example:

Powershell.exe -command "& ".\FPUpdater.ps1" -FPRoot "\\FlashPlayerUpdate\pub\flashplayer\update\current\sau" -DownloadProxy "http://proxy.domain.local" -ProxyCreds "DOMAIN\UserName " -UserAgent "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko""
All parameters can be hardcoded into a script if long startup lines are intimidating.

Script for checking updates and notifying by e-mail
Updates are checked according to the standard version, but since they are updated at the same time (nobody canceled the security fixes), it will also work for ESR. For the script to work, you need to create a CurrentPublic file in the root of the web server (next to the pub folder), in which you enter the current public version for ActiveX(it is the ActiveX version that is used for checking).

Operating logic: the script compares the version obtained from the CurrentPublic file from your server with the version on the Macromedia server. It looks at the version on the server according to the logic of the auto-update: first it looks for the current major build in XML, goes to the folder with the major one and looks at the full build there.

Script parameters:

  • *FPIntServerRoot- Our server address. For example: FlashPlayerUpdate.domain.local
  • FPDownloadRoot- path on the macromedia website. This is set by default, but can be changed if necessary.
  • ESR- check the ESR version (without this flag it will check the public one).
  • DownloadProxy- proxy server, if used in a company. Write in full: http:// proxy.domain.local.
  • ProxyCredits- username for authorization on the proxy.
  • UserAgent- to change the user agent with which PowerShell will download. For example, our proxy is limited by UserAgents, I use the Internet Explorer agent.
  • Force- disable certificate checking for the Invoke-Webrequest cmdlet (more precisely, make it trust all certificates).
  • *MailTo- e-mail addresses to which notifications will be sent.
  • *MailFrom- from whom notifications will come. For example: [email protected]
  • SmtpServer- smtp server through which the message will be sent.
* - required parameter

Usage example:

.\FPCheckUpdate.ps1 -FPIntServerRoot "fp-update.domain.local" -ESR -Proxy "http://proxy.domain.local" -UserAgent InternetExplorer -Force -MailTo " [email protected]","[email protected]"-MailFrom" [email protected]" -SmtpServer "smtp.company.com"

Resources used

UPD

Slightly belated update from 06/17/16.

Since this article was written, Adobe has managed to change the order of access to the FlashPlayer download page twice. As a result, now in order to access the download page, you must first log in to Adobe ID. That is, the option of parsing the page for the ESR version is no longer available rolls.

I haven’t bothered with authorization or receiving and sending cookies via PowerShell yet. As a result, I remade the script for checking ESR on the distribution3 page, which can disappear at any moment. So far so, we will see further.

At the beginning of the year, I asked a question on the Adobe forum on the topic of checking for updates to the ESR version. They promise to come up with something, but so far the problem is still there.

UPD2

The other day, the following information appeared on the Flash Player distribution page (the link to which you received when you received a distribution license):

ATTENTION! Important changes with Extended Support Release

The Extended Support Release was originally designed to minimize the time IT administrators spend certifying each new release of Flash Player: The Extended Support Release limited release changes to security changes and fixes for critical functional issues. At that time, there were many more functional changes in each release of Flash Player than there were security changes. However, the situation has now changed: the number of proactive and reactive security measures far outweighs functional changes. In practice, the Extended Support Release no longer protects IT organizations from huge amount changes made to standard releases of Flash Player, but only reduces functional risks. In this regard, the decision was made to discontinue the Extended Support Release and concentrate on developing only standard releases. Add tags

The last article was devoted to animation. We created animation based on motion tweening, shape tweening, and simply composing movement from individual frames. I think it's time to move on to a more advanced topic, looking at the tool that creates the basis for most quality Flash movies.

This tool is ActionScript, an event-driven language built into Flash. Latest version ActionScript (which is present in Flash 5) is significantly different from ActionScript, which was in Flash 4. If in the previous version it was a limited set of commands, allowing only basic actions, and entered using a not very user-friendly interface, then the new ActionScript is a powerful language, with an increased set of commands, support for classes, inheritance (!), and much more convenient interface.

ActionScript makes your pages interactive. You can react to events from the mouse or keyboard, and you can perform any actions when playing a certain frame.

In order to fully master ActionScript, it is advisable to already have programming experience (preferably in C++, JavaScript, etc.). However, one of the benefits of the Flash language is that you don't need to be a Flash pro, or fully familiar with ActionScript, to write quality code in it. You can use those language features that you deem necessary for your work.

Since this article is about the basics of the language, in it we will cover:

  • The Actions panel is where almost all communication with ActionScript occurs.
  • Buttons - how to make them work as we require.
  • Paths - how to access the necessary objects?
  • Basic actions with Flash cartoons (movie clips) - we will control the process of playing the movie as we please.
  • Debugging in ActionScript - Output and Debugger windows.

The purpose of this article is to give you a feel for ActionScript, to show that this language can be used both for creating very impressive programs and for performing basic actions that will make your page much more attractive.

Terms

Before we get into specific actions, a few ActionScript terms:

  • Actions- these are instructions that tell the Flash cartoon what to do. From them comes the name of the language - ActionScript (literally - action script). Let's agree that within the framework of this article, we will use the term “instructions” so as not to be confused with the actual actions that we will perform.
  • Events- these are the actions that occur when the cartoon is played. Events, for example, can occur when loading of a certain frame ends, when we reach a certain frame, when the user presses a key on the keyboard or the mouse cursor is over our object.
  • Expressions is any part of an instruction that produces a value. The following examples are expressions: 2 + 2, 2 * 2, a + b, 2*pi*r, (15 + k) * random(10).
  • Functions is a block of code that can be reused. You can pass values ​​to a function and receive a return result from it. For example, number = get_color(15, 24). 15 and 24 are arguments (or parameters) to the get_color function, the return value of which is written to the number variable.
  • Classes are types of objects. For example, the tree class is plant. Flash has a number of predefined classes (much like JavaScript classes). You can create your own classes or modify existing ones.
  • Instances are literally instances of certain classes. For example, a plant instance may be a tree, bush, or flower. An instance is already a specific real object. If a class is a definition of an object (instance), then an instance is already a concrete embodiment, it is a class in action. Each instance can be given a name so that functions or variables of the object can be accessed through it.
  • Handlers are special instructions that process events. For example onClipEvent- a handler for actions associated with a specific symbol (see).
  • Operators are language elements that calculate values ​​based on one or more arguments. For example, the addition operator (+) returns the sum of the two values ​​to the left and right of it.
  • Variables are identifiers that can store values. For example, a = 5; or name = "Michael".

These are the terms we'll use when discussing ActionScript. So…

Actions Panel

The action bar is used to display and enter ActionScript programs (Fig. 1). There are two modes of operation with the panel - normal (for dummies) and expert. In expert mode, the list of commands is a simple text input field. In normal mode, we cannot directly edit commands. To do this, use the options panel.

You can add an instruction by clicking on the “+” button (see Fig. 1) or by selecting the appropriate instruction in the list of language elements. In addition, for all actions in Flash there are key sequences that can be used to do this much faster. They are shown to the right of each action in the "+" button menu. For example, to add a function stop(), you need to press Esc+st (sequentially: Esc, then “s”, then “t”).

You can delete an instruction by selecting it and pressing the “-” button (or simply the Delete key).

I recommend that you do not immediately start using expert mode if you do not have experience programming in Java-like languages ​​(C++, Java, JavaScript). The normal mode has a great advantage that makes it indispensable for beginners - there is much less chance of making mistakes with the syntax of the language. This will help beginners quickly understand the intricacies of ActionScript.


Rice. 1 - Action bar

The action panel displays the actions of the object or frame currently selected.

Buttons

The first thing you want when you start learning Flash interactivity is to make something that would respond to user actions, to “revive” your creation, to add feedback. The easiest way to do this is with buttons. Therefore, we will start with them.

As you know, in Flash there is a special type of symbol for creating buttons - Button (see). Let's assume that you have already learned how to create buttons, now let's learn how to track clicks on these buttons.

Buttons in Macromedia Flash have an extensive list of events that we can respond to:

  • press- the mouse button is pressed when the cursor is within the button;
  • release- the mouse button is released when the cursor is within the button;
  • releaseOutside- the mouse button is released when the cursor is outside the button;
  • rollOver- the mouse cursor enters the button;
  • rollOut- the cursor goes beyond the button;
  • dragOver- the cursor enters the limits of the button, while the button was pressed and the mouse key was pressed;
  • dragOut- the cursor goes beyond the button, while the button was pressed and the mouse key was pressed;
  • keyPress("key") - a "key" was pressed. You can view a list of keys in the Flash help (Key object), or use the options bar to enter the desired key.

Unfortunately, Flash only "understands" the left mouse button. The right one is used to call the context menu (right-click on some Flash cartoon). I haven’t yet come across any ways to catch the middle key or mouse wheel in Flash; I don’t think they exist.

These events are intercepted using the directive on(). Its syntax is:

On (event) (... // Our actions)

Below you can try to trigger some events yourself:

A very commonly used example is following a link when a button is clicked:

On (release) ( getURL("http://rubs.boom.ru"); )

To test this scenario, highlight your button, press Ctrl+Alt+A and enter the program.

This is how you can easily intercept all events associated with a button. Well, how to use them is entirely a matter of your imagination.

Basic steps with Movie Clips

A huge amount of creativity in Flash comes from symbol manipulation. Almost all basic techniques, all tricks and effects are impossible without these actions.

With ActionScript, you can do almost anything you want with characters. You just need to remember that these actions can only be performed either in response to a user action, or when a certain frame occurs on the timeline.

So what do we have? I will list only the main (in my opinion) tools. The rest you will find in the list of language elements or in the help.

Movie clip functions that can be called:

  • play() - starts or resumes playback of a clip;
  • stop() - stops clip playback;
  • gotoAndPlay() - goes to a certain frame (scene) and continues playback;
  • gotoAndStop() - goes to a specific frame (scene) and stops playback.

Properties (parameters) of clips that can be read/changed:

  • _x, _y - clip coordinates (in pixels);
  • _xscale, _yscale - clip scale (in percentage), horizontally and vertically, respectively;
  • _width, _height - width and height of the clip (in pixels);
  • _rotation - angle of rotation of the clip (in degrees);
  • _alpha - transparency of the clip (in percent);
  • _visible - visibility.

This is not all that can be done with clips. Use other parameters, experiment, get creative!

Names

In order to access clips, we need to understand the concept of an object name (instance name) and a path to an object (target path). Let's agree that the movie clip and the object are the same things for us.

The object name is the name of a specific symbol instance. Let’s say we can have a symbol - a car, and instances of this symbol will be called “Machine1”, “Machine2”, “Pickup”, “Zaporozhets”...

In order to give a name to an object, you need to select the object, and in the Instance panel (Window->Panels->Instance, Ctrl+I) in the Name column, enter the name of the object (Fig. 2). Names can only consist of letters, numbers, and the underscore character ("_"), and the name cannot begin with a number.


Rice. 2 - Instance panel

Paths

The path to an object is a record of the object's name, taking into account the hierarchy. I'll try to explain what it is.

You know that in Flash, objects can be nested within each other, thus forming a hierarchy. So, this nesting not only provides convenience in handling objects, it also limits the visibility of object names. Visibility is limited to its level. An object can directly (by name) only access objects within it that are one level lower in the hierarchy.

In order to access an object at another level, you need to know the path to it. Moreover, the path can be specified either absolutely (from the very top level of the hierarchy) or relatively (from the current level).

The path includes objects through which we need to “pass” along the hierarchy tree to get to the object we need, listed through a dot. Additionally, there are several pointers (we might call them "virtual objects") that are often very useful:

this - a pointer to “itself” (that is, to the current object). It may be needed, for example, when you need to pass a pointer to the object from which this function is called to a function.

_parent - pointer to the "parent". Points to an object at a higher level in the hierarchy.

_root - "root". This is the beginning of the hierarchy. You can't do without it when specifying an absolute path.

The path looks like this:

leaf.play();- at the subobject leaf(leaf) function called play();

_parent.tree.leaf.stop();- it is assumed that there is an object at one level tree, which has an object leaf, from which the function is called stop();

_root.banner._visible = false;- make a clip banner, located on the 1st level, invisible.



Rice. 3 - Hierarchy of clips

For illustration, let’s take a hierarchy of 5 objects (Fig. 3). Objects 1-4 are on the 1st layer, object 5 is on the 2nd layer. Object 2 is nested in object 1, and object 3 is nested in object 2. The objects in the picture are visually nested within each other, but this in no way means that this should be the case “in real life”. Here they are grouped for clarity. Since the name of an object cannot begin with a number, let our objects be called obj1-obj5.

Now let's deal with the paths. First, let's look at which objects can refer to each other by name. obj1 can contact obj2, A obj2- To obj3, but at the same time obj1 can't contact obj3 directly, because it is not contained in obj1, and in obj2.

Let's say the first object needs object 3 to start playing again from the 1st frame. Here's how it's done:

Obj2.obj3.gotoAndPlay(1);

In order for the 4th object to make the 1st object (note with all subobjects!) semi-transparent, it needs to write the following in its script:

Parent.obj1._alpha = 50;

Root.obj1._alpha = 50;

Because obj4 is at the first level of the hierarchy, then for it _root And _parent- same.

Now for object 3 we will write a script that will make object 5 invisible when the mouse button is pressed. In the script for object 3 we write:

OnClipEvent (mouseDown) ( _root.obj5._visible = false; )

In this snippet we have used an absolute path. If we used relative it would look like:

Parent._parent._parent.obj5._visible = false;

I hope I cleared up the path issue.

The examples above showed not only what paths look like, but also how functions are called and property values ​​are assigned.

Publications on the topic