Hi guys
I am developing a mobile application for the new Nokia N95 but i am having some problems. This is Flash Lite 2.0 by the way.
I want to use the softkeys to unload movieclips so that i can go back.
I have for instance, 2 classes
This is my infoClass. As you can see i am sending a _root.container_mc to my softKeyClass’s constructor. This is all good and works fine.
class infoClass extends MovieClip {
private var container_mc:MovieClip;
public function infoClass() {
softKeys();
trace("constructor is running");
}
public function softKeys() {
var mySoftKey:softKeyClass = new softKeyClass(_root.container_mc);
}
}
But, then i wants put that into my softkeys and this is where it goes bad. I know that i am out of my scope becuase i am in the object.
class softKeyClass extends MovieClip {
private var _target_mc:MovieClip;
private var test_btn:Button;
private var info_mc:MovieClip;
public function softKeyClass(target_mc:MovieClip) {
_target_mc = target_mc;
trace(target_mc +" target_mc");
trace(_target_mc + " _target_mc");
fscommand2 ("SetSoftKeys", "quit", "send");
fscommand2 ("FullScreen", true);
var myListener:Object = new Object ();
myListener.onKeyDown = function () {
if (Key.getCode () == ExtendedKey.SOFT1) {
// Handle left soft keypress event.
//_root.target_mc.unloadMovie();
trace("left soft key");
}
else if (Key.getCode () == ExtendedKey.SOFT2) {
// Handle right soft keypress event.
_target_mc.unloadMovie();
trace("right soft key");
}
}
Key.addListener (myListener);
}
}
I thought to my self, why not use the delegate class, but i cant get it to work. Is there anyone who can help me out?
This is what i tried with the delegate class.
import mx.utils.Delegate;
class softKeyClass extends MovieClip {
private var _target_mc:MovieClip;
private var test_btn:Button;
private var info_mc:MovieClip;
public function softKeyClass(target_mc:MovieClip) {
_target_mc = target_mc;
trace(target_mc +" target_mc");
trace(_target_mc + " _target_mc");
fscommand2 ("SetSoftKeys", "quit", "send");
fscommand2 ("FullScreen", true);
//Key.addListener(Delegate.create("onKeydown", this, getKey));
var myListener:Object = new Object ();
myListener.onKeyDown = Delegate.create(this, getKey);
}
private function getKey() {
if (Key.getCode () == ExtendedKey.SOFT1) {
// Handle left soft keypress event.
//_root.target_mc.unloadMovie();
trace("left soft key");
}
else if (Key.getCode () == ExtendedKey.SOFT2) {
// Handle right soft keypress event.
_target_mc.unloadMovie();
trace(_class._target_mc + " med parent");
trace("right soft key");
}
Key.addListener (myListener);
}
}
I am sorry for my bad English, i hope you guys understand what i am trying to do.
/Morten