Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-31-2003, 02:19 PM   #1
Noobty
Registered User
 
Join Date: Mar 2003
Posts: 9
Default Passing array elements and automatic hyperlink generation

On my existing site I have used PHP to dynamically generate hyperlinks corresponding to a directory filled with image files.

Each hyperlink is stored as an element stored an array.

I am considering making a Flash alternative to my current site and require that it retain the same dynamic functionality.

How can I pass the array over to Flash so that it can generate the hyperlinks?

The only method I have investigated so far involves using text files to store the array element information before reading the text file contents into Flash. This does not sound like a straightforward solution and I can envisage a few potential problems this method would produce.

Can anyone give me the basic structure of how I might go about completing the task in hand?

Might it be possible to read the names of the files contained in a directory into Flash as an alternative?

Appologies if this post echos any that have gone before (it seems that variable passing questions number many ) and any help would be greatfully appreciated.

Last edited by Noobty; 03-31-2003 at 02:21 PM.
Noobty is offline   Reply With Quote
Old 03-31-2003, 02:26 PM   #2
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

well there are a couple of possibilities here.

flash reads in variables as strings so...
you can have your php create a comma (or anyother character) delimited file like: bob.jpg,bill.jpg,sam.jpg,karen.jpg
to flash it will look like: "bob.jpg,bill.jpg,sam.jpg,karen.jpg"

then in flash use the split() funciton to split this string into an array.

or the other option is to have your php script form create a valid xml document, and have flash load that.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 03-31-2003, 02:45 PM   #3
Noobty
Registered User
 
Join Date: Mar 2003
Posts: 9
Default

I must admit to being relatively new to creating dynamic content and have only just worked my way into PHP (my site is my first PHP driven project).

Am am fascinated the possibilities that serverside languages offer and am keen to investigate further. That said however, as I explained above, I still find many of these technologies baffling and can become easily confused.

Thanks for the quick reply. I understand the principles of what you have explained but I am missing fundamental and extremely basic point. What forms the link between PHP and Flash? My current understanding is that all information generated by PHP has to be written to a "middleman" before the generated file is read back into Flash.

So with my problem in mind. If a text file containing the PHP generated hyperlink information is written with every visit to the site wouldn't this result in problems with writing the information?

As you can see, I'm more than a little confused (and confusing ), these are my first few tentative steps into the world of dynamic web development. A little help would be a tremendous learning boost!
Noobty is offline   Reply With Quote
Old 03-31-2003, 03:27 PM   #4
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

gotcha... i don't use php myself, but the serverside scripting conscepts are pretty much the same for all of the scripting languages....

if you want to use xml,
inflash create an xml object, set up its onLoad event handler, then tell it to load your php file.

in the php file have php grab any values that flash may have passed to it, query any databases/files you have data stored in, then have the php ceate the needed output in xml format.

this all takes place in one php script.

if you want to go with the string/array option,
in flash, create a loadVars object, use sendAndLoad to call your php script it will basically do the same thing as listed above for the xml file, but instead of writing out in xml format, have it write out a delimited string.


there are lots of very knowledgable folks here on php, that will most likely comealong soon to help you out with specific questions. to help get you started off with some of this tho, check out some of the tutorials in the intermediate section on the tutorial page here... most of the scripting examples use php, and they should get the ball rolling for you.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:41 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.