0

I have a swf file that I wish to modify the byte code ( I am using ActionScript Extractor ).

What is a good way to easily output a variable for example a quick way to do the equivalent of (in JS)

alert(theVariable);

I have tried to use adobe's trace function but it works very poorly and sometimes doesn't seem to work at all.

2 Answers 2

1

The function is called

Alert.show

http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001965.html

Alert.show(message[, title[, flags[, parent[, clickHandler[, icon[, defaultButton]]]]]])

Parameters

message The message to display.

title The text in the Alert title bar. This parameter is optional; if you omit it, the title bar is blank.

flags An optional parameter that indicates the buttons to display in the Alert window. The default value is Alert.OK, which displays an OK button. When you use more than one value, separate the values with a | character. Use one or more of the following values: Alert.OK, Alert.CANCEL, Alert.YES, Alert.NO.

You can also use Alert.NONMODAL to indicate that the Alert window is nonmodal. A nonmodal window allows a user to interact with other windows in the application.

parent The parent window for the Alert component. The Alert window centers itself in the parent window. Use the value null or undefined to specify the _root timeline. The parent window must be a subclass of the UIComponent class, either as another Flash component that is a subclass of UIComponent, or as a custom window that is a subclass of the UIComponent (for more information see About inheritance in Learning ActionScript 2.0 in Adobe Flash). This parameter is optional.

clickHandler A handler for the click events broadcast when the buttons are clicked. In addition to the standard click event object properties, there is an additional detail property, which contains the flag value of the button that was clicked (Alert.OK, Alert.CANCEL, Alert.YES, Alert.NO). This handler can be a function or an object. For more information, see Using listeners to handle events in Using ActionScript 2.0 Components.

icon A string that is the linkage identifier of a symbol in the library; this symbol is used as an icon displayed to the left of the alert text. This parameter is optional.

defaultButton Indicates which button has initial focus and is clicked when a user presses Enter (Windows) or Return (Macintosh). If a user tabs to another button, that button is triggered when the Enter key is pressed.

This parameter can be one of the following values: Alert.OK, Alert.CANCEL, Alert.YES, Alert.NO.

Returns

The Alert instance that is created.

Description

Method (class); a class (static) method that displays an Alert window with a message, an optional title, optional buttons, and an optional icon. The title of the alert appears at the top of the window and is left-aligned. The icon appears to the left of the message text. The buttons are centered below the message text and the icon.

Example

The following code is a simple example of a modal Alert window with an OK button:

mx.controls.Alert.show("Hello, world!");

The following code defines a click handler that sends a message to the Output panel about which button was clicked. (You must have an Alert component in the library for this code to display an alert; to add the component to the library, drag it to the Stage and then delete it):

import mx.controls.Alert;

// Define button actions.
var myClickHandler:Function = function (evt_obj:Object) {
 if (evt_obj.detail == Alert.OK) {
trace(Alert.okLabel);
 } else if (evt_obj.detail == Alert.CANCEL) {
trace(Alert.cancelLabel);
 }
};

// Display dialog box.
var dialog_obj:Object = Alert.show("Test Alert", "Test", Alert.OK | Alert.CANCEL, null, myClickHandler, "testIcon", Alert.OK);
Sign up to request clarification or add additional context in comments.

2 Comments

is there something that doesn't require an import as I am editing the bytecode
You probably don't have to import anything just use mx.controls.Alert.show("test"); the mx.controls probably already exists? otherwise you could output using the fscommand("messagebox", "test"); javascript function: function myDocument_DoFSCommand(command, args) { if (command == "messagebox") { alert(args); } }
1

As long as it's a property, not a local variable, you can try running the swf in SWFWire Debugger.

You can find the variable by navigating through properties or in the object tab, as shown below.

Properties and objects

Disclaimer: I created this project

2 Comments

What if it is a swf from a website?
You can either paste the URL into the SWF URL field, or download the file and drag-and-drop it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.