Custom Layers

I've been experimenting with creating custom layers (additional interactive SWF content) and I seem to be missing something.

As a simple exercise, I started with the UserInterface AS code and thought I could use that framework to simply stuff static content onto the stage.

I removed a few things from the code that weren't applicable and it compiles fine - but nothing happens with it when added as a layer to PS. Even if I add in a trace statement - I get nothing out of it.

I'm looking for Zephyr's BroadcastEvent events to confirm that all the layers are loaded and that everything has been added to the stage, but it's like that swf is never even executing at all.

If I pull that same code directly into frame 1 within a Flash movie and test it - the code I added works fine in itself, with the big difference being that I pulled out the listeners for the stage ready / layers loaded events since it wouldn't have any visibility to the BroadcastEvents from Zephyr's class when running independently within Flash...

Now, to try to confirm that I wasn't doing something very wrong, I tried loading in the cursor.swf file that was part of the rev93 example - and the same thing happens - nothing. No errors, no traces, PS just continues on as if that layer were ignored.

I then tried to re-compile the AS3 code for the cursor example and although it compiles fine, I get the following error everytime PS loads: TypeError: Error #1007: Instantiation attempted on a non-constructor.
at Cursor()

Now, to minimize variables and make sure that I hadn't totally lost it, I added a simple animated SWF movie that did nothing but loop some graphics on the timeline. When I add that as a layer, it works fine - so clearly, there's something going on in the AS3 code for the others...

Now for the questions:
1) Why doesn't the original cursor code work? It seems to me that something is being treated like a variable that isn't... but I can't find it.
2) I'm simply following suit with how UserInterface does things - ie checking to make sure that the ok is given that everything's been parsed, all the layers are loaded, and PS is happy before trying to do anything... Is there something else I should be doing in addition to that?
3) Is this the basic outline for any added "layers" (pseudocode)?:

package
{

import the usual stuff and any components...

public class someName extends MovieClip (or Sprite for FLEX)
{

declare variables for graphical assets that have been added to the Flash library with linkage names (or EMBED them from the appropriate path), PS classes and objects (like UserInterface uses), tweening, etc

public function someName()
{
instantiate the graphical assets, filters, visibility, location, etc - add them to the stage using this.addChild()...
activate a listener to wait for PS using this.addEventListener(Event.ADDED_TO_STAGE, stageReady, etc)
}

private function stageReady(e:Event):void
{
set visibility / tweens for graphical content so it becomes visible and active...
set any listeners for interaction
remove the ADDED_TO_STAGE listener...
}

other private functions for interactivity responses, etc
}
}

I've even tried adding this line to the layersReady method in the UserInterface build just trying to "grab straws"...
newLayerContent = layerByName["someName"];

...and by the way, "someName" is also the name used as the id identifier for this layer in the XML file for PS.

What am I missing here?

re: Custom layers in PanoSalado

Hey DJ:

djsegler wrote:

I removed a few things from the code that weren't applicable and it compiles fine

The above is probably where the issue is... Without seeing a live example, or the entire package/AS code, I'm not sure what to tell you.

--
Regarding Cursor.as: Yes, we're aware that it has issues. This cropped up somewhere between revision ca. 80 and now, but it isn't extremely high on the priority list as far as fixing goes.

Cheers,

Patrick

__________________

Patrick Cheatham
FlashPanos.com creator, Panoramic Photographer
Got PanoSalado?

OK - that's fair. ;^) Here's

OK - that's fair. ;^)

Here's the code I'm presently using...

