PDA

View Full Version : Global Function


slen
07-18-2005, 03:20 AM
I am having trouble in movie clips. Below is my scenario:

I have 2 movie clips. One of the movie clips, image_mc, has a scrollPane, image_scroll. In the movie has a global function.
_global.myFunctio = function(myname)
{
image_scroll.contentPath = myname;
}

In another movie, “scrollers”, the action script look like this.

….
myWindow=popupManage … (... {…ContentPath: “image_mc”…})
_global.myFunction(“Hello_mc”);



My global function isn’t been invoked. Can anyone give me some suggestion to this problem? I am using this approach because I want to have a popup window appears when a picture button is clicked in the movie clip, scrollers. When “image_scroll” is loaded, if the size of the pass in mc is big, it automatically shows the scrollbars. If my approach isn’t right, do you know any approach is good?

Please help me …

Thank you very much ….

badlorry
07-18-2005, 02:04 PM
in the example you give, you have a function declaration for a function called

_global.myFunctio

and then later you try and call a function called

_global.myFunction(“Hello_mc”);

with an "n" on the end of it

otherwise, it could be a path problem to the image_scroll MC, which you are calling from the _root of the movie when using the global function.

image_mc.image_scroll.contentPath = myname;

slen
07-18-2005, 03:18 PM
Thanks for your reply.

I corrected my function. I put an "n" at the end of the "functio". I also added "image_mc" in front of the "image_scroll.contentPath = myName;"; however, it still doesn't invoke the function.

Any idea to my situation?

Thanks

slen
07-22-2005, 01:59 AM
Can anyone help me ...

csdstudio
07-22-2005, 02:56 AM
Can anyone help me ...


Yap. By calling the function that's been declared in the _global scope, that function is looking for image_scroller in the _global scope and it doesn't exist there. It exists in the _level0 scope;

Try accessing image_scroller this way:

_level0.image_scroller.content....

oldnewbie
07-22-2005, 02:59 AM
The above is MX2004 specific syntax and this is a MX and LOWER only forum, not a MX2004 one. Please post on the appropriate MX2004 forum. ;)

http://www.actionscripts.org/forums/forumdisplay.php3?f=34

slen
07-23-2005, 03:33 PM
Thanks for ur reply ...

I tried it puttin' _level0 or 1, but it doesn't work...

The library structure is -
- "scoller" mc in the "firework Object" folder
- "image_mc" in the "firework Object/products/prdt_des" folder
- "symbols_mc"(will be loaded according the global function pass in parameter) in the same directory of "image_mc"

When ‘scoller” popup a window, it loads "image_mc", and calls a global function in "image_mc", which will load the specified symbols (could be one of "symbols_mc") to "image_scoll" (scrollpane in "image_mc")

Here is the popup Window in scroll:
myWindow = mx.managers.PopUpManager.createPopUp(this,mx.conta iners.Window, true, {title:"Product Description", contentPath:"image_mc", closeButton:true});

Any idea of the my problem ...

Please help ..