Forums  

Go Back   Forums > Talk > General FPP Discussion

Reply
 
Thread Tools Display Modes
  #31  
Old 05-09-2008, 05:33 PM
vipergtsrz vipergtsrz is offline
Junior Member
 
Join Date: May 2008
Posts: 5
Downloads: 0
Uploads: 0
Default

First of all, thanks for all the help and sticking with me on this.

I decided to just try to make a plugin and call a function. I just want to do something basic like trace("hello").

I made a new file named tourFunctions.swf with the following code:

Code:
remove(void):void

var id:String="tourFunctions";
var version:String="1.0";

newPano()
var pano:Object=null;

var panorama:Object;

function init (panoMain) {
	if (panoMain.addExternal(this)) {
		panorama = panoMain;
	}
}
function newPano (link:Object) {
	pano = link;
	if (pano.loadersState!=null) {
	}
}
function newParams (str:String) {

}
function setAttribute (name:String, value:String, time:String=null, type:String=null, onDoneFunction:String=null, onInterruptFunction:String=null, relative:int=0) {
	trace("hello");
}
function remove () {

}
And then in my XML file I load this plugin like this:

Code:
layer_4 = tourFunctions.swf
And then in my hotspots, I do this:

Code:
<hotspots>
	<global onDeactivate="saturation=-1,400" onActivate="saturation=0,200">
		<pano leash="follow" />
    <spot id="simpleHotspot" pan="-110" tilt="-17" url="hot.png" onClick="external.tourFunctions.test=hello" />

	</global>
</hotspots>
According to what I've read, when I put onClick="external.tourFunctions.test=hello", it should call the "setAttribute" function in my tourFunctions.swf and pass "test" in as name and "hello" in as value.

Am I even close at all? What am I missing? I can read tutorials all day long, but until I physically see a working example I won't be able to understand. It's just how I learn I guess.

Any help would be appreciated.

*** EDIT ***
The error comes when I click on the hotspot. Here is the error:

Execute simplehotspot: external.tourFunctions.test=hello
Unrecognized object: external.tourFunctions

Last edited by vipergtsrz; 05-09-2008 at 05:39 PM.
Reply With Quote
  #32  
Old 05-09-2008, 11:06 PM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

all of that code looks just fine on a cursory glance. I am almost certain the problem you are having is the capital letter in the id of the plugin. Try changing:

var id:String="tourFunctions";

to:

var id:String="tourfunctions";

And tell me what that does.

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
  #33  
Old 05-13-2008, 01:43 PM
vipergtsrz vipergtsrz is offline
Junior Member
 
Join Date: May 2008
Posts: 5
Downloads: 0
Uploads: 0
Default

Wow! It worked!

So all this time it was just because I used a capital letter in my name.

Thank you for sticking with me and helping me solve it finally. For all of you who still can't figure it out, here is what you do:

1.) Create a new FLA in flash. In the code, put this:

Code:
var pano:Object;
var id:String="tourfunctions";
var version:String="1.0";

// this function is called on plugin's start
function init (panoMain:Object=null) {
panorama.addExternal(this);
}

// this function is called when new panorama is loading
function newPano(link:Object=null) {
pano = link;
}


// this function handle XML parameters
function newParams (str:String) {
var lines:Array = str.match(/[^\s\n\r;]+[^;\n\r]+/g);
for (var i:int=0;i<lines.length;i++) {
var pair:Array = lines[i].split(/[\s]*=[\s]*/);
setAttribute(pair[0], pair[1])
}
}

// function is for external calls: "external.smartscale.mode=..."
function setAttribute (name:String, value:String, time:String=null, type:String=null, onDoneFunction:String=null, onInterruptFunction:String=null, relative:int=0) {
if (name.toLowerCase() == "dosomething"){
if (value.toLowerCase() == "jump"){
goAndJump();
}
}
}
function goAndJump(){
	trace("hello");
}

function remove () {
}
NOTE: var id:String="tourfunctions";

Now save that FLA and publish it to SWF.

2.) In your XML for your pano movie, add a new layer for your newly created plugin. It should look like this

Code:
layer_4 = tourfunctions.swf
3.) In your hotspots XML, the onClick should look like this:

Code:
onClick="external.tourfunctions.dosomething=jump"
you NEED to use "external.tourfunctions" (tourfunctions is just what I called it in my first code block) and the last two parameters "dosomething=jump" are the two strings you're passing to your "setAttribute" function.

Hopefully this helps someone out.
Reply With Quote
  #34  
