AS3 Trace an info message - actionscript-3

I'm a AS3 developer but I'm not sure how can I trace this kind of messages in firebug as an info messsages.
I know that for an error I just need to inherit for an error but I'm not sure how can I trace this kind of messages.
This code:
trace("Hola")
will show "Hola" in Firebug, but I want the fancy Info icon at the beginning also the background of the line is blue.
Thanks for your help.

you can try https://addons.mozilla.org/en-US/firefox/addon/flashbug/
years ago I've used http://www.sephiroth.it/firefox/flashtracer/ not sure if anyone uses it still.
The trick is to use Debug version of flash player

In the case where you don't want to install the Flash Debug player (performance?), rather than using trace, route it to a Debug method that traces and logs to the console:
import flash.external.ExternalInterface;
var debug:Boolean = true;
function log(msg:String):void {
if ( debug ) {
trace(msg);
ExternalInterface.call('console.log',msg);
}
}
log('Hello World');
You should be able to throw that in a frame. If you're using class definitions, you'll have to interpret that code block as snippets.
Also note that in a browser that doesn't have console.log (like IE7) this will throw an error, so maybe you should test for console.log first and store the result in a global.
Notice the debug variable. When you want to turn debug logging off, just set debug to false. This is an overly simplified idea, but provides the basic concept.
Another way enhance this concept is to include a debug "window" if you will... really just a scrollable text box on top of everything else. This is helpful when dealing with devices that do not support logging, debug versions of flash or are just difficult to debug, e.g. mobile and AIR.

Related

DataVizExtention: issue with clearing viewables while a sprite is selected

In my code, I have this workflow:
When user wants to see some things, add Sprites using 'DataVizCore.addViewables()'
Use 'viewer.addEventListener(DataVizCore.MOUSE_CLICK, onDotClick)' to show info bubble
When user wants to show other things, call 'DataVizCore.removeAllViewables()' to clear Sprites
Repeat from step 1
This sequence works OK except in one situation.
If a sprite was selected (by clicking on it) before removeAllViewables() is called, I don't get MOUSE_CLICK event for newly added Sprites. In browser console, I see following error is thrown.
CustomViewables.js:318 Uncaught TypeError: Cannot read property 'style' of undefined at ViewableData.getViewableUV (developer.api.autodesk.com/modelderivative/v2/viewers/7.*/extensions/DataVisualization/DataVisualization.js:454)
As a workaround, I added 'event.hasStopped = true' to click event handler to prevent Sprite getting selected internally. That seems to work.
This seems like a bug in DataVizExtension to me. Or, my workflow is wrong?
Thanks
Bandu
Bandu. Thanks for the detailed steps to reproduce this issue. I tried with v7.46.0 version of the DataVisualization.js (latest as of my message) but was not seeing the same issue. I'd be curious if you are using this same version of the Forge Viewer (you can figure that out by looking at the viewer3D.js fetched under the Network tab of Chrome DevTools).
Setting event.hasStopped = true works because it internally avoided the code path calls into getViewableUV that threw the exception, but the flag is meant for other use cases (e.g. overriding default sprite selection behavior).
In any case, I've just tweaked our internal code to make use-cases like yours more robust. The changes will be released with the upcoming v7.47.0. Thank you for your feedback 🙂

How to get specific error message from SourceBuffer

I have an HTML5 video with a MediaSource for its source. When I call SourceBuffer.appendBuffer() the SourceBuffer throws an error.
I'm able to detect when this error is thrown like so:
sourceBuffer.addEventListener("error", function() {
console.log(arguments);
});
However the "arguments" in this case contain an ErrorEvent with no meaningful message or data. Just a reference to the SourceBuffer that failed.
I need to figure out why it failed, so I can fix it.
Yes, this is one of the most frustrating parts about MSE... it's really difficult to debug. I think the issue is that the errors have to be standardized from browser to browser. Since there's a lot of
If you're using Chrome, the best place to look is chrome://media-internals.
As of Chrome 91 the media-internals pane is removed. Instead. go to
DevTools / hamburger menu (=== Customize and Control DevTools) / More Tools ▶ / Media
Then you'll have a Media tab on DevTools.

Actionscript ExternalInterface syntax error

