Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Kỹ thuật lập trình
Essential ActionScript 3.0 PHẦN 5
Đang chuẩn bị liên kết để tải về tài liệu:
Essential ActionScript 3.0 PHẦN 5
Kiều Mỹ
65
94
pdf
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Example 17-5. The ShelteredClass class (continued) return null; } } } Now let’s look at Caller, a class that wishes to access ShelteredClass’s restricted methods and variables. Having already seen the authorizedClasses array in ShelteredClass, we know that Caller is a legal class. In our example, Caller is also the main application class, so it extends Sprite. The Caller class creates an instance of ShelteredClass in its constructor method and assigns that instance to the variable shelteredObject. package { import flash.display.*; public class Caller extends Sprite { private var shelteredObject:ShelteredClass; public function Caller ( ) { shelteredObject = new ShelteredClass( ); } }. | Example 17-5. The ShelteredClass class continued return null _ _ Now let s look at Caller a class that wishes to access ShelteredClass s restricted methods and variables. Having already seen the authorizedClasses array in ShelteredClass we know that Caller is a legal class. In our example Caller is also the main application class so it extends Sprite. The Caller class creates an instance of ShelteredClass in its constructor method and assigns that instance to the variable shelteredObject. package import flash.display. public class Caller extends Sprite private var shelteredObject ShelteredClass public function Caller shelteredObject new ShelteredClass _ _ To invoke secretMethod on ShelteredClass a Caller object must first retrieve a reference to the restricted namespace. To do so the Caller object passes itself to getRestrictedNamespace and assigns the result either restricted or null to a variable key for later use. var key Namespace shelteredObject.getRestrictedNamespace this Then before calling secretMethod Caller first checks whether key refers to a valid namespace. If it does then Caller uses key as the namespace when invoking secureMethod if key null shelteredObject.key secureMethod For convenience our Caller class wraps the code that calls secretMethod in a method named callSecretMethod public function callSecretMethod void var key Namespace shelteredObject.getRestrictedNamespace this if key null shelteredObject.key secretMethod _ Example 17-6 shows the entire code for the Caller class including callSecretMethod and another convenience method displaySecret which accesses the restricted variable secretData using the same basic technique. Applied Namespace Examples 345 Example 17-6. The Caller class package import flash.display. public class Caller extends Sprite private var shelteredObject ShelteredClass public function Caller shelteredObject new ShelteredClass callSecretMethod displaySecret public function callSecretMethod void var key Namespace .
TÀI LIỆU LIÊN QUAN
Essential ActionScript 3.0 PHẦN 1
Essential ActionScript 3.0 PHẦN 2
Essential ActionScript 3.0 PHẦN 3
Essential ActionScript 3.0 PHẦN 4
Essential ActionScript 3.0 PHẦN 5
Essential ActionScript 3.0 PHẦN 6
Essential ActionScript 3.0 PHẦN 7
Essential ActionScript 3.0 PHẦN 8
Essential ActionScript 3.0 PHẦN 9
Essential ActionScript 3.0 PHẦN 10
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.