Posts Tagged ‘osx’

Using MTASC with the OSX Terminal Part 1

July 2, 2008

I’m attempting to clarify and document all the methods I intend to use to Compile and Publish to swf files.
The bare bones method would be to use the OSX Terminal.
The following is an abridged OSX specific version of the text in mtasc.org.

Tasks

1. Download MTASC see: mtasc.org

2. Place in applications folder.

3. Open the Terminal Application.

4. Add the path to the MTASC Application in the Terminal:

$ export PATH=$PATH:/Applications/mtasc-1.13-osx/

5. Test by tying MTASc in the Terminal:

$ mtasc

If the the app has been correctly downloaded and the path correctly set the output will be something like:

	 Usage : mtasc.exe [options]
 Options :
  -pack  : compile all files in target package
  -cp  : add classpath
  -v : turn on verbose mode
  -strict : turn on strict mode
  -infer : turn on local variables inference
  -wimp : turn on warnings for unused imports
  -msvc : use MSVC style errors
  -mx : use precompiled mx package
  -swf  : swf file to update
  -out  : swf output file
  -keep : does not remove AS2 classes from input SWF
  -frame  : export into target frame (must exist in the swf)
  -main : enable main entry point
  -header  : specify header format ‘width:height:fps’
  -group : group classes into a single clip
  -exclude  : exclude classes listed in file
  -version : change SWF version (6,7,8,…)
  -trace  : specify a TRACE function
  -help  Display this list of options
  –help  Display this list of options

Which lists all the MTASC Commands.

6. Create a folder to create project in.

$ mkdir tuto

7. Duplicate the Tuto.as Class from the mtasc.org page and save in folder:

class Tuto {

	static var app : Tuto;

	function Tuto() {
		// creates a 'tf' TextField size 800x600 at pos 0,0
		_root.createTextField("tf",0,0,0,800,600);
		// write some text into it
		_root.tf.text = "Hello world !";
	}

	// entry point
	static function main(mc) {
		app = new Tuto();
	}
}

8. make MTASC publish swf enter in the Terminal:

$ mtasc -swf tuto.swf -main -header 800:600:20 Tuto.as

This should create a tuto.swf file in the tuto folder.

———————————————-

9. The flags seen in the help output above can be added to the call launch MTASC for instance:

mtasc -v -swf tuto.swf -main -header 800:600:20 Tuto.as

Will produce a verbose output link which includes:

 as
Classpath : /Applications/mtasc-1.13-osx/std/;/Applications/mtasc-1.13-osx/;;/
Parsed /Applications/mtasc-1.13-osx/std/StdPresent.as
 --
 --
Parsed Tuto.as
Typing Tuto.Tuto
 --
Time spent : 0.004443

I’ll attempt to test further MTASC Commands in further posts, I’ve just found a MTASC forum.

Sprouts

June 26, 2008

Whilst searching for information about MTASC Commands I came across site the Sprouts site. An ‘an open-source, cross-platform project generation and configuration tool for ActionScript 2, ActionScript 3′…. As I’ve been looking at Ruby using the OSX Terminal and am interested in further experiments in finding new an better ways to compile and build swfs I thought I would investigate, and create another project.

Project Aims:

1. Create a Sprout to compile AS2 Flash to a swf using MTASC.

2. As above with SWFMill

The Project uses:

1. Mac OSX 10.4.11

2. Flash 8

3. AS2

4. Ruby ruby 1.8.6 (Once updated)

5. RubyGems

6. OSX Terminal (I’m using the $ symbol to denote input into the Terminal Window, ie type what’s after the $ glyph).

Tasks

1. Ascertain which version of ruby is installed. In the Terminal type:

$ ruby -v

which for me outputs:

ruby 1.8.2 (2004-12-25) [universal-darwin8.0]

2. Update Ruby. The latest version is

ruby 1.8.6

