In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Flex and Flex swf how to achieve communication, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Flex communication series-Flex and Flex swf
This is about nesting a Flex swf in FlexApplication, and then realizing the communication between Flex and Flex swf. We need to introduce the SystemManager interface implementation.
Let's take a look at the description of SystemManager in the Flex3 reference Manual. You'll probably know what's going on. You can use the ready-made properties and methods in it to communicate between Flex and Flex swf.
Each application contains a SystemManager. If the size of the application window changes (you cannot change its size in the application, you can only change it by interacting with the operating system window or browser), SystemManager sends an event. It is the parent of all displayable items in the application, such as the primary instance of mx.core.Application and all pop-up windows, tooltips, cursors, and so on. Any object parented with SystemManager will be treated as a "* *" window, even tooltips and cursors.
Yes, to implement Flex calls to nested Flex swf, the main thing we need to do is to open the door to Flex in Flex swf, that is, to design a publicfunction. Isn't that easy enough? Let's talk about a simple implementation:
1. Load the Flex swf file through the Flex swfLoader tag in FlexApplication (such as Main.mxml):
Viewplaincopytoclipboardprint?
2. Design a publicfunction in Game01.mxml. Such as:
Viewplaincopytoclipboardprint? PublicfunctioninvokeByOutsideFlex (): void {trace ("Success...");} publicfunctioninvokeByOutsideFlex (): void {trace ("Success...");}
3. Call in Main.mxml:
Viewplaincopytoclipboardprint?
Object (Object (Flex swfLoader.content) .application) .invokeByOutsideFlex ()
/ / in fact, the second Object is actually a SystemManager object, so you can also write
Object (SystemManager (Flex swfLoader.content) .application) .invokeByOutsideFlex ()
Object (Object (Flex swfLoader.content) .application) .invokeByOutsideFlex ()
/ / in fact, the second Object is actually a SystemManager object, so you can also write
Object (SystemManager (Flex swfLoader.content) .application) .invokeByOutsideFlex ()
Let's first look at two things, one of which is the content property of Flex swfLoader, and the other is Application.application.
◆ Flex swfLoader-content
Content attribute
Content:DisplayObject []
This property contains objects that represent the content loaded in the Flex swfLoader control.
Application-application
Obviously, the public method under the FlexApplication level can be obtained with such a simple two sentences.
Well, it is now possible to communicate from Flex to Flex swf. So how can Flex swf talk to FLEX in turn? The principle is the same: Flex opens up some function, and then Flex swf can call those function directly.
4. If you add to Main.mxml:
Viewplaincopytoclipboardprint? PublicfunctioninvokeByInsideFlex swf (): void {trace ("Igetit...");} publicfunctioninvokeByInsideFlex swf (): void {trace ("Igetit...");}
5. If you go back to Game01.mxml, you can call it directly through the following code:
Viewplaincopytoclipboardprint? Object (SystemManager (this.parent.parent.root) .application). InvokeByInsideFlex swf (); / SystemManager can be changed to Object, polymorphic characteristic Object (SystemManager (this.parent.parent.root) .application). InvokeByInsideFlex swf (); / / SystemManager can be changed to Object, polymorphic property
Next we need to look at two properties:
◆ UIComponent:
This level I find out through the Debug object layer by layer, different levels of course need to be changed, or even directly jump to a few layers, directly to the outermost layer, this myself to check, hehe.
Source code download: ready to upload
Parent attribute
Parent:DisplayObjectContainer []
The parent container or component of this component. Only UIComponent objects should have parent attributes. Non-UIComponent objects should use other properties to refer to the objects to which they belong. In general, non-UIComponent objects use the owner property to reference the object to which they belong.
◆ DisplayObject:
Root attribute
Root:DisplayObject []
For display objects in a loaded Flex swf file, the root property is the * display object in the display list tree structure section represented by the Flex swf file. For bitmap objects that represent loaded image files, the root property is the bitmap object itself. For * instances of the main class of the loaded Flex swf file, the root property is to display the object itself. The root property of the Stage object is the Stage object itself. For any display object that is not added to the display list, the root property is set to null unless it has been added to a display object container that is not in the display list but belongs to a child of the * display object in the loaded Flex swf file.
Application attribute
Application:Object []
A reference to the application.
In general, Application objects may have a hierarchy because Application can use the Flex swfLoader control to dynamically load other Application. The child Application where the UIComponent is located can be accessed through the parentApplication property of the UIComponent, and you can browse up to the Application in the hierarchy.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.