Old 05-13-2008, 10:58 PM
cheathamlane cheathamlane is offline
Senior Member
 
Join Date: Mar 2007
Location: California, USA
Posts: 773
Downloads: 0
Uploads: 0
Default

Woohoo!

Let us know when you go live with something...
__________________
Patrick
http://patrickcheatham.com
Reply With Quote
  #35  
Old 05-13-2008, 11:11 PM
vipergtsrz vipergtsrz is offline
Junior Member
 
Join Date: May 2008
Posts: 5
Downloads: 0
Uploads: 0
Default

Will do! Thanks again for your help.
Reply With Quote
  #36  
Old 05-26-2008, 12:31 PM
VRob VRob is offline
Junior Member
 
Join Date: May 2008
Posts: 27
Downloads: 0
Uploads: 0
Default

Thanks Viper, I hoped it was going to help - it certainly simplified that part of the post. However I get:

ReferenceError: Error #1065: Variable panorama is not defined.
at mycallbacks_fla::MainTimeline/init()
at PanoController/loadComplete()

When I put it into my project. Any ideas anyone? (I changed the name from tourfunctions to mycallbacks (all lower case but that should make no difference!?)
Reply With Quote
  #37  
Old 05-27-2008, 04:21 AM
zleifr's Avatar
zleifr zleifr is offline
Senior Member
 
Join Date: May 2007
Posts: 609
Downloads: 0
Uploads: 0
Default

switch panorama for panoMain. That should do it I think.
__________________
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
  #38  
Old 10-12-2009, 09:04 PM
Surveyor Surveyor is offline
Junior Member
 
Join Date: Dec 2007
Posts: 19
Downloads: 0
Uploads: 0
Default

I have to do something similar with this code...

i want to call a function that does something when get the value.

Quote:
my AS3 code

//////////////////////////////////////////External triggers
var pano:Object;
var id:String="embedPanoPlugin";
var version:String="1.0";

// this function is called on plugin's start
function init(panoMain:Object=null) {
panorama.addExternal(this);
}

// this function is called when new panorama is loading
function newPano(link:Object=null) {
pano=link;
}


// this function handle XML parameters
function newParams(str:String) {
var lines:Array=str.match(/[^\s\n\r;]+[^;\n\r]+/g);
for (var i:int=0; i<lines.length; i++) {
var pair:Array=lines[i].split(/[\s]*=[\s]*/);
setAttribute(pair[0], pair[1]);
}
}

// function is for external calls: "external.smartscale.mode=..."
function setAttribute(name:String, value:String, time:String=null, type:String=null, onDoneFunction:String=null, onInterruptFunction:String=null, relative:int=0) {
//if (name.toLowerCase() == "dosomething"){
//if (value.toLowerCase() == "jump"){
CurrentPano=parseFloat(value);
minimap_showCpin(CurrentPano);
//}
//}
}

function remove() {
}
/////////////////////////////////////////

------------------


Quote:
my XML

onClick = "pano.pan=-25,200;pano.tilt=-4,200;timer+=1,600,,zoom4me"
zoom4me = "pano.zoomKey=2,1;timer+=1,650,,callPins"
callPins = "external.embedPanoPlugin.currentpano=2; timer+=1,600,,load4me"
load4me = "loadPano(panoName=images/pan2/a&xml_file=images/pan2/a.xml,1000)"


i try to understand why this cant work. i call the wanted function from AS and works fine. for some reason the plugin do not triggers


the behaviur of the programm is that when i call the function from the hotspot , just ignores it and runs further (calls the next pano)


the function that i want to call is this


Quote:
function minimap_showCpin(CurrentP:int):void {
var MMPins:Array = new Array();
var MMText:Array = new Array();
for (X=1; X<13; X++) {

MMPins[X]=root.MiniMap.TheMiniMap["pin"+X];
MMText[X]=root["txt"+X];
if (CurrentP==X) {
MMPins[X].alpha=100;
MMText[X].alpha=100;
} else {
MMPins[X].alpha=0;
MMText[X].alpha=0;
}
}
}
my project is an embed one

Last edited by Surveyor; 10-12-2009 at 09:13 PM.
Reply With Quote
  #39  
Old 10-13-2009, 07:42 AM
Surveyor Surveyor is offline
Junior Member
 
Join Date: Dec 2007
Posts: 19
Downloads: 0
Uploads: 0
Default

i forgot to say that im using 2.3.1 version
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 10:46 PM.


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