so if current version is less you need to update. I used the Ruby One-Click Installer for OSX. Downloaded and unpacked in the Terminal, opened a fresh Terminal window and typed in the Terminal:

$ ruby -v

The output is now:

ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]

3. Install RubyGems.

Down load and unpack. ( I put the ‘rubygems-1.2.0′ folder in Applications.)

4. Install Rails.
In the Terminal Window:

$ sudo gem install rail

Enter password if prompted. My Terminal output was:

Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find rails (> 0) in any repository

(I’m not 100% sure if everything was OK here, or if this step was necessary, so I’ll have to make some further investigations.)

5. Install the sprout gem. Enter in the terminal:

$ sudo gem install sprout

The Terminal Output was:

Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (universal-darwin8.0)
1. sprout 0.7.183 (ruby)
2. sprout 0.7.183 (darwin)
3. sprout 0.7.183 (mswin32)
4. sprout 0.7.183 (x86-linux)
5. Skip this gem
6. Cancel installation

Just guessing entered:

$ 1

A whole load of other options followed such as:

Install required dependency rubyzip? [Yn]

I entered Y for all of them.

Various outputs followed for example:

Successfully installed sprout-0.7.183
Successfully installed rubyzip-0.9.1
Successfully installed archive-tar-minitar-0.5.2
Successfully installed rails-2.1.0
Successfully installed rake-0.8.1
……

So I assumed the correct applications have been successfully installed.

6. Instructions for downloading the Sprouts AS2 Bundle see: ActionScript 2.0 Bundle

For example in the Terminal

cd

to an appropriate folder and enter:

$ sprout -n as2 SomeProject

7. Launch Rake

$ rake

Had some problems tried, output:

rake aborted!
no such file to load — open4

I was getting a message:

sudo gem install open4

8. Sort out Rake problem
Found some advice here: projectsprouts

Enter in the Terminal:

$ sudo gem install open4

Then after a whole load of output:

sudo gem install rb-appscript

9. Launch Rake again

$ rake

After another string of output, the Flash Player launched with the png of the Sprout logo!

Picture 1.png

Conclusion:

The project first aim …compile AS2 Flash to a swf… has been realised, I’ll create further posts to detail further experiments.

Using XTrace and the dubug Class with a Logger Class

June 25, 2008

This post details a further experiment in improving Flash tracing using XTrace.

See my previous post: XTrace, MTASC and TextMate

This project uses:

1. Mac OSX.

2. Flash 8

3. AS2

My aims for this project are:

1. Use XTrace from the Flash IDE.

2. Improve upon the Trace Output, specially the annoying [object Object]

3. Not rely on using other tools like FlashTracer to see trace Trace Output whilst viewing Flash content in a Browser.

Preamble:

The normal Flash Trace will be output something like:

videoChoiceRelease: [object Object],

whilst what we would prefer would be something like:

videoChoiceRelease: {”id”:”building_futures.flv”,”position”:0,”target”:null,”type”:”videoChoice”}

Whilst working for a project for the now defunct BBC Jam our team used a bespoke Logger Class which had a handy way of outputting an object in more detail than Flash’s IDE somewhat like the second output above.

This Class used a method stringify(arg) from the JSON Class to serialize an Object.

I didn’t notice until after I started the project when I viewed a XTrace tutorial that there was a pre-existing method in the debug Class, dumpObject(). Which would output using the same example as above:

{
url:undefined
id:building_futures.flv
position:0
target:_level0.asset_vnv_mc.bgd.videoCarousel
type:videoChoice
}

The trace: target:_level0.asset_vnv_mc.bgd.videoCarousel is an improvement on: “target”:null, but I’ll have to come back to that later.

Project:

The project incorporates the use of 3 new Classes: JSON, debug and Logger.

1. Download the JSON Class. I placed the Class in its own Package: com.designvox.serialisation.json and changed the Class line to: class com.designvox.serialisation.json.JSON.

2. Download the debug Class and XTrace, if you have not already done so.

