View Full Version : Scaleform counter
kaptan_kul
10-02-2010, 10:32 AM
I am trying to make a scaleform count how many times a trigger is touched and output that to a hud element. If anyone has any tips I would appreciate them.
This is the code I am trying to use, and in UDK I try and invoke addCans, but it does not change the value.
var cans:Number = 0;
text1.text = "Cans: 0";
function addCans(toggle:Boolean){
if(toggle){cans++;
}
text1.text = "Cans: " + cans;
}
Selection.setFocus(text1);
kaptan_kul
10-04-2010, 11:04 AM
var Cans:Number = 0;
text1.text = "Cans: " + Cans;
function addCans(intCans:Number){
Cans = intCans + Cans;
text1.text = "Cans: " + Cans;
}
Selection.setFocus(text1);
kaptan_kul
10-04-2010, 12:04 PM
http://img.photobucket.com/albums/v601/high_josh/invoke-1.png?t=1286208204
http://img.photobucket.com/albums/v601/high_josh/kismit.png?t=1286208040
Matt Doyle
10-04-2010, 12:48 PM
I would say debug a few things to start with:
1. Is your trigger firing? Send a log message to verify it is firing. If it isn't firing, something is wrong in the trigger setup.
2. Is your Flash function working on its own. Execute the function from Flash to see if the function works as you intend. If it does, then we know the problem is that Unreal isn't sending the call to the function properly, or Flash isn't receiving it properly.
3. Check scope. Where does the function live on the timeline? _root? Try setting the function in Unreal to _root.addCans maybe?
4. Use trace statements in Flash to verify things are working. Use log message in UDK to do the same.
Matt Doyle
10-04-2010, 01:29 PM
BTW - I can verify your Flash code is working properly. I assume you are using a dynamic text field with an instance name of text1. Firing addCans(5); in Flash sets the text field to cans: 5 on my end just fine.
var Cans:Number = 0;
text1.text = "Cans: " + Cans;
function addCans(intCans:Number){
Cans = intCans + Cans;
text1.text = "Cans: " + Cans;
}
Selection.setFocus(text1);
addCans(5);
kaptan_kul
10-04-2010, 08:13 PM
So I worked back from the scroll Bar example, and this is the most recent. Any help will be greatly appreciated.
http://www.mediafire.com/?zk8tu6whjk5p6vj
Matt Doyle
10-05-2010, 11:32 AM
It looks like your 'addCans' function lives inside the movieclip instance 'demoComponents'. This is the "scope" of the function.
Try using either: _root.demoComponents.addCans(some number)
or: demoComponents.addCans(some number)
as your function call in the InvokeActionScript Kismet node.
Whenever you call a function, you must use the fully qualified path to that function - at least when calling it from Kismet.
kaptan_kul
10-05-2010, 12:17 PM
Thank that made it work. Yeap I needed to add the demoComponents bit.
gegebel
10-20-2010, 03:59 AM
Hey I'm looking for the same stuff as you did, could you help me?
I have bots going through a door triggering a counter in Kismet.
I'd like the int to be on my HUD though.
something like in the upper left corner a text with "Bots: X"
Matt Doyle
10-20-2010, 10:21 AM
Look at the Kismet setup above, and the code. That is pretty much how to do it.
gegebel
10-20-2010, 04:56 PM
when I do addCans(5) it does add 5 cans in flash, but when I try it in UDK, I just have a blank space with nothing in it...
Matt Doyle
10-20-2010, 05:23 PM
Your problem could be any number of issues. As I have no idea what your complete setup is, its hard for me to tell you what that could be. However be sure that:
1. You must have an Invoke ActionScript in Kismet that executes the function 'addCans' (or whatever your function is) and sends the correct parameter.
2. Be sure you use the fully qualified path to 'addCans'. If addCans is on the root timeline in Flash, then use _root.addCans as the function call. If it lives in a movie clip, use the name of the movie clip - example: myMovieClip.addCans
This is all exactly what i told the previous poster and he got it working. Everything you need to know is in the previous posts. I am assuming you already know how to properly set up a Flash HUD.
gegebel
10-20-2010, 05:33 PM
This is my code, it's on scene1, layer1, frame1:
_global.gfxExtensions = true ;
var Bots:Number = 0;
text1.text = "Bots : " + Bots;
function addBots(intBots:Number){
Bots = intBots + Bots;
text1.text = "Bots : " + Bots;
}
Selection.setFocus(text1);
This is what I get after setting an invokescript, using addBots as Method Name
http://img693.imageshack.us/img693/5449/flashyo.jpg
Matt Doyle
10-20-2010, 05:36 PM
Ah, yes - right off the bat I can tell you your fonts aren't embedded in the text field. Please see the #7 UDK Workflow tutorial video which will explain in detail how to handle Fonts in Flash & UDK. Here -> http://www.youtube.com/watch?v=QP-MawV87Vc
FYI - the data is very likely being displayed, but since your fonts aren't embedded it shows empty boxes for missing fonts.
gegebel
10-20-2010, 05:43 PM
Thx Matt, you're the greatest :)
gegebel
10-20-2010, 06:27 PM
I tried this code :
_global.gfxExtensions = true ;
var Bots:Number = 0;
var Escaped:Number = 0;
text1.text = "Ennemies: " + Bots;
text2.text = "Escaped : " + Escaped;
function addBots(intBots:Number){
Bots = intBots + Bots;
text1.text = "Ennemies: " + Bots;
}
function addEscaped(intEscaped:Number){
Escaped = intEscaped + Escaped;
text2.text = "Escaped : " + Escaped;
}
It works fine in flash, but no go in UDK. any ideas?
Matt Doyle
10-21-2010, 10:17 AM
No clue. The ActionScript looks perfectly fine, but I have no idea what problem you are having, nor what your Kismet setup looks like. More details are required to know what is wrong. I assume you embedded your fonts this time.
gegebel
10-22-2010, 06:36 AM
funny enough, the addBots function works fine.
the second one isn't firing, eventho the kismet logs show it does actually work, for some reason, the second function doesn't work.
I thought it would be the actionscript, but the test in flash shows it does work, something is overriding in UDK I guess, just what...
Matt Doyle
10-22-2010, 10:38 AM
I see. Then you'll need to do some basic debugging to figure out what is malfunctioning. Check everything twice to make sure its all setup correctly. If you still have trouble, you can always send me your flash file and your UDK kismet setup (screenshots) so I can give it a look.
Private message me if you need to and I'll send you an email address in PM.
foad-torfi
05-26-2011, 05:56 AM
I got download : http://www.mediafire.com/?zk8tu6whjk5p6vj
but it doesn't answer Please guide me step to step
Thank you
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.