Allright after trying many different variations, I have ended with this below.
It does not work and has killed my pop up window ( my url defenition stinks). I was wondering if you could possibley have a look at it and debug. What I would it to do is every button to load a data file into the "0" level. This will be the data from my db. Is this a viable way to create a semi dynamic content site ??
AS
************************************************** ***************
stop ();
cir_color = new Color(cir);
with (data) {
for (i=1; i<=numMenus; i++) {
numLinks = (eval("menu"+i+"Links"))*1;
set ("_root.menu"+i+".numLinks", numLinks);
for (j=1; j<=numLinks; j++) {
theTitle = eval("menu"+i+"Link"+j+"Title");
set ("_root.menu"+i+".link"+j+".theTitle", theTitle);
theLink = eval("menu"+i+"Link"+j+"Url");
if(thelink.indexOf("http") == 0)
set ("_root.menu"+i+".link"+j+".theLink", theLink);
else
{ link[i].split(",");
set ("link1"+i+".func", f[0]);
set ("link1"+i+".fnarg", f[1]);
}
}}
}
************************************************** ******
If you would likr to peruse the src file let me know.
Looking forward to any help you can offer.
loading one distinct file for every menu is no good idea - just combine all the variables into one file
The last few lines should probably read
else
{ f = theLink.split(",");
set ("link1"+i+".func", f[0]);
set ("link1"+i+".fnarg", f[1]);
}
for a proper split. I do not think I can understand why you want to use link1 here, however
loading one distinct file for every menu is no good idea - just combine all the variables into one file
thats what I am doing for the menu headers and submenus, but then each submenu when selected loads a seperate file of combined variables.
Is that acceptable ?
The last few lines should probably read
else
{ f = theLink.split(",");
set ("link1"+i+".func", f[0]);
set ("link1"+i+".fnarg", f[1]);
}
for a proper split. I do not think I can understand why you want to use link1 here, however
I have tried some variations on the code and it is not working. I have got the file to successfully open my documents and settings folder when you click a link.
Please could you have a look at the fla and see where I have gone wrong, it should work as far as I can see, do not feel obliged to make changes if you could have a look and just let me know where I have gone wrong I would appreciate it.The first sub menu link under corporate is reading a record that looks like this - gotoAndStop,30 - All the enteries under the home menu should be url's
Excuse the bits and the look if you do download still experimental.
and this really is my last attempt
Kindest
Last edited by BarryAllen; 10-17-2002 at 05:29 PM.
// Frame 1
stop ();
loadVariables ("http://prototype.emarket2.com/admin/load_set.php", "data");
// file is text below - too save your time
// data is the targetted movie clip
&menu1=Home&menu2=Corporate&menu3=Products&menu4=C lients&menu5=Location&numMenus=5&menu1Links=3&menu 1Link1Title=Home 1&menu1Link1Url=http://www.flashkit.com&menu1Link2Title=Home 2&menu1Link2Url=http://prototype.emarket2.com/Craig_Development/var.php?id=37&menu1Link3Title=Home 3&menu1Link3Url=http://prototype.emarket2.com/Craig_Development/var.php?id=38&&menu2Links=3&menu2Link1Title=Corpor ate 1&menu2Link1Url=gotoAndStop,30&menu2Link2Title=Cor porate 2&menu2Link2Url=&menu2Link3Title=Corporate 3&menu2Link3Url=&&menu3Links=5&menu3Link2Title=Pro duct 2&menu3Link2Url=&menu3Link3Title=Product 3&menu3Link3Url=&menu3Link4Title=Product 1&menu3Link4Url=&menu3Link5Title=Product 4&menu3Link5Url=&menu3Link6Title=Product 5&menu3Link6Url=&&menu4Links=2&menu4Link1Title=Cli ents 1&menu4Link1Url=fgshrtsh&menu4Link2Title=Clients 2&menu4Link2Url=fghrsthr&&menu5Links=2&menu5Link1T itle=Location 1&menu5Link1Url=&menu5Link2Title=Yemis Location&menu5Link2Url=&&
// Frame 2
play()
// Frame 3
stop ();
with (data) {
for (i=1; i<=numMenus; i++) {
numLinks = (eval("menu"+i+"Links"))*1;
set ("_root.menu"+i+".numLinks", numLinks);
for (j=1; j<=numLinks; j++) {
theTitle = eval("menu"+i+"Link"+j+"Title");
set ("_root.menu"+i+".link"+j+".theTitle", theTitle);
theLink = eval("menu"+i+"Link"+j+"Url");
if(thelink.indexOf("http") == 0)
set ("_root.menu"+i+".link"+j+".theLink", theLink);
else
{ f = theLink.split(",");
set ("link1"+i+".func", f[0]);
set ("link1"+i+".fnarg", f[1]);
}
}}
}
************************************************** ************************
//I have 5 movie clips each is a menu named sequentially //menu1, menu2 ...,menu5
a) I am using ming which creates swf from static data (conceptually like flash, a fla is static data as well) but can also create swf from dynamic sources. Ming does support most of actionscript but has somewhat stricter rules than flash (_every_ statement wants a semicolon) and sometimes more consistent behaviour
b) no problem - best would be the actionscripts plus a swf to look at. In the specific case of your menu, I would like to have a look at the text files as well
if you download the swf to your desktop otherwise the data will not work from domain to domain.
and the code on the link button should read -
on (rollOver) {
tellTarget ("../") {
direction = 1;
play ();
}
}
on (rollOut) {
tellTarget ("../") {
direction = -1;
play ();
}
}
on (release) {
if (typeof (this.func) != 'undefined') {
_root[this.func](this.fnarg);
} else {
getURL (theLink);
}
}
Also the most important part the dat movie clip has the following attached to it sorry it was late last night.
onClipEvent (data) {
tellTarget ("_root") {
nextframe ();
}
for (i=1; i<=numMenus; i++) {
numLinks = (eval("menu"+i+"Links"))*1;
set ("_root.menu"+i+".numLinks", numLinks);
}
}
Kindest
Kindest
Last edited by BarryAllen; 10-18-2002 at 05:06 AM.
BarryAllen -
I was just wondering if you could help me out. I am trying to do somethign similar to what you are doing(flash/php/mysql), but it doesnt seem to work right, I would like to know if you can help me out through Aol instant messenger or msn messenger, since you have experience with this type of thing, when you get some free time. If you dont have a messenger system, I guess I could ask your advice through the fk forums. Anyways, hope to hear from you soon, thank you.
Ok, this is gonna be long ---
So, i have this site, which i want to loadvariables from a php file. The url is http://www.arblanza.invisionworld.com/john/fight .
Let me explain what I have so far. ( i used the php tag to make it organized)
PHP Code:
Main frame, _root:
A movie clip named "content"
A dynamic text box with variable name "news"
A home button, news button, login button, register button.
A lightbulb movie clip with instance name "brain".
Every time you click one of the buttons, it sets _root.brain.event. For instance, the home button has the code _root.brain.event = "A";
Now, on the brain movie clip.
I have a bunch of actions, and its all coded to keep people from finding out how everything works (dont ask).
The following is on the brain movie clip actions:
PHP Code:
onClipEvent (load) {
end = ".php";
end2 = ".swf";
php = "stuff";
pg = "page";
A = "home";
B = "news";
C = "login";
D = "register";
E = "games";
F = "battle";
G = "shop";
H = "signup";
I = "help";
J = "staff";
a1 = "name";
a2 = "password";
a3 = "gender";
a4 = "email";
a5 = "location";
a6 = "interests";
stats = new Array();
stats[0] = false;
event = A;
}
onClipEvent (enterFrame) {
if (event == A) {
_root.news = "Loading....";
_root.content.loadMovie();
_root.loadVariables(php+end+"?RND="+random(999999)+"&"+pg+"="+A, _root, "GET");
event = "";
}
if (event == B) {
_root.news = "Loading.....";
_root.content.loadMovie();
loadVariables(php+end+"?RND="+random(999999)+"&"+pg+"="+B, _root, "GET");
event = "";
}
if (event == C) {
_root.news = "Loading....";
_root.content.loadMovie(C+end2, _root.content);
event = "";
}
if (event == D) {
_root.news = "Loading....";
_root.content.loadMovie(D+end2, _root.content);
event = "";
}
if (event == H) {
_root.news = "Loading....";
loadVariables(php+end+"?RND="+random(999999)+"&"+pg+"="+H+"&"+a1+"="+_root.content.name+"&"+a2+"="+_root.content.pass+"&"+a3+"="+_root.content.gender.getValue()+"&"+a4+"="+_root.content.email+"&"+a5+"="+_root.content.location+"&"+a6+"="+_root.content.profile, _root);
_root.content.loadMovie();
event = "";
}
if (event == I) {
_root.news = "Loading....";
_root.content.loadMovie(I+end2, _root.content);
event = "";
}
if (event == J) {
_root.news = "Loading....";
_root.content.loadMovie(J+end2, _root.content);
event = "";
}
}
So, if event is equal to "A"
it sets _root.news to loading, i did this so it will display the words loading while the text is loading into flash.
Next line says _root.content.loadmovie(); content and news are overlapping, because for something i load text, from php and for somethings I use loadmovie to load an swf.
Next line is the loadvariables. I have this:
_root.loadVariables(php+end+"?RND="+random(999999) +"&"+pg+"="+A, _root, "GET");
If you substitute the variables in, it should turn out like this:
_root.loadVariables(stuff.php?RND=999999&page=home , _root, "GET");
Now we have the php file, very short and everything.
PHP Code:
<?php
if ($page == home) {
echo '_root.news =' . "Welcome to the site.";
}
if ($page == news) {
echo '_root.news =' . "No news yet";
}
?>
The file is called stuff.php
So, i would think that when you click on the home button it would load the words Welcome to the site into the _root.news dynamic text box.
But it doesnt. Well, im going to attach my fla file, and maybe you guys know where my problem is. Thanks.
If you can hold on. I'll have a look at the file when I'm in the office. No flash MX at home.
Hey z from what I can see your ActionScript seems sound apart from the load variables and the way your php is formatted. pls can you dump a txt file of the php output here and i'll look at it tommorrow.
PS are you giving the php time to load = a loop
kindest
Last edited by BarryAllen; 10-20-2002 at 02:56 PM.
On the advice of jimburton from Actionscript.org I went through the file to see where I had gone wrong. I traced the output and found that the functions and arguments are not being defined.
Please could you have a look at the following and see where I have gone wrong. I have included my trace.
Kindest
************************************************** **************
as on frame 3
************************************************** **************
stop();
with (data) {
for (i=1; i<=numMenus; i++) {
numLinks = (eval("menu"+i+"Links"))*1;
set("_root.menu"+i+".numLinks", numLinks);
for (j=1; j<=numLinks; j++) {
theTitle = eval("menu"+i+"Link"+j+"Title");
set("_root.menu"+i+".link"+j+".theTitle", theTitle);
theLink = eval("menu"+i+"Link"+j+"Url");
set("_root.menu"+i+".link"+j+".theLink", theLink);
if (theLink.indexOf("http") == 0) {
trace("this is an url");
trace(theLink);
} else {
f = theLink[i].split(",");
set("theLink"+i+".func", f[0]);
set("theLink"+i+".fnarg", f[1]);
trace("this is not an url");
trace(func);
trace(fnarg);
}
}
}
}
************************************************** **************
my trace output where : this is not an url, should be a function
************************************************** **************
this is not an url
undefined
undefined
undefined
this is not an url
undefined
undefined
undefined
this is not an url
undefined
undefined
undefined
this is not an url
undefined
undefined
undefined
this is not an url
undefined
undefined
undefined
this is an url http://www.testing.com
this is an url http://www.testing.com
this is an url http://www.testing.com
this is not an url
undefined
undefined
undefined
this is not an url
undefined
undefined
undefined
this is not an url
undefined
undefined
undefined
this is an url http://www.flashkit.com
this is an url http://www.testing.com
this is an url http://www.testing.com
*****************************************
This is the action on my button
*****************************************
on (release) {
if (func = "showframe(x)") {
_root.gotoAndPlay(x);
trace(func);
} else {
getURL (theLink);
you use this code to set the url:
set("_root.menu"+i+".link"+j+".theLink", theLink);
now, this should be replaced by
if(theLink.indexOf("http") == 0)
set("_root.menu"+i+".link"+j+".theLink", theLink);
else
{ f = theLink.split(",");
set("_root.menu"+i+".link"+j+".func", f[0]);
set("_root.menu"+i+".link"+j+".fnarg", f[1]);
}
You should perhaps not test the func against a string like showframe(x) but rather add a real showframe function at the root
The traces you are doing print the value of theLink but should rather print the value of _root.menu3.link2.theLink or such - similarly the func and fnarg of a particular element should be traced.
Some time before I wrote .... for a geturl - this should be the window where you want the external link to appear, such as _blank (new window), _self (replace movie by link) or a html frame
Thank you so much, my understanding has increased by leaps and bounds.
Yea Man
All right Musicman,
In case I have not been clear all I want the buttons to do is go to a frame within the flash file. They are accessing external url's fine now(not opening my desktop file).
I am almost there, the functions and arguments are now being defined. The following is a trace from my main flash file.
************************************************** *************
The trace is: Is this an url, if so what is the argument and the function. Works different variations (label name label no.)********************************************** *****************
this is not an url
showframe,aboutus
showframe
aboutus
this is not an url
showframe,10
showframe
10
this ia an url http://www.flashkit.com/
etc.etc.
************************************************** *************
On each button I have a trace. This produces the following:
************************************************** *************
showframe <--------- Function
aboutus <--------- Argument
undefined <--------- If url what url
************************************************** *************
The missing bit would seem to be (apart from my lack of understanding, which is improving) the function to interpret my showframe function and label name or number.
Ok, i figured that problem out. Just messed with stuff and it started working. Anyways, I have another problem.
I have a movie clip that I want to go to frame 2 when a variable, _root.brain.logged is equal to "yes". I have on the movie clip i have:
[code]
onClipEvent (enterFrame) {
if (_root.brain.logged == "yes") {
gotoAndStop(2);
} else {
gotoAndStop(1);
}
}
[code]
And in the php i have:
PHP Code:
if ($page == "home") {
echo "news=Hello, welcome to the site&";
echo 'brain.logged=yes&';
}
I see the variable say yes, but it doesnt move to the 2nd frame. I'm guessing that it is formatted differently from being sent from php, but i am not sure. Any suggestions? Thanks