I have created a simple container app whose purpose is to:
play an embedded flv by clicking a button onscreen
activate an external interface call (this records the fact that the person has watched the video)
That's it.
I have it working partially. I have a button on scene 1 with the "click and go to next scene" code snippet attached to it. I click it and it happily moves on to scene 2 where the flv video plays beautifully. The problem happens when I try to insert the code that the external developer told me to use to make the connection between my flash file and IT's back end work.
Here is the recommended code:
ExternalInterface.call("recordScore()”);
Unfortunately, as soon as I enter this code, there is a syntax error and the movie no longer plays. I added the code on a frame at the end of the movie.
I am no sure that the syntax the developer sent was correct, nor do I know where to insert this code into the proper place.
It looks like there is a closed double quotes (”) in what you pasted:
ExternalInterface.call("recordScore()”);
Assure quotation marks, and you do not need the () on the JavaScript function you're calling:
ExternalInterface.call("recordScore");
When running from Flash Projector (as in Ctrl+Enter), you can test whether External Interface is available; otherwise, an exception is thrown at runtime:
if (ExternalInterface.available) {
ExternalInterface.call("recordScore");
}
Fortunately, I found some code in the former employee's files that seems to have worked:
ExternalInterface.call
(
"recordScore()"
);
Hopefully this will connect with the database and resolve the issue so I can go back to making videos.
Thank you so much for your help!
Regards!

ArgumentError: Error #2109: Frame label default not found in scene default

I have asked this question on the http://www.actionscript.org/ forums, I have yet to get a reply, so I will try here as well, I will copy the post from those forums, but please do tell me if I am missing any details out, posting it on the wrong forum on this website, or whether I should actually post it to another website.
The post is as follows:
I am fairly new to using action script 3.0, I am following a set of video tutorials for such.
I am using Adobe Flash Professional CC 2014, along with some extra elements, to create the main menu for a game using UDK(Unreal Development Kit), that I have in mind, to confirm, this is a test game, not intended for release, it will be free to try when I get various features implemented, a practice project.
So, I am using Scaleform and CLIK. When I run what I have so far, using the Scaleform launcher, everything works as intended, no errors are logged in the console. However, when I use the debugger and click on the 'Options' button on my main menu (it is the only button in frames 1-10, at the moment, under the 'mainMenuScreen' label that I have declared), I get the following error:
ArgumentError: Error #2109: Frame label default not found in scene default.
at flash.display::MovieClip/gotoAndPlay()
at scaleform.clik.controls::Slider/draw()[C:\UDK\UDK-2014-08\Development\Flash\AS3\CLIK\scaleform\clik\contr ols\Slider.as:273]
at scaleform.clik.controls::Slider/set value()[C:\UDK\UDK-2014-08\Development\Flash\AS3\CLIK\scaleform\clik\contr ols\Slider.as:156]
at MainMenu_fla::MainTimeline/frame10()[MainMenu_fla.MainTimeline::frame10:11]
at flash.display::MovieClip/gotoAndPlay()
at MainMenu_fla::MainTimeline/OpenGameplayOptionsScreen()[MainMenu_fla.MainTimeline::frame1:17]
I am not using a label known as 'default', nor do I have a scene called 'default' and also, as can be seen from the code for the button, I am not trying to go to (gotoAndPlay), 'default', I am trying to go to a label I have defined, known as 'gameplayOptionsScreen', the code is as follows:
import flash.events.MouseEvent;
/*Function
#Name: OpenGamePlayOptionsScreen
#Params: None
#Description: This function will make the scene go to the "gameplayOptionsScreen"
label, so that the components that will be on the screen will now be those under the
label of "gameplayOptionsScreen".
*/
function OpenGameplayOptionsScreen(evt : MouseEvent)
{
gotoAndPlay("gameplayOptionsScreen");
}
// Add an event listener to this button, so it can tell if it has been clicked on, // in this case:
optionsBtn.addEventListener("click", OpenGameplayOptionsScreen);
(The line above this one, is where the debugger highlights one of the places the error occurs)
stop(); // Stop the flash movie here
From what problems that the debugger has informed me of, it also seems to have a problem with the slider that appears in frame 10, the frame that the label, 'gameplayOptionsScreen', is assigned too.
But I am wondering why the error occurs, in regards to a call to 'gotoAndPlay("gameplayOptionsScreen");', as that is where I believe the error becomes existent from.
Please do tell me if you require more information to help me solve this problem that I am having, or do tell me if I have posted this in the wrong forum on this website, or if I have in fact posted this to the wrong website altogether and therefore, should be posting to Epic Games' forums instead.
Edit: I have redone the button, so that, it is now known as TestGameButton and DefaultButton is in my library too, as it was in the click components library, this component has been left unchanged this time. Using my new button still produces the same errors and even using the default button does as well. But removing the slider that the debugger also complains about that is displayed in frame 10, removes all the errors, so it seems to be a problem with the slider, I am not sure what though, I have tried putting in a new instance and naming it, but I get similar errors .
Never mind then, I don't mind if this question does not get any answers, I am moving onto UE4, which has much better systems in place for menus, for example, thanks for trying to help #CyanAngel though.

how do you find error in a SWF?

i feel stupid asking that question, but it seems like i'm unable to find out.
i have a SWF that works perfectly inside flash. once i export as SWF, it doesn't work anymore.
i can't use "trace"
i have tryed that function but it doesn't trigger it for some reason. :
function quikTrace(string:String){
//INIT VARIABLES
var tmpTxtField:TextField;
//TEXTFIELD PROPERTIES
tmpTxtField = new TextField();
tmpTxtField.text = string;
tmpTxtField.x = stage.width / 2;
tmpTxtField.textColor = 0xFFFFFF; //white (black background)
tmpTxtField.y = stage.height / 2;
addChild(tmpTxtField);
}
is there any "outside the box" way to find errors in a SWF?
You can view trace statements in the browser by doing a few quick steps:
Get a debug flash player for your browser. link
Set up mm.cfg to enable flash logging to a file. link
Get a text editor / "tail" viewer and read the flashlog.txt file that is generated. This is where FireBug & Flashbug come in handy, if you're in firefox. You can also try baretail for PC, or regular old "tail -f" on a mac/linux machine.
Good luck.
It's not a stupid question at all! You're just learning how to debug Flash for the first time. You can use "trace" with an exported SWF by doing a debug/test build from Flash IDE or Flash Develop. You can then read these traces with Firefox by using the extentions Firebug combined with the Flashbug extension. Now you're all set for getting feedback using traces.
For this particular problem, it's hard to say. Is this function inside of a class or timeline code? If it's a class, it probably because Stage is not ready yet. You can use the event Event.ADDED_TO_STAGE to know when the Stage reference is ready to be used.
Hope this helps!
Install a debug version of flash player for your browser. It will tell you exactly which line of code is throwing error.
http://www.adobe.com/support/flashplayer/downloads.html