Re: [Flashcoders] LoaderContext question

2008-03-09 Thread EECOLOR
Within Flex builder I got it working like this:

ITestAS.as
package
{
   public interface ITestAS
   {
  function get testVar():String;
   };
};


TestAS1.as
package
{
   import flash.display.DisplayObjectContainer;
   import flash.display.Loader;
   import flash.display.Sprite;
   import flash.events.Event;
   import flash.net.URLRequest;
   public class TestAS1 extends Sprite
   {
  private var _loader:Loader;
  public function TestAS1()
  {
 _loader = new Loader();
 _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
_loadCompleteHandler);
 _loader.load(new URLRequest(TestAS2.swf));
  }
  private function _loadCompleteHandler(e:Event):void
  {
 var testAS2:ITestAS = ITestAS(_loader.content);
 trace(testAS2.testVar);
  };
   };
};



TestAS2.as
package
{
   import flash.display.Sprite;

   public class TestAS2 extends Sprite implements ITestAS
   {
  public function TestAS2()
  {
  };
  public function get testVar():String
  {
 return hello;
  };
   };
};


I recall vaguely that I once tried this with an swf created in the Flash IDE
and that we needed to get the firstChild. You can use describeType to
navigate to content and its children to see where the class you need is
located.


Greetz Erik



On 3/7/08, Dave Segal [EMAIL PROTECTED] wrote:

 I am getting a type Coercion error. TypeError: Error #1034: Type Coercion
 failed

 Really the whole goal here is to be able to load swfs (from a different
 server) that implement some public api. Then have the loading swf cast the
 loaded swf to that api, so code hints and type checking are available. Are
 there any solutions for this type of thing?

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] LoaderContext question

2008-03-07 Thread Dave Segal
I am getting a type Coercion error. TypeError: Error #1034: Type Coercion
failed

Really the whole goal here is to be able to load swfs (from a different
server) that implement some public api. Then have the loading swf cast the
loaded swf to that api, so code hints and type checking are available. Are
there any solutions for this type of thing?


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andrei
Thomaz
Sent: Thursday, March 06, 2008 7:05 PM
To: Flash Coders List
Subject: Re: [Flashcoders] LoaderContext question

what is the error?

[]'s
andrei


On Thu, Mar 6, 2008 at 8:41 PM, Dave Segal [EMAIL PROTECTED] wrote:

 I need to load an swf from one server that is a member of some class.
For
 example:



 http://server1.mydomain.com/load_me.swf that uses the Document class
 com.mydomain.componet.LoadMe.as.



 I want to be able to load this swf from different server, say
 http://server2.mydomain.com/load_stuff.swf, and cast it to a LoadMe when
 it is done loading. Should this work? I keep getting errors when trying
to
 cast in the init handler.





 import com.mydomain.componet.LoadMe;



 var _req:URLRequest = new
 URLRequest(http://server1.mydomain.com/load_me.swf;);

 var _ldr:Loader = new Loader();

 var _context:LoaderContext = new LoaderContext();

 _context.securityDomain = SecurityDomain.currentDomain;

 _context.applicationDomain = ApplicationDomain.currentDomain;

 _ldr.contentLoaderInfo.addEventListener(Event.INIT, initHandler, false,
0,
 true);

 _ldr.load(_req, _context);





 private function initHandler($event:Event) () {

var _lm:LoadMe = LoadMe(_ldr.content);

 }

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] LoaderContext question

2008-03-06 Thread Andrei Thomaz
what is the error?

[]'s
andrei


On Thu, Mar 6, 2008 at 8:41 PM, Dave Segal [EMAIL PROTECTED] wrote:

 I need to load an swf from one server that is a member of some class. For
 example:



 http://server1.mydomain.com/load_me.swf that uses the Document class
 com.mydomain.componet.LoadMe.as.



 I want to be able to load this swf from different server, say
 http://server2.mydomain.com/load_stuff.swf, and cast it to a LoadMe when
 it is done loading. Should this work? I keep getting errors when trying to
 cast in the init handler.





 import com.mydomain.componet.LoadMe;



 var _req:URLRequest = new
 URLRequest(http://server1.mydomain.com/load_me.swf;);

 var _ldr:Loader = new Loader();

 var _context:LoaderContext = new LoaderContext();

 _context.securityDomain = SecurityDomain.currentDomain;

 _context.applicationDomain = ApplicationDomain.currentDomain;

 _ldr.contentLoaderInfo.addEventListener(Event.INIT, initHandler, false, 0,
 true);

 _ldr.load(_req, _context);





 private function initHandler($event:Event) () {

var _lm:LoadMe = LoadMe(_ldr.content);

 }

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] LoaderContext question

2008-03-06 Thread EECOLOR
From the top of my head, I think it should be:

var _lm:LoadMe = LoadMe(_ldr.content.getChildAt(0));


Greetz Erik


On 3/7/08, Andrei Thomaz [EMAIL PROTECTED] wrote:

 what is the error?

 []'s

 andrei


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders