Topic: TiltViewer and Flex 3 ???

Hi there,

I'd like to embed the TiltViewer.swf in a Flex 3 application. Does anyone know how I can do this?

Any advice is welcome and thank you in advance,
masu

Re: TiltViewer and Flex 3 ???

Here is the flex code I have done so far:

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" 
    creationComplete="complete()" 
    > 
    
    <mx:Script> 
        <![CDATA[ 
            import mx.core.UIComponent; 
            
            public function complete() : void 
            { 
                var sprite:TiltViewerSprite = new TiltViewerSprite(); 

                bx_viewer.addChild(sprite); 
            } 
        ]]> 
    </mx:Script> 
    
    <mx:UIComponent
        id="bx_viewer"
        width="100%" height="100%"
        />
    
</mx:Application>
package { 
    import flash.display.Loader ; 
    import flash.display.MovieClip; 
    import flash.display.Sprite; 
    import flash.events.Event; 
    import flash.net.URLRequest; 

    public class TiltViewerSprite extends Sprite 
    { 
        private var movieclip:MovieClip; 
        private var loader:Loader = new Loader(); 

        public function TiltViewerSprite() 
        { 
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete); 
            loader.load(new URLRequest("TiltViewer.swf")); 

            addChild(loader); 
        } 
        
        private function loadComplete(e:Event) : void 
        { 
            movieclip = loader.content as MovieClip; 
            movieclip.width = 640;
            movieclip.height = 480; 
        } 
    } 
} 

Anybody here who can help me out?
masu

Last edited by masu (2009-08-03 13:56:49)

Re: TiltViewer and Flex 3 ???

Sorry the forums just migrated from one application to another.

I have never used flex before, however googling 'embedding a swf in flex' I found at Adobe's Flex 3 help states the following:

You can embed SWF files created for Flash Player 8 and earlier.

http://livedocs.adobe.com/flex/3/html/h … bed_4.html

TiltViewer is Flash 9.0.28+ so that may be your issue, if this is still correct information.

more info on how to embed swf files into flex here:
http://www.adobe.com/cfusion/communitye … stId=12871

Mike Richards
SimpleViewer Support Team.

Re: TiltViewer and Flex 3 ???

Hi Miker,

thank you for your help. I tried to embed the TiltViewer.swf as mentioned in your posted links, but, this also does not work. Here is my code:

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" 
    creationComplete="complete()" 
    > 
    
    <mx:Script> 
        <![CDATA[
            import mx.events.FlexEvent; 
            import mx.core.UIComponent; 
            
            [Embed(source="TiltViewer.swf", mimeType="application/octet-stream")]
            private var swf_tiltviewer:Class;
            private var loader:Loader = new Loader();
            
            public function complete() : void 
            { 
                loader.addEventListener(Event.COMPLETE, onComplete);
                loader.loadBytes(new swf_tiltviewer());
            }
            
            private function onComplete(e:Event) : void
            {
                var mc_tiltviewer:MovieClip = MovieClip( loader.contentLoaderInfo.applicationDomain.getDefinition('swf_tiltviewer') );

                bx_viewer.addChild(mc_tiltviewer); 
            } 
        ]]> 
    </mx:Script> 
    
    <mx:UIComponent
        id="bx_viewer"
        width="100%" height="100%"
        />
    
</mx:Application>

Is there another solution for this issue out there? If not, I can't use the TiltViewer for my current project.

Hopefully trying and waiting,
masu

Last edited by masu (2009-08-06 11:09:13)

Re: TiltViewer and Flex 3 ???

How doesn't it work? You should be able to load TiltViewer the same as any other SWF.

Felix Turner
SimpleViewer Support Team.

Re: TiltViewer and Flex 3 ???

Hi Felix,

thank you for your reply! I also expected that the TiltViewer.swf could be easily included to my flex project, but, when I compile the code the TiltViewer only shows up for a half of a seconds and then simply disappears. Maybe there is an issue with the external Javascript code which is preventing the TiltViewer from showing up!? Here is my HTML/Javascript code:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TiltViewer</title>
<script type="text/javascript" src="swfobject.js"></script>
<style type="text/css">    
    /* hide from ie on mac \*/
    html {
        height: 100%;
        overflow: hidden;
    }
    
    #flashcontent {
        height: 100%;
    }
    /* end hide */

    body {
        height: 100%;
        margin: 0;
        padding: 0;
        background-color: #000000;
        color:#ffffff;
        font-family:sans-serif;
        font-size:40;
    }

    a {    
        color:#cccccc;
    }
</style>
</head>
<body>
    <div id="flashcontent">TiltViewer requires JavaScript and the latest Flash player. <a href="http://www.macromedia.com/go/getflashplayer/">Get Flash here.</a></div>
    <script type="text/javascript">
    
        var fo = new SWFObject("TiltApp.swf", "viewer", "100%", "100%", "9.0.28", "#000000");            
        
        // TILTVIEWER CONFIGURATION OPTIONS
        // To use an option, uncomment it by removing the "//" at the start of the line
        // For a description of config options, go to: 
        // http://www.airtightinteractive.com/projects/tiltviewer/config_options.html
                                                            
        //FLICKR GALLERY OPTIONS
        // To use images from Flickr, uncomment this block
        //fo.addVariable("useFlickr", "true");
        //fo.addVariable("user_id", "48508968@N00");
        //fo.addVariable("tags", "jump,smile");
        //fo.addVariable("tag_mode", "all");
        //fo.addVariable("showTakenByText", "true");            
        
        // XML GALLERY OPTIONS
        // To use local images defined in an XML document, use this block        
        fo.addVariable("useFlickr", "false");
        fo.addVariable("xmlURL", "gallery.xml");
        fo.addVariable("maxJPGSize","640");
        
        //GENERAL OPTIONS        
        fo.addVariable("useReloadButton", "false");
        fo.addVariable("columns", "3");
        fo.addVariable("rows", "3");
        //fo.addVariable("showFlipButton", "true");
        //fo.addVariable("showLinkButton", "true");        
        //fo.addVariable("linkLabel", "View image info");
        //fo.addVariable("frameColor", "0xFF0000");
        //fo.addVariable("backColor", "0xDDDDDD");
        //fo.addVariable("bkgndInnerColor", "0xFF00FF");
        //fo.addVariable("bkgndOuterColor", "0x0000FF");                
        //fo.addVariable("langGoFull", "Go Fullscreen");
        //fo.addVariable("langExitFull", "Exit Fullscreen");
        //fo.addVariable("langAbout", "About");                
        
        // END TILTVIEWER CONFIGURATION OPTIONS
        
        fo.addParam("allowFullScreen","true");
        fo.write("flashcontent");            
    </script>    
</body>
</html>

In any case, I would prefer not to use any Javascript code in Flex projects. Is there any other way to set the TiltViewer variables directly within Flash or Flex?

Hope you can help me out,
masu

Last edited by masu (2009-08-07 14:30:26)