Forums  

Go Back   Forums > Talk > General FPP Discussion

Reply
 
Thread Tools Display Modes
  #11  
Old 06-04-2008, 03:05 AM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Looking at the FLVplayer.fla file, there's some code that looks like it should work for hotspot interaction both ways...

Here it is:

var movie:Sprite;
var hotspot:Object;
var hotspots:Object;

loaderInfo.addEventListener(Event.INIT, initHandler);

function initHandler (event:Event) {
if (loaderInfo.loader!=null) {
// get link to hotspot sprite:
movie = loaderInfo.loader.movie;

// get link to hotspot control object:
hotspot = loaderInfo.loader.hotspot;
// example how to change hotspot's properties:
// hotspot.saturation = -1;
// hotspot.rotation = 45;

// get link to hotspots plugin object:
hotspots = loaderInfo.loader.hotspots;
// example how to use it:
// hotspots.execute("pano.pan=45,1000,elastic;pano.ti lt=30,1200,elastic;");

// add your own event listener:
movie.addEventListener(MouseEvent.CLICK, doClick);

// define remove function (will fire on unload)
loaderInfo.loader.remove = remove;
}
}

In the section near the end titled "add your own event listener", would I just do something like this?:
//First define the actual hotspot object that I want to interact with
spotObject = panorama.externals.hotspots.hotspots_obj.getSpot(" spot_id");
//Then add a listener for the mouse over event for that particular hotspot
spotObject.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
//Then create a function called doSomething
function doSomething(event:MouseEvent){
//action here for whatever I want to have happen
}

What am I missing? Is this all there is to it?

I'll try this next and post my results...
Reply With Quote
  #12  
Old 06-04-2008, 03:28 AM
cheathamlane cheathamlane is offline
Senior Member
 
Join Date: Mar 2007
Location: California, USA
Posts: 773
Downloads: 0
Uploads: 0
Default

hey djsegler:

at this point, how about a FLA or full example of your source? That could be extremely helpful in pinpointing your issue.
__________________
Patrick
http://patrickcheatham.com
Reply With Quote
  #13  
Old 06-04-2008, 04:01 AM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

OK - here's my AS3 code in my FLA file. There not really much of anything on the stage but a border to fit around the pano and there's obviously a movieclip instance for the graphic that I'm wanting to control in the function that results from the hotspot activity. I just want to keep it simple for now...

I cleaned out alot of stuff and commented code fragments that I'm not using. Hopefully, I didn't inadvertantly delete something that was required...

This is basically a merge of the embedPano.fla example and the FLVPlayer.fla file with some of the stuff deleted that I know I don't need...

Thanks for the help!!

Here's all of the code (loaded into an actions layer on frame 1):

import flash.display.Stage;
import flash.display.StageDisplayState;
import flash.display.InteractiveObject.*;
import flash.events.*;
import flash.net.*;
import flash.external.*;
import fl.controls.*;
import fl.controls.ColorPicker;
import fl.data.DataProvider;


var movie:Sprite;
var hotspot:Object;
var hotspots:Object;


var panorama:MovieClip;
var loader:Loader = new Loader();
loader.load(new URLRequest("files/pano0.swf"));
addChild(loader);

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);

