Doubt in Defining the class.

0 views
Skip to first unread message

Gerald Anto

unread,
Nov 18, 2009, 12:46:19 AM11/18/09
to flex_delhi_india_group
Hello Friends,

Actually i need a class that extends a super class.

Shall i have two classes in a single .as file? if i do like i cant get
a result

but if i have a separate class in a package it works fine

my previous code


package com
{

public class Example
{
public var status:String = "undefined";
public function Example()
{
status = "it has value now";
trace('status in super : '+status);
}

}


public class ExampleEx extends Example
{
public function ExampleEx()
{
//super();
trace('status in subclass : '+super.status);


}

}
}



my application code

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[

import com.*;
import mx.controls.Alert;

private function displayConstructor():void{
var ex:ExampleEx = new ExampleEx();

}
]]>
</mx:Script>


<mx:Button label="click" click="displayConstructor()"/>
</mx:Application>

-- it is not working ?
Is it possible????

now my code

package com
{
public class Example
{
public var status:String = "undefined";
public function Example()
{
status = "it has value now";
trace('status in super : '+status);
}

}

}



package com
{
public class ExampleEx extends Example
{
public function ExampleEx()
{
//super();
trace('status in subclass : '+super.status);


}

}
}

my application code

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[

import com.*;
import mx.controls.Alert;

private function displayConstructor():void{
var ex:ExampleEx = new ExampleEx();

}
]]>
</mx:Script>


<mx:Button label="click" click="displayConstructor()"/>
</mx:Application>

-- It is working fine.

Thanks&Regards,
Gerald A

amit pandey

unread,
Nov 21, 2009, 1:11:57 AM11/21/09
to flex_delhi_india_group
Hi Gerakd,

You need to define both the classes separately.

--Amit
Reply all
Reply to author
Forward
0 new messages