View Full Version : how to pass values from actionscript to unrealscript ????
daimaku
10-09-2010, 08:03 PM
hello i'm making the main menu of my game using scaleform, i know how to pass values from unrealscript functions to actionscript functions, but i need to pass some values from actionscript to unrealscript.
i don't know how to do it, i have searched over the forum but i can't find anything, somebody can help me with this ?
thank you in advanced for the help....
sidstyler
10-10-2010, 06:10 AM
In you AS2.0 file:
import flash.external.ExternalInterface;
var name:String = "MyName";
var age:Number = 23;
//..other code and stuff
ExternalInterface.call("UnrealFunction", name, age);
and in your unreal script class you have this function:
function UnrealFunction( string name, int age )
{
//do funny stuff here
}
daimaku
10-10-2010, 04:46 PM
thank you sidstyler, i will try it right now .... thanks again ....
daimaku
10-12-2010, 07:46 PM
i'm trying the code but in what class must to be the unreal function to receive the actionscript call ?
i'm having a little problem i have searched over the forum and i have found that the unrealscript function must be in a class extended from GFxMoviePlayer.
now i have put my function for my main menu in other class called MainMenu, but the unrealscript is not receiving the call from actionscript, here is my code in unrealscript
class VentureMainMenu extends GFxMoviePlayer;
//load slots for the main menu
function LoadSlots()
{
`log("i 'm coming from flash actionscript");
CallShowSlots(0,0,0);
}
function CallShowSlots(int fslot1, int fslot2, int fslot3)
{
`log("sendind information to flash with the slots availables");
ActionScriptVoid("ShowSlots");
}
DefaultProperties
{
}
this is my flash code
import flash.external.ExternalInterface;
stop();
ExternalInterface.call("LoadSlots");
function ShowSlots(SlotOne:Number , SlotTwo:Number, SlotThree:Number):Void
{
if (SlotOne==0)
{
Tslot1.text="por aqui fumea";
}
}
can somebody help me with this issue ?
sidstyler
10-13-2010, 01:57 AM
Your class in unreal "VentureMainMenu" extends the movieplayer class but you don't ever tell it to load your swf file? Or have you just removed that information for the sake of clarity in this thread?
Your code is correct with how the calls are being made. So my guess is that it's how you load your swf file that is your problem. Have you confirmed that you can interact with your swf file to begin with? That it is loaded and is runned when you start your game I mean.
daimaku
10-13-2010, 04:18 AM
the swf file is running ok, i load the swf file using kismet in a map that i have created only for my main menu.
i don't know how to load or assign the swf main menu from unrealscript code, that's why i'm using kismet to load the menu.
sidstyler
10-13-2010, 08:05 AM
Well unfortunetely for you I try to keep as far away from kismet as possible ^^ 90 % of what I do is done via unrealscript.
What I do in unrealscript to bind a swf file to a certain movieplayer class is to define the swf file in its defaultProperties. Here is an example class I use that contains all the scaleforminformation.
class SanctumHUDGFxBuild extends GFxMoviePlayer;
function Write( string text )
{
`log( text );
}
function CallAbleToUpgradeChanged( bool newValue )
{
`log( "ableToUpgrade changed"@ newValue );
ActionScriptVoid( "_root.buyAndUpgrade.ableToUpgradeChanged" );
}
function Init(optional LocalPlayer LocPlay)
{
Start( );
Advance( 0.f );
}
DefaultProperties
{
MovieInfo=SwfMovie'HUD.BuildHUD'
}
The function "CallAbleToUpgradeChanged" calls the function "ableToUpgradeChanged" located within the movieclip "buyAndUpgrade" in the swf file "BuildHUD".
To load this movieplayer I keep a variable of the class "SanctumHUDGFxBuild" in my HUD class, instantiate it and then call the Init function when I want to display the SWF file.
If you insist on going on with kismet then all I can say is GLHF =)
daimaku
10-13-2010, 09:15 AM
I have made my custom hud using scaleform and all the calls in my hud were made with unrealscript, i can change the call from kismet to unrealscript.
The problem is, this is my main menu i don't know how to handle it in the way that i have handled my custom hud, i don't know what class i need to extend to make my custom class for my main menu.
Without the knowing of the class menu i have another problem, i don't know how to load a especific class when the level loads up, that's why i'm using kismet to load my custom scalewform menu.
Can you help me with this ?
Thanks in advance for all your help ....
Matt Doyle
10-13-2010, 10:36 AM
Most of this stuff is covered already in the video tutorial on creating custom menus. I really advise you to watch the video.
That being said, be sure you tell your SWF file to start playing with this function (which should live at the top of your UnrealScript class file):
function bool Start(optional bool StartPaused = false)
{
super.Start();
Advance(0);
return true;
}
And be sure your UnrealScript class (VentureMainMenu) is used in the Kismet Movie Player Class drown down rather than the standard GFxMoviePlayer.
daimaku
10-13-2010, 09:32 PM
thank you Matt Doyle i will check the videos ....
Matt Doyle
10-14-2010, 10:43 AM
The video does not specifically cover external interface calls, but it does show you exactly what you need to do to have a working Flash menu that can send external interface calls successfully.
daimaku
10-14-2010, 06:20 PM
thank you very much Matt, the videos help me a lot, i have figure out all my problems, your videos are awesome !!!!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.