[Original] flex control of flash components

2010-02-24  来源:本站原创  分类:Flash  人气:236 

Recent agreement with the background of the hessian, communication technology and interface has been basically almost started fighting the enemy with the prospects of cooperation.

Front of the flash device to be able to make it more convenient to use in flex in my general idea is this. More "dead" things made of pictures, with some methods, relatively active components made. Swf, and then flex in use as3 to control, this is more convenient and easier to change and modify.

First of all flash devices in production, properties, methods ah ah these names to communicate well.

There are two in the flex in use:

The first method is used with the as3 directly through the loader loads. Swf, and then show to the program. There are small tips, flash to do something directly addchild to flex containers will force the type conversion occurs, but with one exception, is the UIComponent, reason can see flex class diagram of the inheritance.

The second method is to use SWFLoader load, if the less I am inclined to such components as lazy, easier layout. . .

I only had a demo control properties, methods, Kazakhstan is also no problem, the code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationPolicy="all" creationComplete="init()">
        <mx:Script>
                <![CDATA[
                import mx.core.UIComponent;
                        private var swfurl:String=" My cash  .swf";
                        // Create an instance of the Loader class
                        private var context:LoaderContext=new LoaderContext();
                        private var loader:Loader=new Loader();
                        private var myUI:UIComponent = new UIComponent();
                        private var something:Object;
                        private function init():void
                        {
                                this.addChild(myUI);
                                context.applicationDomain=ApplicationDomain.currentDomain;
                                // Load external SWF library   loader.load() The 2nd parameter    Used to determine whether you can use the loaded SWF's library
                                loader.load(new URLRequest(swfurl), context);
                                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
                        }
                        private function onComplete(e:Event):void
                        {
                                trace(loader);
                                something = loader.content;
                                something.myCash.text = 3000;
                                myUI.x = 300;
                                myUI.y = 300;
                                myUI.addChild(loader);
                        }
                        private function cc():void
                        {
                                var ss:Object = mm.content;
                                ss.myCash.text =50000;
                        }
                        private function addMoney():void
                        {
                                var ss:Object = mm.content;
                                ss.myCash.text = int(ss.myCash.text) + 10000;
                        }
                ]]>
        </mx:Script>
        <mx:SWFLoader source=" My cash  .swf" creationComplete="cc()">

        </mx:SWFLoader>
        <mx:Button x="273" y="10" label="+10000" click="addMoney()"/>
</mx:Application>

Further, by the flash to provide a class library, which can have multiple components, to repeat the use of resources:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                                creationComplete="init()"
                                layout="absolute">
        <mx:Script>
                <![CDATA[
                        import mx.core.UIComponent;
                        import flash.display.Loader;
                        import flash.display.Sprite;
                        import flash.net.URLRequest;
                        import flash.events.Event;
                        //
                        import flash.system.ApplicationDomain;
                        import flash.utils.getDefinitionByName;
                        import flash.display.MovieClip;
                        import flash.system.LoaderContext;
                        /**
                         * ...
                         * @author  Qi Qi beast
                         * QQ:649723623
                         *
                         *  Implementation library reuse
                         */
                        // The address of the library resources
                        private var myUI:UIComponent = new UIComponent();
                        private var swfurl:String="element.swf";
                        // Create an instance of the Loader class
                        private var context:LoaderContext=new LoaderContext();

                        private var loader:Loader=new Loader(); 

                        public function init():void
                        {
                                // Specifies the domain for the current period
                                this.addChild(myUI);
                                context.applicationDomain=ApplicationDomain.currentDomain;
                                // Load external SWF library   loader.load() The 2nd parameter    Used to determine whether you can use the loaded SWF's library
                                loader.load(new URLRequest(swfurl), context);
                                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
                        }

                        private function onComplete(e:Event):void
                        {
                                // Get the class definition      MCExample  aaaa
                                var className:Class=ApplicationDomain.currentDomain.getDefinition("aaaa") as Class;
                                // Export resources from the library
                                var mc:MovieClip=new className();
                                // In the middle of the scene
                                mc.x=275;
                                mc.y=200;
                                // Added to the display list
                                myUI.addChild(mc);
                        }
                ]]>
        </mx:Script>
</mx:Application>

Annex is the first Demo of the flash components can be placed in src directory