package
{
import flash.display.*;
import flash.events.*;
import flash.utils.Dictionary;
import flash.system.ApplicationDomain;
import zephyr.BroadcastEvent;
import flash.text.*
import com.afcomponents.tooltip.Tooltip;
import com.afcomponents.common.transitions.*;
import com.afcomponents.tooltip.ContentType;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;
       
import flash.display.Loader;

import flash.utils.Timer;

        public class LogoLoader extends MovieClip
        {
       

                public var Logo1:Class;
                public var Logo2:Class;
                       
                private var PanoSalado:Class;
                private var ModuleLoader:Class;
                private var ViewportBaseLayer:Class;
                private var BulkLoader:Class;
                private var BulkProgressEvent:Class;
                private var TweenLite:Class;
                private var DisplayObject3D:Class;
                private var InteractiveScene3DEvent:Class;
                private var Viewport3D:Class;
                private var BroadcastEvent:Class;
               
                private var layerByName:Dictionary;
                private var panoSalado:Object;
                private var moduleLoader:Object;
                private var theNavigation:Object;
                private var theCursor:Object;
                private var theLogos:Object;
               
                private var settings:XML;
       
                private var TweenLiteTo:Function;
       
                private var timer:Timer = new Timer(2000, 1);
       
                private var myTooltip = new Tooltip();
                private var logo1_toolTip:String = "some stuff";
                private var logo2_toolTip:String = "some other stuff";

                private var logo1:Logo1;
                private var logo2:Logo2;

                private var myTooltip = new Tooltip();

                public function LogoLoader()
                {
                        logo1 = new Logo1;
                        logo2 = new Logo2;
                        logo1.alpha = 0;
                        logo2.alpha = 0;
                        logo1.buttonMode = true;
                        logo2.buttonMode = true;
                       
                        logo1.x = 125;
                        logo1.y = stage.stageHeight-75;
                       
                        logo2.x = stage.stageWidth - 100;
                        logo2.y = stage.stageHeight-75;
                       
                        //Create the gradient style
                        var gradientDefault:Object = new Object;
                        gradientDefault.fillType = "linear";
                        gradientDefault.colors = [0x0000FFFF, 0x0000FF55];
                        gradientDefault.ratios = [0, 255];
                        gradientDefault.alpha = 0.5;
                        gradientDefault.matrix = new flash.geom.Matrix();
                        gradientDefault.matrix.createGradientBox(100, 50, (Math.PI * 3 / 2), 0, 0);
                       
                        //Tooltip Settings
            myTooltip.autoShow = false;
                        myTooltip.delay = {enabled: false, show:0, hide:0};
                        myTooltip.tailStyle = {enabled: true, width: 10, height: 25, offset: 20, position: "bottom"};
                        myTooltip.shapeStyle = {fill:true, fillColor:0x0000FF, stroke:false, strokeColor:0x0000FF, strokeThickness: 2, cornerRadius: 5};
                        //Create a custom drop shadow here
                        var myFilter = new DropShadowFilter(5, 45, 0x000000, .75, 5, 5, 1, 1, false, false, false);
                        myTooltip.filters = [myFilter]
                        //
                        myTooltip.transition = new Blur();
                        myTooltip.dragBounds = {enabled: false, global: false, x:0, width:100, y:0, height:100};
                        myTooltip.contentStyle = {textColor: 0xFFFFFF, textFont: "courier", textEmbed: false, textSize: 12, textHTML: true, textAlign: "left", horizontalPadding: 5, verticalPadding: 5, autoSize: true, scaleContent: false, maintainAspectRatio: false};
                        myTooltip.type = ContentType.TEXT;
                        myTooltip.shapeStyle.fillGradient = gradientDefault;

                       
                        //Add logos to the stage...
                        this.addChild(logo1);
                        this.addChild(logo2);
                       
                        //we create a new instance of the tooltip
                        this.addChild(myTooltip);
                       
                        this.addEventListener(Event.ADDED_TO_STAGE, stageReady, false, 0, true);
                }
                       
                private function stageReady(e:Event):void
                {
//                      BroadcastEvent = ApplicationDomain.currentDomain.getDefinition("zephyr.BroadcastEvent") as Class;
                       
//                      parent.addEventListener(BroadcastEvent.ALL_LAYERS_LOADED, layersReady, false, 0, true);
                       
//                      settings = parent["xmlByName"]["Logos"];

                        TweenLiteTo = TweenLite["to"];
                               

                        //Fade in logos...
                        TweenLiteTo(logo1, 1.0, { alpha:0.7 } );
                        TweenLiteTo(logo2, 1.0, { alpha:0.7 } );
               
                        //Add listeners to logos on stage...
                        logo1.addEventListener(MouseEvent.MOUSE_OVER, logo1_Over);
                        logo1.addEventListener(MouseEvent.MOUSE_OUT, logo1_Out);
                        logo1.addEventListener(MouseEvent.CLICK, logo1_Click);
                        logo2.addEventListener(MouseEvent.MOUSE_OVER, logo2_Over);
                        logo2.addEventListener(MouseEvent.MOUSE_OUT, logo2_Out);
                        logo2.addEventListener(MouseEvent.CLICK, logo2_Click);
                       
                        this.removeEventListener(Event.ADDED_TO_STAGE, stageReady);
                       
                }
                       
                private function layersReady(e:Event):void
                {
                               
                        PanoSalado = ApplicationDomain.currentDomain.getDefinition("PanoSalado") as Class;
                        ModuleLoader = ApplicationDomain.currentDomain.getDefinition("ModuleLoader") as Class;
                        ViewportBaseLayer = ApplicationDomain.currentDomain.getDefinition("org.papervision3d.view.layer.ViewportBaseLayer") as Class;
                       
                        parent.removeEventListener(BroadcastEvent.ALL_LAYERS_LOADED, layersReady);
                       
                        layerByName = Dictionary( parent["layerByName"] );
                        panoSalado = PanoSalado( layerByName["PanoSalado"] );
                        theNavigation = layerByName["Interface"];
                        theCursor = layerByName["Cursor"];
                        theLogos = layerByName["Logos"];
                        moduleLoader = ModuleLoader( parent );
                       
                       
                        TweenLiteTo = TweenLite["to"];
                               

                        //Fade in logos...
                        TweenLiteTo(logo1, 1.0, { alpha:0.7 } );
                        TweenLiteTo(logo2, 1.0, { alpha:0.7 } );
               
                        //Add listeners to logos on stage...
                        logo1.addEventListener(MouseEvent.MOUSE_OVER, logo1_Over);
                        logo1.addEventListener(MouseEvent.MOUSE_OUT, logo1_Out);
                        logo1.addEventListener(MouseEvent.CLICK, logo1_Click);
                        logo2.addEventListener(MouseEvent.MOUSE_OVER, logo2_Over);
                        logo2.addEventListener(MouseEvent.MOUSE_OUT, logo2_Out);
                        logo2.addEventListener(MouseEvent.CLICK, logo2_Click);
               
                        // clean up after ourselves
                        parent.removeEventListener(BroadcastEvent.ALL_LAYERS_LOADED, layersReady);
                       
                }
                       
                private function logo1_Over(event:MouseEvent):void {
                        TweenLiteTo(logo1, 1.0, { alpha:1 } );
                        myTooltip.content = logo1_toolTip;
                        myTooltip.show();
                }
               
                private function logo1_Out(event:MouseEvent):void {
                        TweenLiteTo(logo1, 1.0, { alpha:0.7 } );
                        myTooltip.hide();
                }
               
                private function logo1_Click(event:MouseEvent):void {
                        // some action
                }
               
                private function logo2_Over(event:MouseEvent):void {
                        TweenLiteTo(logo1, 1.0, { alpha:1 } );
                        myTooltip.content = logo2_toolTip;
                        myTooltip.show();
                }
                       
                private function logo2_Out(event:MouseEvent):void {
                        TweenLiteTo(logo1, 1.0, { alpha:0.7 } );
                        myTooltip.hide();
                }
               
                private function logo2_Click(event:MouseEvent):void {
                        // some action
                }
        }
}

I have the logos loaded into my library in my FLA file and their AS linkage settings are setup to match this code as usual...

Also - the layer in my XML file has an id of "Logos" and points to this SWF file...

It should be obvious what I've changed since I've only commented things out... If I re-enable the ALL_LAYERS_LOADED event, then I start to get other errors... Just don't have a grasp on all the handshakes yet to find what I'm doing wrong...

What am I missing?