function loadComplete (e:Event) {
swapChildren(loader, border);
panorama = loader.content;
panorama.setArea(13,17,660,450);

panorama.loadPanorama("panoName=images/imageName_cube&xml_file=myPanoXMLfile.xml");


loaderInfo.addEventListener(Event.INIT, initHandler);

function initHandler (event:Event) {
if (loaderInfo.loader!=null) {
// get link to hotspot sprite:
movie = loaderInfo.loader.movie;

// get link to hotspot control object:
hotspot = loaderInfo.loader.hotspot;
// example how to change hotspot's properties:
// hotspot.saturation = -1;
// hotspot.rotation = 45;

// get link to hotspots plugin object:
hotspots = loaderInfo.loader.hotspots;
// example how to use it:
// hotspots.execute("pano.pan=45,1000,elastic;pano.ti lt=30,1200,elastic;");

// add your own event listener:
//movie.addEventListener(MouseEvent.CLICK, doClick);

// define remove function (will fire on unload)
loaderInfo.loader.remove = remove;
}
}

//First define the actual hotspot object that I want to interact with
spotObject=panorama.externals.hotspots.hotspots_ob j.getSpot("spot_whatever_ID");
//Then add a listener for the mouse over event for that particular hotspot
spotObject.addEventListener(MouseEvent.MOUSE_OVER, onOverFunction);

//I obviously have a movieclip that contains a graphic of some sort and placed //an instance of it on the stage with an instance name of let's say, //"myGraphicThingy". Here, I've set it's visibility to false.

myGraphicThingy.visible=false

//And here's the function to do something with it after my hotspot event...
function onOverFunction(event:MouseEvent) {
myGraphicThingy.visible=true;
}



What am I doing wrong!?

Thanks SO MUCH for your help!
Reply With Quote
  #14  
Old 06-04-2008, 07:13 AM
AxeCrazy AxeCrazy is offline
Member
 
Join Date: May 2008
Posts: 45
Downloads: 0
Uploads: 0
Default

hotspot = loaderInfo.loader.hotspot;
should be
hotspot = loaderInfo.hotspot.loader;

i think

and the xml file would also bee nice to read..
Reply With Quote
  #15  
Old 06-04-2008, 01:00 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Here's the XML - which has worked great by the way before trying to embed this thing into another FLA movie...

<?xml version = '1.0'?>
<panorama>
<parameters>

panoName = images/image_cube
zoomHome = .6
zoomMin = 0
zoomMax = 2
panHome = 0
tiltHome = -20
friction=.8

segments=20
sensitivity=80
qualityMotion = low
qualityStatic = high
loaderTextColor = #FFFFFF
loaderBackColor = #000000
loaderText =


layer_2 = files/hotspots.swf
layer_4 = files/glassMeter.swf
layer_6 = files/menuFullscreen.swf
layer_8 = files/fps.swf
layer_10 = files/tooltips.swf
<!--layer_8 = files/editor.swf-->


</parameters>

<tooltips>
altFont=Arial
altSize=14
altColor=0x000000
altFill=0xFFFFFF
altStroke=0x999999
altAlpha=0.6
</tooltips>

<hotspots>

<global
onEnterFullscreen="enter.visible=0;exit.visible=1; "
onExitFullscreen="enter.visible=1;exit.visible=0;"


goUp="
pano.qualityStatic=low
saturation=0,300
contrast=.1,300
alpha=1,800
depth=30
static=1
scaleable=0
staticX=0
staticY=0
scale=0.9,400
distance=1
rotationX=0
rotationY=0
rotationZ=0
global.timer=1,1000,-,restoreQuality
"

goDown="
pano.qualityStatic=low
saturation=-0.5,700
alpha=0,500
depth=10
static=1
scaleable=0
scale=.25,300,easyOut
distance=1.5,600
rotationX=0,600
rotationY=0,600
rotationZ=0,600
global.timer=1,500,-,restoreQuality
"

restoreQuality="
pano.qualityStatic=best
">
<!--------------------------------------------------------------->
<!--------------------------------------------------------------->
<!-- Full Screen Buttons -->

<spot id="enter" url="images/fullscreen_enter.png" alt="Click for Full Screen"
static="1" scale="0.5" align="CM" salignX="0.45" salignY="-0.425"
onOver="alpha=0.8,500; scale=.6,1000,elastic"
onOut="alpha=0.3; scale=0.5,1000,elastic"
onClick="fullscreen(-)"
onLoad="alpha=0;alpha=0.3,500"
/>

<spot id="exit" url="images/fullscreen_exit.png"
static="1" scale="0.5" align="CM" salignX="0.45" salignY="-0.425"
onOver="alpha=0.8,500; scale=.6,1000,elastic"
onOut="alpha=0.3; scale=0.5,1000,elastic"
onClick="fullscreen(-)"
onLoad="alpha=0;alpha=0.3,500"
/>

<!--------------------------------------------------------------->
<!--------------------------------------------------------------->
<!-- Button -->
<box id="spot_whatever_ID" linked="images/image_cube" url="images/large_glo.png" alt="spot_whatever_ID"
pan="-1" tilt="-14" distance="1" orientation="sphere" rotationX="0" rotationY="0" rotationZ="0" depth="99" scale="1"
alpha="0" glow="0" alignX="-0.5" alignY="-0.5" scaleable="1"
onLoad="alpha=0"
onOver="alpha=1,100; scale=1.2,600,elastic"
onOut="alpha=0,250; scale=1,600,elastic"
onClick="spot_whatever_ID.visible=0;thisFocus()"
thisFocus="pano.qualityStatic=low;pano.pan_v=0;pan o.tilt=-20,400;timer+=1,300,,zoom_me"
zoom_me="pano.zoom=2,1000;timer+=1,1000;pano.leash =free;loadPano(?panoName=images/anotherimage_cube&pan=0&tilt=0&zoom=1&,500,fade)" />


</global>

</hotspots>

</panorama>



Just a snippet - but you get the idea. Nothing new here.

BTW - I tried your recommendation, but it still doesn't work. I don't think the examples would have been wrong as I just cut and pasted those lines directly from the embedPano.fla and FLVplayer.fla files.

I did test this thing on another computer that shows me the errors from the browser (not sure how to turn that on for my other PC) and this is the error I'm getting:

Error #1009: Cannot access a property or method of a null object reference.


I also noticed that I must have inadvertently deleted something when I cleaned out the AS3 code I posted earlier as it doesn't work like my "uncleaned out code".

Anyway - by the error I'm getting, it looks like something isn't being defined somewhere.

Other ideas?
Reply With Quote
  #16  
Old 06-04-2008, 05:58 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

I got rid of the error and here's my latest code...

BUT... still no response from the hotspot listener...

This uses the embedPano.fla stage objects and instances... I'm just trying to make one of the buttons disappear on a hotspot rollover event.

I changed the name of my pano, xml file, and hotspot ID to protect the innocent...

That shouldn't be this hard, right!? What am I doing wrong!?

var movie:Sprite;
var hotspot:Object;
var hotspots:Object;
var spotObject:Object;

var panorama:MovieClip;
var loader:Loader = new Loader();
loader.load(new URLRequest("files/pano0.swf"));
addChild(loader);

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);