3. Create new Class Logger into Package: com.factornine.shared.utilities .

class com.factornine.shared.utilities.Logger {

	/*
	 * Constructor should not be called
	 */
	private function Logger(){ throw new Error("Logger should not be instantiated"); }

	/*
	 * @method log
	 * Static Method for Callee to trace via the XTrace window
	 *
	 * @param message (String) Message to be traced
	 * @param payload (Object) Optional Object - serialized by JSON Class
	 *
	 */
	public static function log(message:String, payload:Object)	: Void{

		if (typeof(payload) == "movieclip")
				{
					message += ": " + payload;
				}
				else
				{
					message = (payload != undefined) ? message + ": " + JSON.stringify(payload) : message;
				}

		debug.trace(message);

	}
}

4. Add a method call in Class where you want to replace the standard Flash trace() .
See my example:

	private function videoChoiceRelease(event : IDEvent) : Void {

		// trace("videoChoiceRelease "+event); // previous call

		Logger.log("Application.videoChoiceRelease", event);
		}

5. Launch the XTrace application.

6. Test Movie.

Which should resulted in something like the following:

Picture 3.png

Conclusion:

I’m pretty happy that I’ve got a more helpful Trace output, which also works in Firefox and Safari.

More To do:

1. Look further into using the set up with MTASC.

2. See what happens in AS3.

3. See PC alternatives.

4. Have the option to use the rather dumpObject(obj) than the stringify(arg) method.

RUBY

June 20, 2008

I was having a little time on my hands and I thought I would try looking at Ruby.

Ruby is installed with OSX.

(I’ll post these links and information and tidy and format them up later. )

I’ve used the dollar sign $ to indicate the following text is to be entered into the Terminal window.

Links:

See: guide

download

introduction

expansion pack:

How To Install Ruby on OS X

Ruby One-Click Installer for OSX

1. Download Ruby and place in Applications folder

2. Open the terminal

3. Launch Ruby and see prompt:

$ irb –simple-prompt

>>

4. To create a Hello World application

I created a new folder - ruby in my Workspace

Created the following in a textfile:

puts “Hello World”

saved as hello.rb in the ruby folder.

in the Terminal window:

$ cd to workspace/ruby

$ ruby hello.rb

And Voila:

“Hello World”

appears in the terminal window!

5. To make make executable:

add:

#!

(pronounced “sharp bang”) to the first line of the HelloWorld file

to make:

#! /usr/bin/ruby

puts “Hello World”

6. The file needs to be ‘modified’ before the app can run:

$ chmod +x hello.rb

( And ./ has to precede the fie name. )

$ ./hello.rb

The Terminal outputs:

“Hello World”

6. EXAMPLES OF RUBY COMMANDS:

$ ri

can give you information about a class.

TextMate

June 20, 2008

I occasionally us TextMate as an alternative to Eclipse.

It’s a Mac OSX only text editor with plenty of extra features. I’ve used is ability to compile with MTASC with some success, see my post ‘XTRACE, MTASC and TextMate‘.

I found a useful Cheat Sheet provided by grayskies.net.

Also, G Design’s 2 Page Cheat Sheet is excellent.

The TextMate online manual provides a useful key for the Glyphs used in the Cheat Sheets.

XTRACE, MTASC and TextMate

June 18, 2008

Generally I use FDT to create my Flash projects, but have just trashed my Java paths and am unable to use Eclipse. So I thought I would have a go at using TextMate to create a Flash project and see if I can compile with MTASC, rather than using the slow Flash IDE and use XTrace, rather than the Flash Output. Also, if possible preview the swf in a browser with the Trace active.

I’ll try and keep this post brief and if necessary create new posts if certain points need more clarification.

The Monaki site explains how to set up TextMate, MTASC and XTrace to build Flash projects in Mac OSX.

(I won’t detail setting up the Main entry point the Application Class, or detail the structure of my project here.)

