Interaction of ActionScript and UnrealScript in Scaleform

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/NEOCSL/p/4174134.html

Scaleform is a great tool for making the UI:

1. He can liberate programmers from code-controlled UI effects, such as panning, rotation, and zooming, all extremely easy. If you want to make a complex animation page, simply rely on the code to achieve a very troublesome.

2. He can combine the game engine to implement a stereoscopic UI using the RenderTarget form. It's really cool. Like the cliché of "dead space" and the latest "Advanced Warfare".

  

Into the Chase, Setup lets ActionScript and UnrealScript interact.

Flash:

  1. Introduce PNG images into the library. Set its properties correctly to remove the suffix. We introduce a button picture with a mouse pointer that implements the function of clicking the mouse button:

Create 5 channels on the timeline, one action, and insert the AS2 script code on the first frame. We set up three buttons, each of which is placed on a separate timeline, using F8 to convert those images to button. Drag the three buttons into the scene individually, with the attribute instance names btn1,btn2,btn3. Then fill in the code on the first frame of the action timeline

ImportFlash.external.ExternalInterface;ImportGfx.controls.Button;Importgfx.motion.tween;_global.gfxextensions=true;Importmx.utils.delegate;btn1.onpress=function() {Externalinterface.call (' attack '); Trace ("attack button pressed");} Btn2.onpress=function() {Externalinterface.call (' Jump '); Trace ("Jump button pressed");} Btn3.onpress=function() {Externalinterface.call (' Defense '); Trace ("defense button pressed");}

The above code defines the UnrealScript function corresponding to each button press, such as ' attack ' in call (' attack ').

Next set the mouse pointer, click the mouse pointer, and then F9 fill in the code

onclipevent (enterFrame) {_x=_root._xmouse _y=_root._ymouse}

This section of code allows the mouse to appear.

UnrealScript:

We're going to borrow the HUD to display the new Scaleform page that calls itself, and create a new class Antgfxmenu that inherits from Gfxmovieplayer. In the HUD, there are:

varAntgfxmenu Menumovie;//Createfunction Creategfxmenu () {Menumovie=New class'Antgfxmenu';    Menumovie.settimingmode (Tm_real);  Menumovie.initialize (); //custom initialization in Antgfxmenu} //destroyedSingularEventdestroyed () {super.     Destroyed (); if(menumovie!=None) {Menumovie.close (true); Menumovie=none; }}//in the Drawhud class of the HUDfunction Drawhud () {//invoke Refresh rendering of ScaleformMenumovie.tickhud ();}

In the Antgfxmovie class

classAntgfxmenu extends Gfxmovieplayer;//looking for variable components defined in Flash, we only implement mouse and buttonvarGfxobject attackbutton,cursor;//function Implementationfunction Initialize () {Start (); //initialization function of ScaleformAdvance (0. f); Attackbutton=getvariableobject ("_ROOT.BTN1");//variable name in FlashCursor=getvariableobject ("_ROOT.CURSOR_MC");//Get Mouse}//Real-time updatesfunction Tickhud () {//actions for real-time updates}defaultproperties{Bdisplaywithhudoff=false  //do you want to kill HUDMovieinfo=swfmovie'test.menutest' //Menubignoremouseinfo=false}

These are general steps, and the following code demonstrates the method by which UnrealScript calls ActionScript;

//before the functionDelegateattackdelegate ();//implement the function definition of the button, as in Externalinterface.call (' attack ');function Setupattackdelegate (Delegate<AttackDelegate>d)    {Local Gfxobject rootobj; Rootobj=getvariableobject ("_root");//Our action first frameActionscriptsetfunction (Rootobj,"Attack");//in ActionScript}//functions called asfunction Attack () {Antplayercontroller (Getpc ()). Givemoney ();}

This concludes.

Interaction of ActionScript and UnrealScript in Scaleform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.