View Full Version : Displaying the mysql in flash
peredy
May 30th, 2008, 06:18 PM
I read the tutorial to do it all. I even adjusted all the coding to the best of my knowlege. But it doesnt like this line...
var component = _parent;
and the as file was changed to where to call the php file, but thats it. And it is calling errors from it.
I am wondering if this is because I have to publish it in 3.0 and it was done in earlier versions.
A fix or any help is greatly appreciated.
Thanks
Peredy
rbnzdave
May 30th, 2008, 07:11 PM
var component:<Object or MovieClip> = this.parent;
depending on what the parent is, generally you would state MovieClip
peredy
May 30th, 2008, 07:50 PM
Thanks a ton. But now I'm getting a new error...
Here is the AS script and I'll put the problem below it.
function lv(l, n, t, e, f) {
if (l == undefined) {
l = new LoadVars();
l.onLoad = function() {
var i;
n.htmlText = "";
if (t == undefined) {
n.htmlText += "<b>"+this["title"+e]+"</b><br>";
} else {
for (i=0; i<this.n; i++) {
n.htmlText += "<class='menu_item'><a href='"+this["link"+i]+"'>"+this["title"+i]+"</a><br>";
}
}
};
}
l.load(f);
}
lv(news_txt, "cycle", null, "http://www.blysterband.com/bschedule/news.php");
Now I get 3 errors.
Line 3 1180: Call to a possibly undefined method LoadVars. I=newLoadVars();
Line 18: 1120: Access of undefined property news_txt Iv(news_txt, "cycle", null, "http://www.blysterband.com/bschedule/news.php");
Line 18 1136: Incorrect number of arguments. Expected 5 Iv(news_txt, "cycle", null, "http://www.blysterband.com/bschedule/news.php");
Thanks again for any help.
dail
May 30th, 2008, 08:50 PM
Looks like you are using AS2 examples in an AS3 project. LoadVars has gone from AS3
peredy
May 30th, 2008, 09:12 PM
Crap. Well, I got it from the example. Then just tried to change the small details to fit my php pages that I already have. I dont know how to script this stuff.
If there is anything I can copy and paste out there, I would sure love the info. I've been digging for 2 days and cant seem to get this right. I remember the days of Flash 4. Maybe there was alot less that could be done, but man... it was alot simpler then haha.
dail
May 30th, 2008, 09:32 PM
package {
import flash.display.*;
import flash.net.URLVariables;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLRequest;
import flash.events.*;
public class QueryDataBase extends Sprite {
public static const DATA_ACCESSED:String = "dataaccesed";
public function QueryDataBase() {
var myData:URLRequest = new URLRequest("http://www.blysterband.com/bschedule/news.php");
myData.method = URLRequestMethod.GET;
var variables:URLVariables = new URLVariables();
myData.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, dataOnLoad);
loader.load(myData);
}
private function dataOnLoad(event:Event):void {
trace(event.target.data)
//do your html stuff
dispatchEvent(new Event(QueryDataBase.DATA_ACCESSED, true));
}
}
}
peredy
May 30th, 2008, 10:24 PM
Thanks a ton again... however, I am now getting the following errors with it.
Line 3 - 1037 Packages cannot be nested - Package {
dail
May 31st, 2008, 03:34 AM
Sounds like you are trying to put two packages together. Like the error says, you can't nest packages. Just pull out the elements you need from what I posted.
dail
May 31st, 2008, 04:02 AM
Try this out; I hacked this together in text edit, no idea if it has any errors.
Save this as "QueryDataBase.as"
package {
import flash.net.URLVariables;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLRequest;
import flash.events.*;
public class QueryDataBase extends EventDispatcher {
private var php_Url:String;
private var phpResponse:String
//getter for accessing what php sends back to you. Note
//the return is typed as a string, you may want to change this
//to match what you get back from php!
public function getPhpResponse():String{
return phpResponse;
}
//constructor
public function QueryDataBase(php_Url:String) {
this.php_Url = php_Url;
requestPhpResponse()
}
//form up the php request
private function requestPhpResponse():void{
var myData:URLRequest = new URLRequest(php_Url);
myData.method = URLRequestMethod.GET;
var variables:URLVariables = new URLVariables();
myData.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, dataOnLoad);
loader.addEventListener(IOErrorEvent.IO_ERROR, handleError);
loader.load(myData);
}
//listen for response from php
private function dataOnLoad(event:Event):void {
phpResponse = event.target.data;
//simply redispatch the complete event, so you can listen for success
//at the class instance level.
//As the events target will no longer be the loader, we populate our var
//that will hold the php response, and then access it via the getter
//in the complete event listener set up at the class level.
dispatchEvent(event);
}
private function handleError(event:IOErrorEvent):void {
throw new Error("There was an IOerror accessing the PHP file: ");
}
}
}
Then, in your main class, or on your timeline;
var getDataBaseData:QueryDataBase = new QueryDataBase("http://www.blysterband.com/bschedule/news.php");
getDataBaseData.addEventListener(Event.COMPLETE, callbackHandler);
var myDataBasesData:String
function callbackHandler(event:Event):void {
//we get a response from php, so we can access the returned data
//via our classes getter function
myDataBasesData = getDataBaseData.getPhpResponse
//do your stuff, you got data!
}
As I said, I have not tested this, but it should work..
peredy
May 31st, 2008, 09:22 AM
Thanks a ton for the help again.
The only problem now is that nothing at all is showing up in the window. I dont have any errors, but I dont have anything there either.
http://www.blysterband.com/blystersite.zip is the flash and the .as
I might have left something out when I was pasting it in the as or in the timeline. It put it all in one line so I tried to seperate it as it looked on here.
Once again, all the help is greatly appreciated.
Oh... I almost forgot. The link for News is the only one I have doing anything (inside the flash) so far.
dail
June 1st, 2008, 06:23 PM
what happens if you trace the event.target.data within the complete handler in the class, that way you can see if you are getting anything returned by php..
peredy
June 6th, 2008, 05:31 PM
Wow, that is completely greek to me. Flash has realy gone and confused the hell out of me with all the changes. Well, thanks for the help, but it looks like this is a lost cause for me. I cant seem to grasp the concept of how to get this to work, and flash is WAY touchy these days. haha.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.