AS3 Class?

Q&A about the latest versions
Post Reply
WBSKI
Posts: 6
Joined: Sat Dec 22, 2007 9:38 pm

Hey, I am trying out your Pano2VR software and want to integrate some panoramas into an AS3 Flash file. The code works fine when it is not in a packaged class, but when I put it in the class, I get a whole bunch of errors. Here is my current code:

Code: Select all

package com.vs.pano{
	import flash.display.*;
	import flash.net.URLRequest;
	import flash.events.Event;
	var loader:Loader;
	var urlReq:URLRequest
	var vr:MovieClip;
	class pano  {
		
		loader = new Loader();
		var url:String = "data/1/pan/base.swf";
		urlReq = new URLRequest(url);
		
		// This is done after the swf is loaded.
		function finished_loading(e:Event) {
		}
		function initHandler(event:Event):void {
			trace("initHandler: " + event);
			vr = MovieClip(loader.content);// cast 'DisplayObject' to 'MovieClip'
			vr.pano.setWindowSize(200,100);
		}
		// Tell the loader to call 'finished_loading' after the swf is loaded.
		loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
		loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
		loader.load(urlReq);
		addChild(loader);// add your swf directly to the stage
		
	}
}
I have used your Pano2QTVR for many years and will likely buy this software if I can get this class working.
WBSKI
Posts: 6
Joined: Sat Dec 22, 2007 9:38 pm

I figured it out. Here is a working AS3 basic panorama class:

Code: Select all

package com.vs.pano{
	import flash.display.*;
	import flash.net.URLRequest;
	import flash.events.Event;

	public class pano extends MovieClip {

		public function pano() {
			var loader:Loader;
			loader = new Loader();
			var url:String = "URL HERE";
			var urlReq:URLRequest = new URLRequest(url);
			var vr:MovieClip;
			// This is done after the swf is loaded.
			function finished_loading(e:Event) {
			}
			function initHandler(event:Event):void {
				trace("initHandler: " + event);
				vr = MovieClip(loader.content);// cast 'DisplayObject' to 'MovieClip'
				vr.pano.setWindowSize(200,100);
			}
			// Tell the loader to call 'finished_loading' after the swf is loaded.
			loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
			loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
			loader.load(urlReq);
			addChild(loader);// add your swf directly to the stage
		}
	}
}
Just change the package location and the url.
User avatar
360Texas
Moderator
Posts: 3684
Joined: Sat Sep 09, 2006 6:06 pm
Location: Fort Worth, Texas USA
Contact:

Hello WBSIK. While I am forum moderator, I am not AS3 proficient...

I thank you for your effort.
Dave
Pano2VR Forum Global Moderator
Image
Visit 360texas.com
Post Reply