function loadComplete (e:Event) {
swapChildren(loader, border);
panorama = loader.content;
panorama.setArea(100,50,400,300);

panorama.loadPanorama("panoName=images/panoImageName&xml_file=panoImageName.xml");

loaderInfo.addEventListener(Event.INIT, initHandler);

function initHandler (event:Event) {
if (loaderInfo.loader!=null) {
// get link to hotspot sprite:
movie = loaderInfo.loader.movie;

// get link to hotspot control object:
hotspot = loaderInfo.loader.hotspot;
// example how to change hotspot's properties:
// hotspot.saturation = -1;
// hotspot.rotation = 45;

spotObject = panorama.externals.hotspots.getSpot("hotspotNameTh ingy").movie;
//spotObject.mouseChildren = true;
//spotObject.onOver="onOverFunction()";
spotObject.addEventListener(MouseEvent.MOUSE_OVER, onOverFunction);

function onOverFunction(event:MouseEvent) {
down_btn.visible=false;
}


// get link to hotspots plugin object:
hotspots = loaderInfo.loader.hotspots;
// example how to use it:
// hotspots.execute("pano.pan=45,1000,elastic;pano.ti lt=30,1200,elastic;");

// add your own event listener:
//movie.addEventListener(MouseEvent.CLICK, doClick);

// define remove function (will fire on unload)
loaderInfo.loader.remove = remove;
}
}
}
Reply With Quote
  #17  
Old 06-04-2008, 08:32 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

