# Code Behind Problems (building for AIR)

**URL:** <https://forum.kirupa.com/t/code-behind-problems-building-for-air/307886>\
**Category:** flash\
**Created:** [April 12, 2010, 9:33pm UTC](https://forum.kirupa.com/t/code-behind-problems-building-for-air/307886 "2010-04-12T21:33:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sammo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sammo/32/779_2.png) [@Sammo](https://forum.kirupa.com/u/Sammo)\
**Post date:** [April 12, 2010, 9:33pm UTC](https://forum.kirupa.com/t/code-behind-problems-building-for-air/307886/1 "2010-04-12T21:33:25Z")

</div>

I’ve been trying to set up a nice environment on Flex 4 and Flash Builder 4 by using the “code behind” philosophy on my Application tag. This has given me a silly amount of problems!

So working with this:  
[LIST]  
[_]src  
[LIST][_](default package)  
[LIST][_]Test.mxml  
[_]TestBase.as[/LIST]  
[\*]Test-app.xml[/LIST]  
[/LIST]

```auto
// TestBase.as
package {
	import spark.components.WindowedApplication;
	import mx.controls.Alert;
	
	public class TestBase extends WindowedApplication {
		public function TestBase() {
			super();
			
			Alert.show("hello");
		}
	}
}

```

and

```html
<?xml version="1.0" encoding="utf-8"?>
<app:TestBase xmlns:fx="http://ns.adobe.com/mxml/2009" 
					   xmlns:s="library://ns.adobe.com/flex/spark" 
					   xmlns:mx="library://ns.adobe.com/flex/mx"
					   xmlns:app="*">
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
</app:TestBase>

```

Firstly I can’t seem to be able to put either of these two files into a package other than the default one without getting error’s about the -app.xml file.

Secondly, it seems I can’t name my class Test.as, this confuses Flex so I renamed it TestBase.as.

However, once they’ve been renamed and are both in the default package Flex wants an -app.xml file for both of them. So humouring it I created a TestBase-app.xml alongside the already existing Test-app.xml.

Only now does Flash Builder 4 not show any errors in any of the files in my project. So I move to run it and I get an alert with the error:

> If the program is already running, close it before attempting to run.

I [googled](http://www.google.co.uk/search?hl=en&safe=off&client=firefox-a&hs=6x6&rls=org.mozilla%3Aen-GB%3Aofficial&q=%22if+the+program+is+already+running+close+it+before+attempting+to+run%22&meta=&aq=f&aqi=&aql=&oq=&gs_rfai=) this error but got absolutely nothing.

I also found [this](http://casaburmese.com/wordpress/?p=17), thinking it was the solution to my problem but I’m not entirely sure what the solution is.

All I want is to be able to represent the Flex Application as an AS3 class, ideally in my package structure, but I guess that’s not essential.

Anybody know what on earth is going on here?
