Running a program with a package
Can any one tell me if i have saved the following file as test.mxml
If i run the program i get some errors.If we include a class in a package how should the program be run??
package {
import flash.display.Sprite;
开发者_Python百科import flash.media.*;
public class test {
public function Test() {
//alerting some code
}
}
}
You can either have a MXML class that would look something like this Test.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
Alert.show("test");
}
]]>
</fx:Script>
</s:Application>
Or you can have a pure actionscript class that looks like this:
Test.as
package
{
import mx.controls.Alert;
public class Test
{
public function Test()
{
Alert.show("Test");
}
}
}
Your problem might be the lower case "t" of your class name and the upper case "T" of its constructor. Otherwise it's not clear what you are asking.
精彩评论