Alright, I got off my *ss and looked up some code from when I can remember doing that, and I did it slightly differently. There are two ways you can place event listeners: on the parent object, or on the object itself. When you place one on the parent object, it applies to ALL of the children objects, and when you place it on the child object, it only applies to the child. You have been trying to place it on the child object, and I placed it on the parent object: hotspots.stage. And then I ignored clicks on the background, so I would only get clicks on the hotspots, and then you could further isolate clicks on only a certain hotspot by checking the id. And of course, you will want to change it from a CLICK event to a MOUSE_OVER event. And finally, make sure you don't try to set the event listener before hotspots has loaded.

hotspots.stage.addEventListener(MouseEvent.MOUSE_D OWN, doPress);
.....
function doPress (event:MouseEvent) {
// make sure we've got the right object
obj = event.target;
while (!obj.hasOwnProperty("attributes")) {
if (obj.hasOwnProperty("parent")) {
if (obj is Stage) { return; }
obj = obj.parent;
} else {
return;
}
}
if (obj.attributes.id == "zzz") { doSomething() }
}


Hope that helps.

Zephyr
__________________
Zephyr Renner - AdvancedVirtualTours.com - zleifr @t yahoo

Improving the panoramic one mighty fine plug-in at a time: http://www.flashpanos.com
Reply With Quote
  #18  
Old 06-04-2008, 09:03 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

OK - then how do I check if hotspots are done loading?

Here's what I tried to add in, but it didn't work...

I put this if statement within my main initHandler function that fires on the INIT event:

if (panorama.externals.hotspots!=null) {
waitTimer.stop();
waitTimer = null
hotspots = panorama.externals.hotspots;
}


And I then added your code later within my MOUSE_OVER function (that's within the main initHandler function) like this:

function onOverFunction(event:MouseEvent) {
// make sure we've got the right object
obj = event.target;
while (!obj.hasOwnProperty("attributes")) {
if (obj.hasOwnProperty("parent")) {
if (obj is Stage) { return; }
obj = obj.parent;
} else {
return;
}
}
if (obj.attributes.id == "Name_I'm_Looking_For") {
// Here's what I want it to do....
down_btn.visible=false;
}

With this - I don't get any errors, but my "down_btn" graphic instance doesn't go away when I mouse over the correct hotspot...

What next?

Thanks again for the help!!
Reply With Quote
  #19  
Old 06-04-2008, 09:06 PM
djsegler djsegler is offline
Member
 
Join Date: Apr 2008
Posts: 67
Downloads: 0
Uploads: 0
Default

Oops - realized I missed the timer function!

I'll add it near the top after my var declarations like this:

waitTimer = new Timer(50);
waitTimer.addEventListener(TimerEvent.TIMER, waitHotspots, false, 0, true);
waitTimer.start();

That way it should start at the beginning and I'll be looking for it to be done in my function that tries to setup the hotspot listeners...

Am I on the right track?
Reply With Quote
  #20  
Old 06-04-2008, 09:12 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

I don't see that you actually set the event listener, and right after hotspots is defined would be a fine place to set it:

if (panorama.externals.hotspots!=null) {
waitTimer.stop();
waitTimer = null
hotspots = panorama.externals.hotspots;
hotspots.stage.addEventListener(MouseEvent.MOUSE_O VER, onOverFunction);
}


function onOverFunction(event:MouseEvent) {
// make sure we've got the right object
obj = event.target;
while (!obj.hasOwnProperty("attributes")) {
if (obj.hasOwnProperty("parent")) {
if (obj is Stage) { return; }
obj = obj.parent;
} else {
return;
}
}
if (obj.attributes.id == "down_btn") {
// Here's what I want it to do....
down_btn.visible=false;
}

Also, make sure that you use lower case ids for all of your hotspots, because FPP will transform any upper case letters to lower case and fail to match.

Zephyr
__________________
Zephyr Renner - AdvancedVirtualTours.com - zleifr @t yahoo

Improving the panoramic one mighty fine plug-in at a time: http://www.flashpanos.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 01:09 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.