I installed the XTrace app and the com/mab/util/debug Class as described, but was unable to get the ‘build.sh’ or ‘runScript.sh’ to work. So, I switched to using TextMate to create the necessary MTASC files.

From the TextMate Menu Select: - Bundles - ActionScript - MTASC - Install MTASC Support Files.
This creates a file called ‘mtasc.yaml’. For a definition of yaml see the wikipedia entry). This will create a default file that MTASC uses. First step is to change these parameters from:

# Name of your output file:
swf: myApplication.swf

# Name of your main class:
app: myClass.as

to reflect the structure of your project (in my case):

# Name of your output file:
swf: bin/textMateTest_2.swf

# Name of your main class:
app: Application.as

To use xTrace simply un-comment the following line
#trace: xtrace

to:

trace: xtrace

Also if you change the preview line in the yaml file the to the path of the export html path:

preview: bin/textMateTest_2.html

The Flash file is previewed in a browser and the trace outputs to the XTrace application.

There are a few issues to sort out and document regarding the project:

1. I removed the com.mab.util.debug folder and the XTrace still worked.
2. I could not move the Application Class from the top level of the project.
3. I would really like to use XTrace with FDT, and MTASC.
4. I tested an application using a Flash library asset and it worked. (That is the application was able to attach a named MovieClip.

Setting up SVN with Mac OSX

May 23, 2008

How to set up and use Subversion in OSX.

0. I neglected to post how to install Subversion see: How to Install Subversion on Mac OS X.

1. Open the Terminal: Applications -> Terminal

2.Set the correct path in the Terminal window:

export PATH=$PATH:/usr/local/bin

3. Test by entering

svn

in Terminal window. Output should be something like:

Type ’svn help’ for usage

. If the path is correct.
Otherwise it will be:

-bash: svn: command not found

4. Create a repository by adding;

svnadmin create /Volumes/MainBackUp/svn/monopoly

Which creates the files necessary for Subversion.
5. Initial import:

svn import -m “Initial import.” /Users/russell/Documents/workspace/MONOPOLY
file:///Volumes/MainBackUp/svn/monopoly

6. Checking Out A Working Copy
Navigate to correct folder by eg:

cd /Users/russell/Desktop/test

GENERAL COMMANDS

Navigate to correct folder for the following commands:
svn status (Gives overview of changes, use to check folder is working copy)

svn commit NewClass.as –m “New Class committed”

(Commits new file with log message)

svn add AnotherClass.as

(Adds, new file to Subversion)

Terminal Outputs: A AnotherClass.as

svn status –verbose

(gives detailed information of each file and its revision number, will show ‘mixed revisions’)

svn log

(Shows log messages)

svn move oldfilename newfilename

(Replaces old with new filename)

svn mkdi

r (Makes a new directory)

svn delete StateVieo.a

s (Deletes file)

Terminal Outputs:

D StateVieo.as

svn delete –force StateVieo.as

(If above method fails this will force the deletion)

svn rm State.as

(Removes file from Subversion)

svn update –-revision 14

(Updates to specific revision number)

svn list file:///Volumes/MainBackUp/svn/GOF_VIDEO_2

(Lists top level files/ folders in chosen path) Outputs:

.as2_classpath
.classpath
.project
.settings/
assets/
src/

svn list file:///Volumes/MainBackUp/svn/GOF_VIDEO_2/assets -R

(-R Stands for Recursive – will lists all level files/ folders within chosen path)

Outputs:

test/
test/newTest.txt
video/
video/ClearExternalAll.swf
video/video_state.swf
video/video_working.swf

Best Tools

May 5, 2008

As I’ve been working all-over the place at the moment, I’m making a list of a useful freeware and applications I find essential for my work so i can find the links without any fuss.

MAC OSX

Free Ruler

marsEdit 2 blog editor

Eclipse Download

FDT 3.0 the greatest actionscript tool.

Also here’s a big list of top-100-mac-apps.