View unanswered posts | View active topics


Reply to topic  [ 12 posts ] 
[resolved] attachMovie doesn't work (wrong Player in FD) 
Author Message
Member

Joined: Tue Jan 10, 2006 3:59 pm
Posts: 43
Location: Paris, France
Post [resolved] attachMovie doesn't work (wrong Player in FD)
Hi everybody,

i'm struggling with this :

Code:
class Main
{
   public static function main()
   {
      var main:MovieClip = _root.attachMovie("Main", "main", 0);
      trace(String(main)); // traces: _level0.main
      
      var to:MovieClip = main.attachMovie("To", "to", 1);
      trace(to +" [" +(typeof(to)) +"]");
      // if MovieClip "Main" is linked to a class
      //   -> traces:  [undefined] (the MovieClip does not appear)
      // else
      //   -> traces: _level0.main.to (the MovieClip is correctly displayed on screen)
   }
}


the class i use to link my "Main" symbol extends MovieClip.
i tried to link it with Object.registerClass and via the Flash IDE.
obviously, this is working fine within Flash IDE.

thanks for helping :)


Last edited by flip3r on Tue Jan 31, 2006 12:23 am, edited 2 times in total.



Sat Jan 28, 2006 9:48 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10726
Location: Paris, France
Post 
There is a direct solution to your problem:
Creating a class instance based on MovieClip without a symbol in the library

Alternatively, you can use the __proto__ solution


Sun Jan 29, 2006 12:06 am
Profile WWW
Member

Joined: Thu Jan 12, 2006 3:17 pm
Posts: 23
Location: Spain/ France
Post 
in your Main.as

/**
* Test class for testing mtasc swf building in FlashDevelop.
* @mtasc -version 8 -swf build.swf -trace SOSTracer.out -main -trust
*/
import com.blitzagency.xray.util.XrayLoader;
import net.arp.test.view.*;

class Main extends MovieClip
{
public function Main(target)
{
target.__proto__ = this.__proto__;
target.__constructor__ = Application;
this = target;

trace("Main::constructor");

// --- XRAY
var listener:Object = new Object();
listener.xrayLoadComplete = function(){
_global.tt("Everything is ready");
}
XrayLoader.addEventListener("xrayLoadComplete", listener);
XrayLoader.loadConnector("ConnectorOnly_as2_fp7_OS_1.4.5.swf", _root, true);

var app = Application(attachMovie(Application.id,"application", 1));
}

static function main ()
{
// Create an Application instance and have it assimilate _root.
SOSTracer.start(0xFFFFCC);
var test:Main = new Main( _root );
}
}


in your subclass MovieClip:

class Application extends org.osflash.arp.ArpForm // extends MovieClip
{
static var id = (id="__Packages.net.arp.test.view.Application")+(Object.registerClass(id,Application)?"":"");

function Application (target)
{
trace("Application::constructor");
}

function onLoad(){
trace("Application::onLoad");
}

}

Maybe the example seems a little overloaded but hope you can get an overall idea of the trick ;)

Mike.


Sun Jan 29, 2006 11:14 am
Profile
Member

Joined: Tue Jan 10, 2006 3:59 pm
Posts: 43
Location: Paris, France
Post 
well i tried these methods but it seems that i have a problem with the inheritance of MovieClip...

Code:
var main = _root.attachMovie(MainMC.id, "main", 0); // outputs: i am the main MovieClip
trace(main +" [" +(typeof(main)) +"]"); // outputs: _level0.main [movieclip]
trace(main instanceof Object);          // outputs: true
trace(main instanceof MovieClip);       // outputs: false
trace(main instanceof MainMC);          // outputs: true

where

Code:
class MainMC extends MovieClip
{
   static var id = (id="__Packages.MainMC")
   +(Object.registerClass(id, MainMC) ? "" : "");
   
   function MainMC()
   {
      trace("i am the main MovieClip");
   }
}


then attachMovie method does not exist (and so does not work) in the "main" object, which gives the result i mentionned in my first post...


Sun Jan 29, 2006 6:35 pm
Profile WWW
Member

Joined: Tue Jan 10, 2006 3:59 pm
Posts: 43
Location: Paris, France
Post 
i don't understand why but my MainMC class just extends Object while i declare it to extend MovieClip...

Code:
trace(main.__proto__.__proto__.constructor == Object); // returns true


Sun Jan 29, 2006 8:28 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10726
Location: Paris, France
Post 
all classes eventually extend Object


Sun Jan 29, 2006 8:34 pm
Profile WWW
Member

Joined: Tue Jan 10, 2006 3:59 pm
Posts: 43
Location: Paris, France
Post 
yes but when i declare
Code:
class MainMC extends MovieClip

i'd like to have this :
MainMC :arrow: MovieClip :arrow: Object

and not :
MainMC :arrow: Object
...


Sun Jan 29, 2006 8:59 pm
Profile WWW
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10726
Location: Paris, France
Post 
That's really weird, I agree it's not the expected result. It looks like the "extends MovieClip" was ignored...
Maybe you should ask the MTASC list.


Mon Jan 30, 2006 12:49 pm
Profile WWW
Member

Joined: Tue Jan 10, 2006 3:59 pm
Posts: 43
Location: Paris, France
Post 
ok i found something coming from FlashDevelop.

i tried to compile only with mtasc and it worked fine.
Actually it was working since the beginning but with the correct player :
i was using Flash Player 8 version for my project, while when testing on FlashDev, it runs a Flash Player 6 !
and i was having the problems i described in this topic.
but in the external Flash Player 8 : no problems.

now if i declare my project as version 6, it works correctly.
and in version 7 or 8 : still buggy, Flash Player 6 cannot play it well.

so now i'd like to have Flash Player 8 in my FlashDevelop. can i do it ?


Tue Jan 31, 2006 12:02 am
Profile WWW
Member

Joined: Tue Jan 10, 2006 3:59 pm
Posts: 43
Location: Paris, France
Post 
ok got it ! :)
that's IE Flash Player that runs in FlashDev.


Tue Jan 31, 2006 12:21 am
Profile WWW
Admin

Joined: Thu Sep 01, 2005 4:34 pm
Posts: 240
Location: Portland, OR
Post 
Yep, FlashDevelop uses the IE ActiveX control so it's tied to that player version. Glad this mystery is solved :D


Tue Jan 31, 2006 12:54 am
Profile WWW
Member

Joined: Tue Jan 10, 2006 3:59 pm
Posts: 43
Location: Paris, France
Post 
he he thank you Nick :D


Tue Jan 31, 2006 1:05 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.