In flash itself. Something like:
function init(){
if (inited == null)
{
inited = true;
var InfoService = new Service( connection info here)
}
}
init();
I'm not sure how you are calling your webservice or coldfusion pages to
recieve data or if you using actionscript 1 or 2 but "new Service()" is
actionscript 2 remoting.
The Flash is being exported as Flash 7 and uses ActionScript 2.0. Here's the
ActionScript that calls the products from the database:
[h]//-- box styles
lb_ProductList.setStyle("backgroundColor","0xF3E6E0");
lb_ProductList.setStyle("borderStyle","none");
_root.product_details_mc.colours.setStyle("fontSize","9");
_root.product_details_mc.sizelist.setStyle("fontSize","9");
_root.product_details_mc.quantity.setStyle("fontSize","9");
_root.product_details_mc.quantity.setStyle("backgroundColor","0xF2ECD9");
_root.product_details_mc.quantity.setStyle("borderStyle","solid");
_root.product_details_mc.quantity.setStyle("borderColor","0x999999");
//--
var z=1;
while(z < 15){
setProperty(_root.swatches["swatch" + z], _visible, false);
z++;
}
// Include the Required NetService class files
#include "NetDebug.as"
#include "NetServices.as"
// connect to the Flash Remoting service provider
if (isGatewayOpen == null) {
// do this code only once
isGatewayOpen = true;
// Make the Gateway connection
NetServices.setDefaultGatewayUrl("http://OURIPADDRESS/flashservices/gateway");
gatewayConnnection = NetServices.createGatewayConnection();
}
productService=
gatewayConnnection.getService("com.clientname.product_range_new", this);
trace("Connected");
// CALL Web service: Do initial Data load for DropDown List
productService.product_range();
trace("sent request");
function getProductsList() {
// Check first list item is not selected
if(bob.getSelectedIndex() != 0){
// Invoked when a user selects a product Type from the ComboBox
trace("sent request. ProductType: " + bob.text);
// invoke the "getProductsList" method in the productService service, send
current selection
productService.product_range2(bob.text);
}
}
function product_range2_Result(result){
// populate the list box with products of the selected type
trace("server responded: Records: " + result.getLength());
trace("setting the ListBox");
lb_ProductList.setDataProvider(result);
}
function product_range_Result(result) {
trace("server responded: Records: " + result.getLength());
trace("setting the Drop Down");
// This function will be invoked by the server when it has finished processing
bob.setDataProvider(result);
bob.labelField = "range_name";
}
function getProductDetails() {
// Invoked when a user selects a product Type from the ComboBox
trace("sent request. Product id: " + lb_ProductList.selectedItem.data);
// invoke the "getProductsList" method in the productService service, send
current selection
productService.product_details(lb_ProductList.selectedItem.data);
// retrieve all styles for this item
productService.product_styles(lb_ProductList.selectedItem.data);
}
function getSizes() {
productService.product_sizes(lb_ProductList.selectedItem.data,_root.product_det
ails_mc.colours.selectedItem.label);
}
_root.product_details_mc.product_name="";
function product_details_Result(result){
// This is the final bit which displays the product details. It just takes
the values from the server and puts them into the mc product_details_mc
trace("server responded: Records: " + result.getLength());
_root.product_details_mc.product_name=result.items[0].product_name;
_root.product_details_mc.product_description=result.items[0].product_descriptio
n;
if (result.items[0].price != "0"){
_root.product_details_mc.price="?"+(result.items[0].price)+".00";
}
trace("On Sale: " + result.items[0].onsale);
if (result.items[0].onsale == "yes"){
setProperty(_root.product_details_mc.strike, _visible, true);
_root.product_details_mc.saleprice="SALE:
?"+(result.items[0].saleprice)+".00";
}else{
setProperty(_root.product_details_mc.strike, _visible, false);
_root.product_details_mc.saleprice="";
}
}
function product_sizes_Result(result){
trace("server responded: Size Records: " + result.getLength());
_root.product_details_mc.sizelist.setDataProvider(result);
}
function product_styles_Result(result){
trace("server responded: Records: " + result.getLength());
_root.product_details_mc.colours.setDataProvider(result);
setProperty(_root.product_details_mc, _visible, true);
getProductImage();
getSizes();
loadColourChart();
}
function loadColourChart(){
_root.colourArray = new Array();
_root.loadedcolours = 0;
_root.overlay.gotoAndPlay("fadeout");
_root.overlay.loadingtxt = "Loading colours...";
var numcolours = _root.product_details_mc.colours.length;
var x=0;
_root.maxcolours = numcolours;
while(x < numcolours){
var thiscolor = _root.product_details_mc.colours.getItemAt(x).label.split("
/ ");
productService.swatches(thiscolor[0]);
if(thiscolor.length==2){
productService.swatches(thiscolor[1]);
_root.maxcolours = _root.maxcolours + 1;
}
x++;
}
}
function swatches_Result(result){
if (array_search(result.items[0].colour_name, _root.colourArray)===false){
var colorpos = _root.colourArray.push(result.items[0].colour_name);
set("_root.swatches.swatch" + colorpos + ".colourlabel",
result.items[0].colour_name);
_root.swatches["swatch" +
colorpos].loadimg.loadMovie("http://www.ourdomain.co.uk/images/colour_chart/" +
result.items[0].swatch);
}else{
_root.loadedcolours = _root.loadedcolours + 1;
}
}
function array_search(needle, haystack) {
var y;
var found=false;
for (y=0; y<haystack.length; y++) {
if (haystack[y]==needle) {
found=true;
break;
}
}
if (found==true)
return (y);
else
return (false);
}
function getProductImage(){
// this removes the instuction text
setProperty(this.prodInstructions, _visible, false);
// this shows the loading mc
setProperty(this.loading, _visible, true);
// This populates the product details movie clip and loads the image.
if (_root.played_once){
// there is already a product image there. Use this to remove it before
loading in the new one below.
removeMovieClip(_root.product_details_mc.image_holder)
}
// duplicate movie loader movie clip so that it the duplicate can be deleted
when it's time to remove it.
duplicateMovieClip(_root.product_details_mc.image_loader, "image_holder", 50)
// pass the variables so it knows what image to load.
_root.product_details_mc.image_holder.product_image=_root.product_details_mc.co
lours.selectedItem.data;
_root.product_details_mc.image_holder.gotoAndPlay(2);
}
function addToCart(){
productService.addtocart(_root.userid,lb_ProductList.selectedItem.data,_root.pr
oduct_details_mc.colours.selectedItem.label,_root.product_details_mc.sizelist.se
lectedItem.label,_root.product_details_mc.quantity.text);
}
stop();[/h]
We are really stumped so any help is much appreciated.