ActionScript 3.0 :: Trace Value Within Function?
Nov 8, 2009how to trace value within ActionScript function.
Problem solved moderators can close this thread.
how to trace value within ActionScript function.
Problem solved moderators can close this thread.
I am having issues with a global array. I have an actionscript file called MyGlobal.as at the same level as my main FLA:
[Code]....
I am able to trace that first element while trace is called within the function... but if I try to trace that first element outside of the function it is "undefined". Do I need to return the array at the end of the function? I tried that but I cant seem to get it working correctly.
I've been playing with prototype a bit and I've noticed that either it isn't as static as it should be or that some functions are protected from altering, or that in some cases the prototype actually extends a function. For example, I was trying to modifiy the global trace function to output the current time of a trace action, something like this :
Code:trace("lulu"); // output 12:48:17.286 lulu I DID achieve something close to it, but it seems that I haven't actually modified the global trace function, but rather it's "_root" counterpart,
[Code]...
how would you trace the name of a function, without writing it yourself, is it possible?
So if I have:
private function destroy():void{
trace();
}
how would the trace look like to trace out some kind of refecence-name to destroy? (without typing in destroy into the trace ofc....)
So this is my code:
ActionScript Code:
onClipEvent(enterFrame) {
if (!this.already) {
setTimeout(win, 2000);
[Code]....
The problem is that I can't do trace(this); How to get it work? I have tried to do this.setTimeout etc..
hive just started actionscripting instead of tweening so be gentle. i use mx 2004 but i cant get the trace function to work.., here is the code form a kirupa tutorial...
_global.myvar=5;
trace (_global.myvar);
why does this not work?i thought it shud display 5.
I want to modify the trace function to add it to a log, then display it in the trace output window.
View 3 RepliesI have 20 players in a game and cutting and pasting lots of code except for a few numbers. I have future features that would require over 400 lines of mostly repeated code. So I learned how to use "for", and practiced with a trace command. Traced the results exactly as I thought. However when I apply it to the guts of my function, the movie breaks down. I suspect it's because the function is being called on an EnterFrame command and the for loop I wrote is being executed over and over.
This works when I hand code:
Actionscript Code:
function drill(){GUESS0 = ((guess0min * 60)*1000) + ((guess0seconds * 1000))
GUESS1 = ((guess1min * 60)*1000) + ((guess1seconds * 1000))
GUESS2 = ((guess2min * 60)*1000) + ((guess2seconds * 1000))
GUESS3 = ((guess3min * 60)*1000) + ((guess3seconds * 1000))
GUESS20 = ((guess20min * 60)*1000) + ((guess20seconds * 1000))
//and then 300 more lines of other code}
And then a button later calls this when pressing:
Actionscript Code:
my_MC.onEnterFrame = function(){_root.drill ();
//so _root.drill is continually being called, which is good, because it has all sorts of data that needs to be refreshed, but I think it's screwing with my "for" loop.}
And the following is NOT working.
Actionscript Code:
function drill(){for (i=0;i<20;i++){
"GUESS"+i+" = ((guess"+i+"min * 60)*1000) + ((guess"+i+"seconds * 1000));";}
But when I trace it in a separate test movie, it outputs exactly what I would hope it placed in the code:
Actionscript Code:
for (i=0;i<5;i++){trace("GUESS"+i+" = ((guess"+i+"min * 60)*1000) + ((guess"+i+"seconds * 1000));");}
So at the end of the day, I guess I can trace these results in a test movie and use it to generate what I need, and cut and paste it into the project... but I thought 'for' loops were for saving time AND space. Am I using this code right? Maybe my use of "", or +, or i is misguided?
I'm working through some tutorials from my instructor to eventually build a simple e-com website for a state park. Basically, I'm using the two as3 files shown below and trying to get "bob" in my output with an array function and trace. Load store function is intentionally coded out. When I test project, nothing comes up in output, and I have no errors.
Main012.as:
package {
import flash.display.MovieClip;
public class Main012 extends MovieClip {
public function Main012() {
[Code] .....
I don't have any practical need for this but just for learning purposes, is it possible and how to trace the name of the function to the Output panel?
View 6 RepliesI have an enter frame event and a function running that event, I have place a tracestatement within the function and the stage is running at 25fps.My problem is how do you make the trace statement run just once only? Since it get really annoying when the output panel keep tracing the same thing and slow down my swf....
View 3 RepliesHow do you send the output of a function to a dynamic text field on the stage instead of the output panel?I have used trace(); but that just sends the value to the output panel.
View 3 RepliesThe trace function in this file doesn't output all of the keycodes on my keyboard. Some letters generate a keycode and others don't. For instance, "u" outputs 85 but "i" outputs nothing.
Here's the trace function trace(event.keyCode);
[Code]...
I have a simple code that seems to be giving strange results.
var startPoint:Point = new Point(x, y); // a point
var r:Number = path[i].row + (-Math.floor((length * 2 + 2) / 2)); // just some math
trace(r); // the math checks out and gives a 3
var tey = startPoint.y + r; //this gives a really strange return....
[Code].....
I am having a problem with the if statement in my timer function, the trace statement within in it is not working, eventually I wanted to use this if statement further but need to make sure it is working first.
Code:
timerFunction();
} function call in function above
function timerFunction() {
trace("hey");//this trace works
var myTimer:Timer=new Timer(1000,15);
[Code] ......
I follow some sample code which uses trace("Hello World"); to print out something in ActionScript 3.0, in Flash Professional CS5.
But nothing seems to get printed out (in a browser). Is the trace() function deprecated / removed?
I'm starting to learn Objective C and I wonder if there is any similar function toactionscript trace to show messages in a console.
View 1 RepliesI got this weird problem, when i run this code:
Code:
package {
import flash.display.MovieClip;
[Code]....
In Flash Cs3 it acts exactly as i want, the ENTER_FRAME runs and the addObject places numerous sprites on the stage. In the window output i'll see the trace. But when i run this code in Eclipse which is set up to use the Flash Player as output i get the first trace from EDHV_ImageSlider but the traces inside addObject won't show up, the sprites however are generated perfect.
The difference between the eclipse setup and the cs3 setup is the fact that the cs3 setup has a *.fla which calls the *.as package.
ive got a loaded xml list for an mp3 player. from playing track1, when i select track 2, it traces "track1" but then after a second click it traces "track2" and stays on that. the actually music for track2 does load on the first click though, but not the trace. anyone know why on the first click it would still trace the previous track? here is the code for that function...
[Code]...
take a look at the results of these traces:
trace(imgGal); //traces "1"
trace(itemClip1._y); //traces "32"
trace(itemClip[imgGal]._y); //traces "undefined"
why does the last trace not trace "32" like the second trace? I want to insert the variable "imgGal" onto the end of the mc "itemClip", how can I do this?
[Code]...
var dane:Array = new Array();
dane_xml = new XML();
dane_xml.ignoreWhite = true;[code]....
and this last trace gives me undefined while trace(temp) gives me what I want
I'm making the transition from AS2 to AS3 and have some rollover and rollout code below. I'm looking to place an if statement into the onClipOver function that can trace what specific button is being pressed. In AS2 I would use the "this" command to see which movieclip was being used. how to properly write the IF statements using AS3 in the code below.
[Code]...
I've got a Vector of ViewToActionMap objects, which have following constructor:
public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,
[code].....
i'm preparing to do a tile based game, but i'm going to probably have access to at least maybe 20 tiles so i wish to do my tile map like this
var myArray:Array = [[001,001,001,001],
[001,000,002,001],
[001,015,000,001]];
that's a rough example. but to develop a map editor i need to be able to string a number will 0s preceding anything that is less than 100. is there an API for this or would i have to go with something like
if (a < 10) {
string = "00"+a;
} else if (a < 100) {
string = "0"+a;
}
I have define complete event handler and want to return value . But I lose "myString". I do not know how to return "myString" from loadXMLFile.[code]...
View 1 RepliesI wanted to ask that what is the method to trace the attribute in the xml file. I am trying a code but its saying undifined. The xml file looks like
[Code]...
This successfully traces that the cue point has occurred
how do I add tracing the name of the cue point?[code]...
I have a movieclip on stage.I load external image in it.Now on mouseclick over it I want to trace the image name eg "Andrew.jpg"How can I do this.
View 8 RepliesI just bought CS5 like a week ago. I'm finally getting around to using it for older content and now my trace output doesn't work for anything. The output window opens up, but nothing prints out. I'm also getting TweenMax errors in something I haven't touched in weeks.
View 7 RepliesIm using hitTestObect to detect collision.
if (movieclip1.hitTestObject(movieclip2) {
// do something
}
the above code detects whether movieclip1 hits movieclip2.... ok
if (hitTestObject(movieclip2) {
// do something
}
the above code detects whether 'Anything' has hit movieclip2.... ok
what i want is a way to use the second code but for example, trace the movieclip's name that hit movieclip2
there are above 50 possible movieclips that could have hit movieclip2
the only way i've thought of doing it is doing a loop using the first method (replace movieclip1 with movieclipArray[x])
but rather than doing a loop i would just like for it to trace the name of whatever hit movieclip2