I should give a quick explanation of what the mechanism is for the new
<passthrough> tag, which is required for accessing as3 classes in
other packages.

When you have a method in a view or class in lzx, and you compile to
swf9, the compiler
produces an intermediate as3 class file, which might look like this

<view>
  <method name="mymethod">
  ...
  </method>

compiles to a file $lzc$class_$m57.as:

 package {
 dynamic class $lzc$class_$m57 extends LzView {....
     function mymethod() {
      ....
     }



If your method code tries to refer to as3 classes in other packages,
you need an as3 "import" statement. For example, if you want to access
something in the flash.geom package, you would need the file to
contain

package {
  import flash.geom.*;
  dynamic class $lzc$class_$m57 extends LzView {....

   function mymethod() {
      return new Point(10,20);
}

The <passthrough> tag in lzx will automatically stick a block of text
right before the class declaration that is emitted. This actually
generates a "#passthrough (toplevel:true) {" block in the intermediate
as3 file that the compiler generates.


So to get the proper import statement(s), put this in your view or
class declaration

<view>
  <passthrough>
     import flash.geom.*;
  </passthrough>
  <method name="mymethod">
     return new Point(10,20);
  </method>
</view>

Remember, the <passthrough> tag operates in the scope of the class or
view that contains it.













On Sat, Nov 8, 2008 at 12:28 PM, Henry Minsky <[EMAIL PROTECTED]> wrote:
> Here's an example of the Google map component running in a LZX <window>
>
> There is a Google discussion group regarding a non-flex Flash map component at
>
> http://groups.google.com/group/google-maps-api-for-flash
>
> They have a library which seems to have remove the dependencies on the
> Flex mx.* framework.
>
> You just need to  download the library map_flash_1_6.swc from
> http://groups.google.com/group/google-maps-api-for-flash/files
> and copy that to WEB-INF/flexlib
>
> then the following code compiles and runs in swf9 runtime and displays
> the map component.
>
>
> <canvas debug="true">
>
>  <script when="immediate"><![CDATA[
>         class FlashMapOL {
>            #passthrough (toplevel: true) {
>            import com.google.maps.*;
>            import flash.geom.*;
>            }#
>
>            var map:Map;
>
>            function createMap() {
>                map = new Map();
>                map.addEventListener(MapEvent.MAP_READY, onMapReady);
>                // Henry's key
>                map.key =
> "ABQIAAAAT-bIcrU96-d2UT9ao4fuQhQeYAb4p95ZEYTsQwGDQ7cOBxduDBQsJj99qzzLWoeHwQer1vjPN0wTNg";
>                map.setSize(new Point(LFCApplication.stage.stageWidth,
> LFCApplication.stage.stageHeight));
>                return map;
>            }
>
>             function onMapReady(event:MapEvent):void {
>                this.map.setCenter(new LatLng(40.736072,-73.992062),
> 14, MapType.NORMAL_MAP_TYPE);
>            }
>
>        }
>
>        var mapfactory = new FlashMapOL();
>        lz.map = mapfactory.createMap();
>
>    ]]>
>    </script>
>
>  <window id="mapwin" width="640" height="480">
>    <passthrough>
>      import flash.display.*;
>    </passthrough>
>    <handler name="oninit">
>      var sprite:Sprite = this.content.sprite
>      sprite.addChildAt(lz.map, sprite.numChildren);
>    </handler>
>  </window>
>
>
>
> </canvas>
>
>
>
>
>
>
>
> --
> Henry Minsky
> Software Architect
> [EMAIL PROTECTED]
>



-- 
Henry Minsky
Software Architect
[EMAIL PROTECTED]

Reply via email to