View Full Version : Execute custom ActionScript when click HotSpot
agnosix
11-18-2008, 11:01 AM
Hi guys.
I need for a project (i have FPP embed in my flash movie)to execute custom ActionScript functions when the user clicks in a HotSpot.
I have no idea if this is possible.
Ideas??
Thanks in advance.
LepLep
11-18-2008, 12:27 PM
probably its difficult solution but i would start with this link (http://flashpanoramas.com/forum/search.php) ...
zenofonte
03-05-2009, 11:02 PM
Hi guys.
I need for a project (i have FPP embed in my flash movie)to execute custom ActionScript functions when the user clicks in a HotSpot.
I have no idea if this is possible.
Ideas??
Thanks in advance.
Hotspots objects has the addEventListener methods. so is theoretically simple. :cool:
in the panorama loading functions I used this....
function waitHotspots (event:Event) {
if (panorama.externals.hotspots!=null ) {
if (panorama.externals.hotspots.ready) {
hotspots = panorama.externals.hotspots;
hotspots.addEventListener(MouseEvent.MOUSE_UP, doSomething}
}
}
so doSomething is called on the MouseEvent on every hotspots you instanced on you pano.
the triggered function is...
function doSomething(e:Event){
var obj:Object;
var ids:String;
var param:String;
obj = e.target;
while (!obj.hasOwnProperty("attributes")) {
if (obj.hasOwnProperty("parent")) {
obj = obj.parent;
} else {
return;
}
}
ids = obj.attributes.id;
param = obj.attributes.getParam("a_new_kind_of_paramenter_in_spot");
...... then add what do you want...
}
it works... I warrant...
sidefin
03-18-2009, 11:28 AM
Hello i try this example but it dont work... i'm a newbie, perhaps i forgot something!
this is my function (doSomething):
function doSomething(e:Event) {
var obj:Object;
var ids:String;
var param:String;
obj = e.target;
while (!obj.hasOwnProperty("attributes")) {
if (obj.hasOwnProperty("parent")) {
obj = obj.parent;
} else {
return;
}
}
ids = obj.attributes.id;
param = obj.attributes.getParam("a_new_kind_of_paramenter_in_spot");
panorama.pano.panKey = -1;
}
then i load here the pano:
function doPano1(e:Event) {
if (panorama.pano.loadCompleted) {
// if Hotspots plugin is present, use hotspots.loadPano()
// change panorama manually otherwise
// this allows to avoid problems with Hotspots controller
if (panorama.externals.hotspots!=null) {
if (panorama.externals.hotspots.ready) {
hotspots = panorama.externals.hotspots;
hotspots.addEventListener(MouseEvent.MOUSE_UP, doSomething);
}
panorama.externals.hotspots.loadPano(["pano.swf?panoName=images/nature"]);
} else {
panorama.pano.remove();
panorama.loadPanorama("pano.swf?panoName=images/nature");
}
}
}
xml line (hotspot):
<hotspots>
<global onLoad="alpha=100; alpha=1,1000">
<box id="info" url="info.png" align="C" pan="-42.00" tilt="-47.00" orientation="down" rotationX="30.00" rotationY="90.00" scale="5" onOver="scale=7,600,elastic;depth+=20" onOut="scale=5,600,elastic;depth+=80" onClick="openUrl(info/1.html, _self)"/>
</global>
</hotspots>
what do i have to write in the xml line on the >> OnClick= ??
thank you!
sidefin
03-18-2009, 02:52 PM
is there a tutorial or something i can learn to make a simple function call from xml ? i want to tell the hotspot CLICK to run a function that is in my AS3. The entire AS3 and XML is in the same frame of my flash movie (integrated xml in AS3)
var panorama:MovieClip;
var loader:Loader = new Loader();
loader.load(new URLRequest("files/pano.swf"));
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);
function loadComplete(e:Event) {
swapChildren(loader, border);
panorama = loader.content;
panorama.setArea(0,0,377,250);
//panorama.loadPanorama("panoName=images/nature");
//Variants:
//panorama.loadPanorama("pano.swf?panoName=images/snow"); //load images/snow pano, old syntax
//panorama.loadPanorama("panoName=images/snow&segments=10&pan=100"); //load images/snow with custom params
//panorama.loadPanorama("panoName=images/snow&xml_file=&"); //load images/snow without myPano.xml file
//panorama.loadPanorama("panoName=images/snow&xml_file=my.xml"); //load images/snow with custom xml file
//panorama.loadPanorama("xml_file=my.xml"); //load xml file (panoname within)
//panorama.loadPanorama("panoName=images/snow&layer_1=files/menuFullscreen.swf"); //load menuFullscreen plugin
panorama.loadPanorama("xml_text="+xml_1);//load with predefined XML data
left_btn.addEventListener(MouseEvent.MOUSE_DOWN, doLeft);
right_btn.addEventListener(MouseEvent.MOUSE_DOWN, doRight);
up_btn.addEventListener(MouseEvent.MOUSE_DOWN, doUp);
down_btn.addEventListener(MouseEvent.MOUSE_DOWN, doDown);
stage.addEventListener(MouseEvent.MOUSE_UP, reset);
btn_zoomin.addEventListener(MouseEvent.MOUSE_DOWN, doZoomin);
btn_zoomin.addEventListener(MouseEvent.MOUSE_UP, doZoominStop);
btn_zoomout.addEventListener(MouseEvent.MOUSE_DOWN , doZoomout);
btn_zoomout.addEventListener(MouseEvent.MOUSE_UP, doZoomoutStop);
btn_fullscreen.addEventListener(MouseEvent.MOUSE_D OWN, doFullscreen);
btn_info.addEventListener(MouseEvent.MOUSE_DOWN, doInfo);
pano1_btn.addEventListener(MouseEvent.CLICK, doPano1);
pano2_btn.addEventListener(MouseEvent.CLICK, doPano2);
}
// you can store XML's for panoramas directly in code:
var xml_1:XML =
<panorama>
<parameters>
qualityMotion = high
panoName=images/nature
layer_1 = files/fps.swf
layer_3 = files/limits.swf
layer_9 = files/hotspots.swf
layer_6 = files/cylConverter.swf
layer_7 = files/movDecoder.swf
layer_8 = files/menuFullscreen.swf
panHome=100
</parameters>
<hotspots>
<global onLoad="alpha=100; alpha=1,1000">
<box id="info" url="info.png" align="C" pan="-42.00" tilt="-47.00" orientation="down" rotationX="30.00" rotationY="90.00" scale="5" onOver="scale=7,600,elastic;depth+=20" onOut="scale=5,600,elastic;depth+=80" onClick="here i want to call the doSomething Function"/>
</global>
</hotspots>
</panorama>;
function doSomething(e:Event) {
var obj:Object;
var ids:String;
var param:String;
obj = e.target;
while (!obj.hasOwnProperty("attributes")) {
if (obj.hasOwnProperty("parent")) {
obj = obj.parent;
} else {
return;
}
}
ids = obj.attributes.id;
param = obj.attributes.getParam("a_new_kind_of_paramenter_in_spot");
panorama.pano.panKey = -1;
}
function doLeft(e:Event) {
panorama.pano.panKey = -1;
}
function doRight(e:Event) {
panorama.pano.panKey = 1;
}
function doUp(e:Event) {
panorama.pano.tiltKey = 1;
}
function doDown(e:Event) {
panorama.pano.tiltKey = -1;
}
function reset(e:Event) {
panorama.pano.panKey = 0;
panorama.pano.tiltKey = 0;
}
function doZoomin(e:Event) {
panorama.pano.zoomKey=1;
}
function doZoominStop(e:Event) {
panorama.pano.zoomKey=0;
}
function doZoomout(e:Event) {
panorama.pano.zoomKey=-1;
}
function doZoomoutStop(e:Event) {
panorama.pano.zoomKey=0;
}
function doFullscreen(e:Event) {
//fullscreen(-);
}
function doInfo(e:Event) {
panorama.pano.tiltKey = -1;
}
function doPano1(e:Event) {
if (panorama.pano.loadCompleted) {
// if Hotspots plugin is present, use hotspots.loadPano()
// change panorama manually otherwise
// this allows to avoid problems with Hotspots controller
if (panorama.externals.hotspots!=null) {
if (panorama.externals.hotspots.ready) {
hotspots = panorama.externals.hotspots;
hotspots.addEventListener(MouseEvent.MOUSE_UP, doSomething);
}
panorama.externals.hotspots.loadPano(["pano.swf?panoName=images/nature"]);
} else {
panorama.pano.remove();
panorama.loadPanorama("pano.swf?panoName=images/nature");
}
}
}
function doPano2(e:Event) {
if (panorama.pano.loadCompleted) {
if (panorama.externals.hotspots!=null) {
if (panorama.externals.hotspots.ready) {
hotspots = panorama.externals.hotspots;
hotspots.addEventListener(MouseEvent.MOUSE_UP, doSomething);
}
panorama.externals.hotspots.loadPano(["pano.swf?panoName=images/snow"]);
} else {
panorama.pano.remove();
panorama.loadPanorama("pano.swf?panoName=images/snow");
}
}
}
can somebody help me ?? Thank You very much! Alain
Scott Witte
03-18-2009, 06:50 PM
is there a tutorial or something i can learn to make a simple function call from xml ? i want to tell the hotspot CLICK to run a function that is in my AS3.
Search these forums for "FPP API" and "API cheatsheet" (with quote marks!). Also check out Zephyr's excellent plugin tutorial at flashpanos.com. And don't forget the FLA files Denis included with many plugins, both the regular plugins and the smart hotspots. They are reasonably well commented and a great learning tool. All the techniques you need should be covered.
LepLep
03-18-2009, 10:43 PM
who said it gonna be easy? ;)
fragmented tutorial you are looking for is here
http://flashpanoramas.com/forum/showthread.php?t=976
vBulletin® v3.7.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.