相关文章
  • [Original] flex control of flash components 2010-02-24

    Recent agreement with the background of the hessian, communication technology and interface has been basically almost started fighting the enemy with the prospects of cooperation. Front of the flash device to be able to make it more convenient to use

  • Flex Shared Object flash cookie 2010-10-03

    Flex Shared Object flash cookie Flash cookie Is not the first time I heard? everyone is familiar cookie is stored in the browser directory of a text file, the maximum amount of information is 4K. Flash cookie similar to the function of the browser co

  • Flex3 Component Explorer Flex examples of various components 2010-11-14

    Flex3 Component Explorer Flex examples of various components http://examples.adobe.com/flex3/componentexplorer/explorer.html

  • Flex Control session method (transfer) 2010-12-26

    Flex Control session method 1, an increase in the web.xml <filter> <filter-name> AMFContextFilter </ filter-name> <filter-class> soft.flex.context.AMFContextFilter </ filter-class> </ Filter> <filter-mapping> <

  • Flex之理解Flash中的事件机制 2014-01-11

    上次测试中当我们点击"发送"按钮时,flex就会与后台中定义的Java方法交互并将结果返回给flex并呈现在前台页面,其实这靠的就是事件.事件贯穿在Flex中的所有过程中,如果没有事件,那么就谈不上什么人机交互. Flash的ActionScript语言支持事件编程.在ActionScript中,每个事件都由一个事件对象表示.事件对象是flash.events.Event类或其某个子类的实例.事件对象不但存贮有关特定事件的信息,还包含便于操作事件对象的方法.事件对象有如下两个用途: ●

  • flex and flash components interact 2010-01-22

    Some time ago made a flex and JavaScript, data exchange, and now to learn if the interaction with the flash <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout=&quo

  • [Original] Flex + Struts2 File Download Control 2010-05-01

    <?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" width="334" height="140" fontSize="12" title=" File down

  • Good open source components flex control 2010-11-14

    http://code.google.com/p/flexlib/wiki/ComponentList

  • [Original] flex dynamic link library and static link library 2010-03-23

    flex could have two libraries, one is a dynamic link library (RSL), one is a static link library. We usually use the swc is a static link library, compile time will be compiled directly into the need to things, included in the generated swf in. swc f

  • flex game engine (PushBotton) - components and implementation of the framework 2010-07-12

    Flow Of Execution An important part of understanding PushButton Engine is understanding what is run when. While most of the behavior described in this chapter is completely automated, it is helpful background information when you are developing or de

  • flex control object. RemoteObject and others have a common method addEventListener. 2010-10-29

    addEventListener as follows: public function addEventListener (type: String, listener: Function, useCapture: Boolean = false, priority: int = 0, useWeakReference: Boolean = false): void { eventDispatcher.addEventListener (type, listener, useCapture,

  • [Original] Flex simple and practical instrument panel controls 2010-11-20

    [Note: This article is http://www.smithfox.com/?e=33 original, reprinted, please indicate the original, thank you] On the Internet for a very simple dashboard controls Flex http://www.betterthanflex.com/app/gaugeexplorer/Main.html But some questions,

  • FLEX layout of the components of the size of the set (change) 2010-04-14

    Component size (size) refers to the height and width of the component. View Flex Help Flex components can be seen on the size of the property there are many, to width, for example, the width of the following attributes: * Width * MaxWidth * MinWidth

  • Flash Components style set comes with component methods (text style / appearance style) 2010-04-18

    Ide own recent use of many components, each component basically need to set about style. Here, to sum up the style for some of the ways to set components. Components have (inherited) a setStyle (style: String, value: Object): void method. First: Set

  • Open source projects: a map of China Flash Components 2010-05-03

    This is a Flash map of China before the release version of the optimized version of source code in GoogleCode, available for download, with the following features: 1. In accordance with the province divided into administrative regions, showing detail

  • flex control learning website 2010-07-20

    Beginning to see flex, that there is no clue, which controls many feel no way, occasionally found a good site to learn control, to share http://examples.adobe.com/flex3/componentexplorer/explorer.html. Other sites: http://bbs.actionscript3.cn http://

  • Flex round of missile components 2010-08-14

    Recently used a component that round of bomb components even, quote them now use the program, the effect source code from the Internet application: <? Xml version = "1.0" encoding = "utf-8"?> <Mx: Application xmlns: mx = "

  • [Original] Flex in A-star Algorithm for Route 2010-09-06

    A * pathfinding algorithm is the most commonly used method to find way, here are some concepts, and implemented in Flex Demo Node (node): Is essentially a square grid inside a box (yujjj Note: Why do not they described as a box? As divided in a numbe

  • TWaver Flex Demo in Flash Builder4 problems and solutions are deployed 2010-09-26

    Customers get TWaver Flex Demo, and then deployed in the FB, the demo copy of src into it often will find a lot of reported errors, not run. This was mainly due to the latest Flash Builder used by default SDK is 4.0 or 4.1, but many customers still u

  • Install flash player bug is fixed and flex run newspaper flash player not fond solution 2010-09-27

    Today when installing flash player10, has been in not responding state, then change flash player9, installation error just started, and installation fails, adobe? Flash? Of class error. Was found http://kb2.adobe.com/cps/494/cpsid_49419.html Solution