Loading and Communicating with Inline Images and SWFs
Số trang: 11
Loại file: pdf
Dung lượng: 28.42 KB
Lượt xem: 11
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Tải và Giao tiếp với Inline Hình ảnh và văn bản file SWF gì không thể được spruced dựng và tăng cường với một giật gân của nội dung đồ họa ở dạng một hình ảnh, hoặc thậm chí một bộ phim Flash? Mặc dù việc đặt văn bản và nội dung đồ họa với nhau là chắc chắn có thể với phiên bản trước của Flash
Nội dung trích xuất từ tài liệu:
Loading and Communicating with Inline Images and SWFs < Day Day Up >Loading and Communicating with Inline Images and SWFsWhat text cant be spruced up and enhanced with a splash of graphical content in the formof an image, or even a Flash movie? Although placing text and graphical content togetherwas certainly possible with previous versions of Flash, there wasnt a way of embeddingan image or Flash movie within the text so that text flowed around it. Flash MX 2004changes all that with built-in support of the HTML image tag () within text fields.When a text field has been set to accept and interpret HTML, using the tagembeds the specified graphic at the location you choose within the text. Lets look at asimple example:var myText:String = Hello! Do you like this picture of my doggie?;This script creates a string using some simple HTML tags. The next step is to render thisHTML snippet in a text field, which is done with the following bit of code:myTextField_txt.htmlText = myText;This line sets the htmlText property of the myTextField_txt text field to the string thatwas just created. As a result, the text field displays the text, formatted as shown, andloads the specified JPG image between the first bit of text and the last.For a text field to have the capability to render HTML loaded into it, its html propertymust be set to true. This can be accomplished by selecting the text field in the authoringenvironment and clicking the Render Text as HTML button on the Property Inspector, orvia ActionScript:myTextField_txt.html = trueNOTECurrently, Flash can load only non-progressive JPG images. Progressive JPGs, GIFs, andPNGs are not supported.If you thought loading a JPG was great, it gets even better because Flash can also loadSWFs into a text field in the same way, using the tag. Look at this revisedexample:var myText:String = Hello! Do you like this picture of my doggie?;myTextField_txt.htmlText = myText;NOTEFor an SWF to render properly in the tag, its registration point must be at 0,0.This has an effect similar to that of the previously discussed script, except that the revisedHTML string loads myDogMovie.swf. You can interact with this movie just as if you hadviewed it separately.TIPThe tag can also be used to embed movie clips from the library. Simply referencethe clips identifier name in the src attributeBut it gets even better! Notice within the tag the use of an attribute named id. Thisattribute provides an instance name to the loaded SWF, enabling other elements withinyour movie to communicate with that loaded SWF. Its full target path is the name of thetext field into which its loaded, followed by its ID/instance name:myTextField_txt.myDogMovie_mcOther supported attributes of the tag include width, height, hspace, vspace, andalign.NOTEThe align attribute only supports a left or right value. The default value is left.In the following exercise, youll begin scripting a Flash-based HTML browser. Thebrowser has the capability to load external HTML pages, and display images and SWFswithin those pages. Youll also create a simple media player that plays SWFs embeddedwithin the HTML. Finally, youll use the MenuBar component to add a menu bar at thetop of the application window. 1. Open flashBrowser1.fla in the Lesson14/Assets folder. This project contains six layers—Background, Media Player, MenuBar, Titlebar, Content Window, and Actions. Our projects static graphics are on the Background layer. There are two button instances on the Media Player menu, named play1_btn and stop1_btn. These are used as playback controls for SWFs loaded in using the tag. The MenuBar layer contains an instance of the MenuBar component named mainMenu. This menu will contain two menu buttons: File and Style. The File menu allows users to select HTML pages to open; the Style menu allows them to select a style for the various text elements in the loaded HTML page (the latter functionality is explored more in the next lesson). The Titlebar layer contains a graphical bar that spans the top of the application. This is for design purposes only. The Content Window layer contains a text field instance named window_txt. This field acts as our browsers main window. HTML content (including embedded images and SWFs) is loaded into this field. As always, the Actions layer will contain all the script for this project. This project uses several external files that have already been created. Before we begin scripting, lets review those files and what they contain.2. Using your operating systems directory-exploring application, navigate to the Lesson14/Assets directory and locate the following files: o home.htm o science.htm o header_home.jpg o header_science.jpg o morning.swf o galaxy.swf The first two files on this list are the HTML files that the project will open. The home.htm file contains tags that embed the header_home.jpg and morning.swf files; the science.htm file embeds the two remaining files. To help you get a sense of the structure of one of these HTML files, lets open it.3. Using your favorite HTML editor, open home.htm. As you can see, this is a simple document. Unlike most HTML documents,however, it begins and ends with a tag. Within the tag, severalother tags are used, most of which are explained in the next exercise. The only tagwere concerned with for now is the tag, which is used twice in thisdocument. The first use of this tag appears at the top of the document:This embeds header_home.jpg at the top of the page. The next use of the tag lookslike this:This line embeds the morning.swf movie. Be aware that weve given this SWF anid of media1_mc. This plays ...
Nội dung trích xuất từ tài liệu:
Loading and Communicating with Inline Images and SWFs < Day Day Up >Loading and Communicating with Inline Images and SWFsWhat text cant be spruced up and enhanced with a splash of graphical content in the formof an image, or even a Flash movie? Although placing text and graphical content togetherwas certainly possible with previous versions of Flash, there wasnt a way of embeddingan image or Flash movie within the text so that text flowed around it. Flash MX 2004changes all that with built-in support of the HTML image tag () within text fields.When a text field has been set to accept and interpret HTML, using the tagembeds the specified graphic at the location you choose within the text. Lets look at asimple example:var myText:String = Hello! Do you like this picture of my doggie?;This script creates a string using some simple HTML tags. The next step is to render thisHTML snippet in a text field, which is done with the following bit of code:myTextField_txt.htmlText = myText;This line sets the htmlText property of the myTextField_txt text field to the string thatwas just created. As a result, the text field displays the text, formatted as shown, andloads the specified JPG image between the first bit of text and the last.For a text field to have the capability to render HTML loaded into it, its html propertymust be set to true. This can be accomplished by selecting the text field in the authoringenvironment and clicking the Render Text as HTML button on the Property Inspector, orvia ActionScript:myTextField_txt.html = trueNOTECurrently, Flash can load only non-progressive JPG images. Progressive JPGs, GIFs, andPNGs are not supported.If you thought loading a JPG was great, it gets even better because Flash can also loadSWFs into a text field in the same way, using the tag. Look at this revisedexample:var myText:String = Hello! Do you like this picture of my doggie?;myTextField_txt.htmlText = myText;NOTEFor an SWF to render properly in the tag, its registration point must be at 0,0.This has an effect similar to that of the previously discussed script, except that the revisedHTML string loads myDogMovie.swf. You can interact with this movie just as if you hadviewed it separately.TIPThe tag can also be used to embed movie clips from the library. Simply referencethe clips identifier name in the src attributeBut it gets even better! Notice within the tag the use of an attribute named id. Thisattribute provides an instance name to the loaded SWF, enabling other elements withinyour movie to communicate with that loaded SWF. Its full target path is the name of thetext field into which its loaded, followed by its ID/instance name:myTextField_txt.myDogMovie_mcOther supported attributes of the tag include width, height, hspace, vspace, andalign.NOTEThe align attribute only supports a left or right value. The default value is left.In the following exercise, youll begin scripting a Flash-based HTML browser. Thebrowser has the capability to load external HTML pages, and display images and SWFswithin those pages. Youll also create a simple media player that plays SWFs embeddedwithin the HTML. Finally, youll use the MenuBar component to add a menu bar at thetop of the application window. 1. Open flashBrowser1.fla in the Lesson14/Assets folder. This project contains six layers—Background, Media Player, MenuBar, Titlebar, Content Window, and Actions. Our projects static graphics are on the Background layer. There are two button instances on the Media Player menu, named play1_btn and stop1_btn. These are used as playback controls for SWFs loaded in using the tag. The MenuBar layer contains an instance of the MenuBar component named mainMenu. This menu will contain two menu buttons: File and Style. The File menu allows users to select HTML pages to open; the Style menu allows them to select a style for the various text elements in the loaded HTML page (the latter functionality is explored more in the next lesson). The Titlebar layer contains a graphical bar that spans the top of the application. This is for design purposes only. The Content Window layer contains a text field instance named window_txt. This field acts as our browsers main window. HTML content (including embedded images and SWFs) is loaded into this field. As always, the Actions layer will contain all the script for this project. This project uses several external files that have already been created. Before we begin scripting, lets review those files and what they contain.2. Using your operating systems directory-exploring application, navigate to the Lesson14/Assets directory and locate the following files: o home.htm o science.htm o header_home.jpg o header_science.jpg o morning.swf o galaxy.swf The first two files on this list are the HTML files that the project will open. The home.htm file contains tags that embed the header_home.jpg and morning.swf files; the science.htm file embeds the two remaining files. To help you get a sense of the structure of one of these HTML files, lets open it.3. Using your favorite HTML editor, open home.htm. As you can see, this is a simple document. Unlike most HTML documents,however, it begins and ends with a tag. Within the tag, severalother tags are used, most of which are explained in the next exercise. The only tagwere concerned with for now is the tag, which is used twice in thisdocument. The first use of this tag appears at the top of the document:This embeds header_home.jpg at the top of the page. The next use of the tag lookslike this:This line embeds the morning.swf movie. Be aware that weve given this SWF anid of media1_mc. This plays ...
Tìm kiếm theo từ khóa liên quan:
máy tính mạng máy tính internet phần mềm ứng dụng lập trình SQL HTML sever web XMLTài liệu có liên quan:
-
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 2
102 trang 299 0 0 -
Giáo án Tin học lớp 9 (Trọn bộ cả năm)
149 trang 299 0 0 -
Bài giảng: Lịch sử phát triển hệ thống mạng
118 trang 283 0 0 -
Ngân hàng câu hỏi trắc nghiệm môn mạng máy tính
99 trang 280 1 0 -
47 trang 250 4 0
-
Đề cương chi tiết học phần Thiết kế và cài đặt mạng
3 trang 247 0 0 -
80 trang 239 0 0
-
6 trang 230 0 0
-
Giáo trình môn học/mô đun: Mạng máy tính (Ngành/nghề: Quản trị mạng máy tính) - Phần 1
68 trang 227 0 0 -
122 trang 223 0 0