-
Sending a Var outside of a MC to the root
Please help.
I brought a pre-built shopping cart and I'm trying to put some buttons in another MC but when I click them the cart don't update.
The original setup of the cart was:
The 'Add to cart' buttons are on the root and the cart was inside an MC also on the root.
Now I understand that it's not not working due to me moving the buttons into a MC.
Can anyone tell me what I have to do to make this work so I can have my buttons inside a different MC
This is the AS on the buttons originally:
on (press)
{
var item = new CartItem
("Product 1", 10.00, 1);
additem(item);
}
I tried putting the function for the button on the main stages but without any luck:
pages.CarlsB.onRelease = function () {
var item = new CartItem
("Product 1", 10.00, 1);
additem(item);
}
I really hope someone can help.
Many thanks,
Stuart.
-
Flashkit Veteran
You added the CartItem to the root actions rather than the button actions. You need to put
pages.CarlsB.item = new CartItem in that second piece of code if you want the CartItem object to be assigned to the button. I doubt that will fix the problem though, the code probably references that button in other locations as being at the root location... Give it a try but you might need to alter some other code.
-
Hi and thanks for the reply but, i'm not sure i understand fully. You say i've added the CartItem to the root. Do you mean i've put the function on the root instead of on the button itself?
Many thanks.
-
Flashkit Veteran
Yea, thats what I meant, you added the declaration of the CartItem to the root, so you have to change your reference path to match where the button now resides.
-
Any ideas how i would change the code to acheive this?
-
FK'n_dog
try passing parameters to a function on the root timeline -
PHP Code:
pages.CarlsB.onRelease = function () {
_root.myFunc("Product 1", 10.00, 1);
};
function myFunc(a,b,c){
item = new CartItem(a,b,c);
additem(item);
}
not tested...hth ??
-
That didn't work but it thinks it's because I don't really know AS well enough
is it best to have the AS on the root or on the buttons?
I though it wouldn't be too hard to put it in a a function like I originally did and as dog suggested.
Do i need to put a path on the Var item or new cart item - or the woud it be on the add item, and how would I do that exactly.
pages.CarlsB.onRelease = function () {
var item = new CartItem
("Product 1", 10.00, 1);
additem(item);
}
sorry this is very lame, it's just i'm still learning and I realy need to get this done for a friend.
Any help is much apreciated,
Many thanks.
-
var item at _root.
just wondering if you found a fix for this as I have a similar problem. I need to have the variable for the shopping cart passed to the _root. of the movie..
Any help would be great!!!
Thanx in advance guys!
-
Hi there,
Yes, I did get it sorted. Here's how.
My original problem was with this code sending the vars out of the MC to the root:
on (press)
{
var item = new CartItem
("VK Blue Large Bottle", 4.00, 1);
_parent.additem(item);
}
And I managed to get it to send the vars out to the root by using _parent. as shown below.
on (press)
{
var item = new _parent.CartItem
("VK Blue Large Bottle", 4.00, 1);
_parent.additem(item);
}
Hope this helps.
-
var item at _root.
THANK YOU THANK YOU THANK YOU!!!! that has saved me so many headaches!
you've really saved me some serious time here!.. so simple yet I would never had thought of it!
Thanx again my friend!
Monkai
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|