View Full Version : help with custom product listing using dynamically populated comboboxes
zonemikel
05-31-2006, 04:15 AM
just when i thought i was about finished my client has discovered they need something else in their product listing before it was just product color qty price now we have Products which have different colors for each product and there are different sizes for each color and to boot different prices & qty for each size so im thinking
product name - product color - product size - product qty/price
now before i made the product listing in php but i made the whole rest of the page in flash so to keep it all the same im going to attempt to make the product listing/order in flash also (it will look so much nicer :) )
I will be able to pull off the mysql/php to support such complication but in flash i think ill be lost.... so i need help
im thinking of making flash movie load the products in loadvars and then display them then i was going to use the combo box component to select different colors so it would display the product in one color then if you select a different color from the dropdown menu it would refresh the values in the sizes dropdown box and then display the actual price for the specified color / size of the product ... so ill make this into a few questions that hopefully you all can easily answer to get me started
1.) how can i make a product listing that creates a new movie clip for every product ? or should i ? generate it all from actionscript ?
2.) how can i load content from loadvars into a dropdown combo box ?
3.) how can i make it refresh content in the child combo boxes when a parent combo box is selected ?
im thinking maybe i should make it load from xml but i have gotten semi comfortable with loadvars loading from a php file ...
thanks in advance i know itz a humdinger
well my post has moved to page three ... guess i midas well give up on help with this .... im editing this so i dont bump it ... i guess thanks anyway ill try and figure it out peice by peice and then ask smaller problems ? :(
hobbis
06-02-2006, 03:53 PM
Depending on how far you've come, I would ditch the loadvars route and use amfphp. In the long run it's so much easier. I can help you with this if you want as it needs some setting up, but it's a great way to connect your php/mysql to flash. Especially when we're talking about components such as ComboBoxes. But getting back to your questions:
1.) how can i make a product listing that creates a new movie clip for every product ? or should i ? generate it all from actionscript ?
Not sure what you are asking here. You can create movieclips on the fly but I think I have misunderstood your question.
2.) how can i load content from loadvars into a dropdown combo box ?
Build an array and bind the data to the component.
3.) how can i make it refresh content in the child combo boxes when a parent combo box is selected ?
You use event listeners. Each component such as comboBox fires events when certain things happen like if the selected item has changed. You can then tell the listener to use a function that populates the other combo Boxes with other data.
Hope that helps.
zonemikel
06-02-2006, 07:45 PM
Yes i did read up on something like ampfphp i cant remember the name but it was like some sort of little add on for flash and then some gateway.php file ... anyway ill look into ampfphp ... i figured loadvars would work and i didnt want to get sidetracked trying to install and figure out how to work something else.. I figured i would hafto use event listners i just dont know how to use them ... anyway i have only done the first part where it list the different categories by buttons (from loadvars) then when a button was clicked i was going to do a attachmovie and then pass the values from the button to a send and recive () and take the recived loadvars and load them into a movie clip. the movie clip would contain some dynamic text and comboboxes and pictures that would have values loaded in them from the loadvars ... anyway here is my code im gonna do some reading on ampfphp ... i love php and im very good at it - thanks[ as]//attachMovie(idname,newname,depth,initobject,(x y w h label);
//_root.createTextField(instancename="",depth,x,y,w,h)
import flash.filters.*;
stop();
xtext=125;
ytext=60;
btnx=50;
btny=75;
myVars = new LoadVars();
myVars.owner = this;
// call the load method to load my php page
myVars.load("http://www.harryrice.zonemikel.com/btnflash.php?"+Math.random());
//loadVariables.load("http://www.harryrice.zonemikel.com/conflash.php","GET");
myVars.onLoad = function( success ){
if(success){
i = 0;
while (i<myVars.endbtn){
var thmdesc = attachMovie("description","desc"+[i],getNextHighestDepth(),{_x:xtext, _y:ytext, _width:309, _height:30, label: i});
thmdesc.desc1.text = myVars["buttondesc" + i];
ytext=(ytext+35);
thmdesc._visible=false;
var thmbut = attachMovie("btn","btn"+[i],getNextHighestDepth(),{_x:btnx, _y:btny, _width:100, _height:20, label:i});
//we had label: myVars["buttonthm" + i]
var ds:DropShadowFilter = new DropShadowFilter(2,35,0x000000,5,5,5,.8,3,false,fa lse,false);
thmbut.btntext.text = myVars["buttonthm" + i];
thmbut.filters = [ds];
/*
this["btn"+[i]].onRollOver = function(){
showdesc(this._name)
}
showdesc(ref) {
var currdec = ref.slice(-1)
for(var i = 0;i< noofdec;i++ )
{ if ( i== currdec )
{ this["desc"+ i]._visible = true
}
else {
this["desc"+ i]._visible = false
}
}
}
*/
thmbut.onRollOver = function(){
if (this.label == 0){
desc0._visible=true;}
if (this.label == 1){
desc1._visible=true;}
if (this.label == 2){
desc2._visible=true;}
}
thmbut.onRollOut = function(){
if (this.label == 0){
desc0._visible=false;}
if (this.label == 1){
desc1._visible=false;}
if (this.label == 2){
desc2._visible=false;}
}
thmbut.onRelease = function(){
selected.filters = [];
var k:Number = this.label
title.title.text = this.label;
}//end function
btny=(btny+35);
//trace(myarray);
//trace(k);
i++;}
}// end if sucess
//end of parent function
else {
trace("Error loading page");
}
}
[/as]
zonemikel
06-05-2006, 08:00 PM
well im spending way to much time on this and im getting no where .. im catching hell making the pictures stay in the holder movie clips etc. and im getting no help from here ... amfphp looked to be incredibly complicated and the tutorials really sucked (video tutorials). i would have no problem doing this if i had a better understanding of actionscript but as i only have a about two weeks under my belt and i have learned some stuff but when i spend three days and still cant get a damn picture (loadmovie()) to show up in a movie clip right i give up .. i have finished the menu part where you would select your type of product then im gonna make that throw a GET var to another page where php will take over from there .... also im gonna buy a book on actionscript and read it untill then goodbye yall, i know ill be finished by tonight if i do the rest in php ... ill just spiff up the graphics to make them blend in with the flash
thanks anyway
bye
-zonemikel
hobbis
06-06-2006, 05:04 PM
Two weeks is not a long time for Flash apps! Why don't you post your files up and we can help out.
zonemikel
06-08-2006, 02:38 AM
Well in php i would have been done after one week ... i did install amfphp and im pretty sure its working... what files do you want me to upload ? let me know and ill upload them im totally into giving away anything i do so others can build on it
if you want to see the webpage in action go to www.harryrice.zonemikel.com and click on products .. you will see i made the product categoies in flash it loads those buttons and descriptions/qty dynamically but then when you click on the button it opens a new window with php :grin: i had no trouble hacking out what i wanted to do in php .. but for me to do that in flash im so lost ! i could never get the loadmovie to load the picture the way i wanted .. and then to load information into comboboxes and set up listener events totallyover my head ...
thanks for your help
i dont think i can upload files to these forums but if you tell me which files you want (ballpark) ill put them on my server and then link to them here .. i really do want to know how to do this but i never learned the basics of AS and at least with php i read a chapter out of a book ;)
hobbis
06-08-2006, 09:13 AM
Ok I can see from your site what you are trying to acheive. I think that amfphp would be a great advantage to you. Follow these threads, they have instructions on them which will help you:
http://www.actionscript.org/forums/showthread.php3?t=58195&highlight=flash+remoting+as2.0
http://www.actionscript.org/forums/showthread.php3?t=77725&highlight=flash+remoting+as2.0
Once you have a basic example working, then use the amfphp services to call your database/images etc and pull them into flash player.
Are you writing your as code in classes? If so, create a basic class that calls an amfphp service and bind the results to your component. It's a learning curve but you will realise what a huge benefit it is over the loadVars way.
zonemikel
06-09-2006, 02:20 AM
I dont really understand what amfphp is doing ? and ive neve written a php class before i used to write lots of classes in c++ so does amfphp just take a class and send its return value(s) to flash where you can pick it up using the remoting stuff in flash ?
one thing that confuses me about the php script in these amfphp examples is the $this->methodTable = array(
"getFLV" => array( stuff what is -> and => ive never used these operators in php.
=> seems like equal to or greater than ? anyway what is the concept behind amfphp and why do the php codes written for amfphp always look so strange to me ? is it just because ive never written classes in php or is it because they are using set vairables that correspond only to amfphp stuff ?
thanks for your help hobbis
hobbis
06-09-2006, 09:01 AM
amfphp requires that you write your classes in a certain way but generally they are quite similar to normal classes in php. E.g.
$instance = new Object();
$instance->someMethod($argument);
In amfphp, the method table is a requirement that registers your custome function and gives a description of it.
$this->methodTable = array(
"getClipData" => array(
"description" => "Returns recordset for FLV/video files",
"access" => "remote",
"roles" => "admin",
"arguments" => array ("user_id")
)
);
function getClipData($user_id) {
//do something and return something
}
The => is used in arrays or objects like this:
$a = array("a" => "apple", "b" => "banana");
so the key is "a" and the value is "apple" etc.
Then to acces these parts, use this kind of code:
foreach($obj as $key => $value)
{
echo $key . " : " . $value;
}
zonemikel
06-09-2006, 02:29 PM
Oh i see what your doing is making a array with a key and a value that makes sence but ive never done it before ... its amazing all the stuff i have done and with the little i know. if i were to make a array (which i never do) i would just call the var and set values as a array like this
$a= "a,apple,b,bannana";
$array=explode(",",$a);
while ($array){
echo "$array[] : $array[]";
}
that might work im not to sure .. i might need a incramenting i in there the point is i have never really actually made the arrays i have only exploded other strings and made them arrays. I remember in one webpage i had a array that held 10 colors and then called a random [i] every time the page was loaded to load a different color for the page. anyway ill stop before i start rambling :)
Im waiting for my client to give me some content and get to work on the dbase i have made them .. the whole page is controled by a control panel and they are the ones who add the products etc. so im at a standstill for a while. i hafto fix one thing about the page then im going to study amfphp and php classes for the rest of the day ... also im gonna get some examples and try them out in flash .. thats the best way to start.
ill get back to you this evening
thanks
hobbis
06-09-2006, 03:55 PM
No probs. Believe me, once you get your head around flash remoting, you'll never go back. It makes the communication between swf and database so much easier.
A good site to look at is www.flash-db.com (http://www.flash-db.com)
Good luck.
zonemikel
06-11-2006, 12:36 AM
Well i have tried the example here on actionscript.org the simple bb one ... it works great so i guess everything is working... It is awsome the speed of it and how it is so seemlessly inegrated into flash. Do you have any idea how i could make a amfphp service to return 2 results from a db .. i have this chatroom and i actually have it working in flash (i have no idea how itz a list that i screwed with untill it worked) but i want to remake it so it works with amfphp so i would just have a name and message returned from the dbase and maybe a setinterval so it checks for new messages ... i can safley mess around with that webpage without screwing with my clients page where i have allready set up the db and all .. if you want to see the page (chat room) im talking about to get a better idea it is here www.galvestonchatroom.com itz kinda a hobby/experiment website i made similar to myspace but i never get around to making it just the way i want it (finishing)
if you have any ideas let me know
thanks hobbis
hobbis
06-12-2006, 08:39 AM
I suppose you could use setInterval to run a remoting call. To return more than one result, I'm sure that you can return an array with the two results in it. I've never tries to create a chat room so I am not much help but good luck!
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.