3 Replies - 1149 Views - Last Post: 12 April 2008 - 06:47 PM

#1 Wade  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 23-September 07

Getting Confused on Passing Vars

Post icon  Posted 09 April 2008 - 12:33 PM

Sorry for the descriptions - they are probably wrong but hopefully will convey my issue.

I have a flash movie that uses MySql variables that get set in getpage.php. This php file simply queries the database and returns things like text color, the banner text, etc. all of this works fine, but I cannot seem to figure out how to pass in the page id number to the getpage.php that flash calls through myData.load("flash/getpage.php)" - currently I am not sending the id to getpage.php so I am getting my default id=1 so the query always gets record 1.

Basically I need to know how to send the page id# from webpage.html to flash and then in flash send it in the myData.load call (i guess) to getpage.php so that it knows the page number from the web site that is being loaded.

I can call the flash and send the id# by using the following, just don't know what to do once it is there? Thanks in Advance.

Web Page Code (just cut out part in flash object where it is called once)
<embed src="flash/banner.swf?id=<?=$id?>" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="875" height="100"></embed>



My ActionScript:

function textLoader() {
 myData = new LoadVars() 
		myData.ref = this 
		myData.onload = function(succes){ 
			if(succes){ 
			Title_txt.html = true;
					Title_txt.htmlText = this.Title;
					Title2_txt.html = true;
					Title2_txt.htmlText = this.Title2; 
					comment_txt.html = true;
					comment_txt.htmlText = this.Comments;
					comment2_txt.html = true;
					comment2_txt.htmlText = this.Comments2;
					holder_mc.loadMovie(this.Image); 
					holder_mc2.loadMovie(this.Image1); 
					  } else trace("Error loading data") 
		} 
		myData.load("flash/getpage.php") 
}
inner_txt.text = passed;
var myCSS = new TextField.StyleSheet(); 
myCSS.load("flash/myStyle.php");
myCSS.onload = function() { 
Title_txt.styleSheet = myCSS;
Title2_txt.styleSheet = myCSS;
comment_txt.styleSheet = myCSS;
comment2_txt.styleSheet = myCSS;
textLoader(); 
};
stop();



Is This A Good Question/Topic? 0
  • +

Replies To: Getting Confused on Passing Vars

#2 theRemix  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 440
  • Joined: 19-October 05

Re: Getting Confused on Passing Vars

Posted 09 April 2008 - 01:03 PM

that would be

_root.id

Was This Post Helpful? 0
  • +
  • -

#3 Wade  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 23-September 07

Re: Getting Confused on Passing Vars

Posted 09 April 2008 - 03:11 PM

Thanks for the reply. A little too cryptic for me though. I guess your reply means that in flash the id parameter passed from the html document as ?id= is referenced by _root.id.

Looking around there are examples of POST and sendandLoad out there but most are poor examples

Thanks again in Advance.


I tried this but no luck. Created new LoadVars - myVars, assigned myVar.id=_root.id, did a sendandLoad sending myVars and getting back myData.

function textLoader() {
 myData = new LoadVars()
 myVars = new LoadVars();
		myData.ref = this 
		myData.onload = function(succes){ 
			if(succes){ 
					Title_txt.html = true;
					Title_txt.htmlText = this.Title;
					Title2_txt.html = true;
					Title2_txt.htmlText = this.Title2; 
					comment_txt.html = true;
					comment_txt.htmlText = this.Comments;
					comment2_txt.html = true;
					comment2_txt.htmlText = this.Comments2;
					holder_mc.loadMovie(this.Image); 
					holder_mc2.loadMovie(this.Image1); 
					  } else trace("Error loading data") 
		} 
		myVars.id = _root.id;
		myVars.sendAndLoad("flash/getpage.php", myData, 'POST')
}
var myCSS = new TextField.StyleSheet(); 
myCSS.load("flash/myStyle.php");
myCSS.onload = function() { 
Title_txt.styleSheet = myCSS;
Title2_txt.styleSheet = myCSS;
comment_txt.styleSheet = myCSS;
comment2_txt.styleSheet = myCSS;
textLoader(); 
};
stop();


This post has been edited by Wade: 09 April 2008 - 06:52 PM

Was This Post Helpful? 0
  • +
  • -

#4 theRemix  Icon User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 440
  • Joined: 19-October 05

Re: Getting Confused on Passing Vars

Posted 12 April 2008 - 06:47 PM

View PostWade, on 9 Apr, 2008 - 03:11 PM, said:

Thanks for the reply. A little too cryptic for me though. I guess your reply means that in flash the id parameter passed from the html document as ?id= is referenced by _root.id.

Looking around there are examples of POST and sendandLoad out there but most are poor examples

Thanks again in Advance.


I tried this but no luck. Created new LoadVars - myVars, assigned myVar.id=_root.id, did a sendandLoad sending myVars and getting back myData.

function textLoader() {
 myData = new LoadVars()
 myVars = new LoadVars();
		myData.ref = this 
		myData.onload = function(succes){ 
			if(succes){ 
					Title_txt.html = true;
					Title_txt.htmlText = this.Title;
					Title2_txt.html = true;
					Title2_txt.htmlText = this.Title2; 
					comment_txt.html = true;
					comment_txt.htmlText = this.Comments;
					comment2_txt.html = true;
					comment2_txt.htmlText = this.Comments2;
					holder_mc.loadMovie(this.Image); 
					holder_mc2.loadMovie(this.Image1); 
					  } else trace("Error loading data") 
		} 
		myVars.id = _root.id;
		myVars.sendAndLoad("flash/getpage.php", myData, 'POST')
}
var myCSS = new TextField.StyleSheet(); 
myCSS.load("flash/myStyle.php");
myCSS.onload = function() { 
Title_txt.styleSheet = myCSS;
Title2_txt.styleSheet = myCSS;
comment_txt.styleSheet = myCSS;
comment2_txt.styleSheet = myCSS;
textLoader(); 
};
stop();




first make sure that you are actually getting the variable from the html.

put a quick dynamic text field with the instance name: "trace" somewhere on stage.
then anywhere in your code, first frame for example do:
_root.trace.text = _root.id


you should see the value of "id" in that text field when run in browser. if you get nothing, or "undefined" then we should fix this first before moving on to step 2.

if it shows up, undo all of that and we can safely assume that _root.id is what you expect it to be.

and i think you may be getting scope problems.

try taking the code out of the function textLoader() like this.
var myCSS = new TextField.StyleSheet(); 
myCSS.load("flash/myStyle.php");
myCSS.onload = function() { 
Title_txt.styleSheet = myCSS;
Title2_txt.styleSheet = myCSS;
comment_txt.styleSheet = myCSS;
comment2_txt.styleSheet = myCSS;
};

myData = new LoadVars()
 myVars = new LoadVars();
		myData.ref = this 
		myData.onload = function(succes){ 
			if(succes){ 
					Title_txt.html = true;
					Title_txt.htmlText = this.Title;
					Title2_txt.html = true;
					Title2_txt.htmlText = this.Title2; 
					comment_txt.html = true;
					comment_txt.htmlText = this.Comments;
					comment2_txt.html = true;
					comment2_txt.htmlText = this.Comments2;
					holder_mc.loadMovie(this.Image); 
					holder_mc2.loadMovie(this.Image1); 
					  } else trace("Error loading data") 
		} 
		myVars.id = _root.id;
		myVars.sendAndLoad("flash/getpage.php", myData, 'POST')

stop();



hth.

btw, i'm not receiving subscription emails for replies to threads like i'm supposed to, so if you need more help, PM me again, because i get email notifications from PMs. thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1