How do you express if a passed in variable is defined?

Posted on 2004-11-11
Last Modified: 2010-04-07
I'm using 2 instances of a single swf file on my webpage, one on the left nav and one on the right nav.  Both of which I'm trying to output from flash, the height of the movieclip that is generated dynamically.  Since i'm using the same swf I changed the id on the param and embed tags so the javascript function can resize each accordingly.  I'm having trouble with some syntax though to specify wheather a variable is defined or not in flash.

How do I express if a variable is defined in flash?
I also need to add on the same variable to the javascript function name, confused on the syntax.

Here's what I got so far:

if (_root.siteID ???is defined???) {
    var jsFunction = "resizeMovie" + _root.siteID;
else {
    var jsFunction = resizeMovie;

getURL("javascript:jsFunction('" + navWidth + "','" + startLeftNavY + "');");

or should it go something like this:

if (_root.siteID ???is defined???) {
     getURL("javascript:"resizeMovie" + _root.siteID('" + navWidth + "','" + startLeftNavY + "');");
else {
     getURL("javascript:resizeMovie('" + navWidth + "','" + startLeftNavY + "');");


I think the first one is more on track but I am unsure, any help would be greatful.

Question by:madasczik
    LVL 9

    Expert Comment


    and then in page script:

    function resizeMovie(mywidth,myheight)

    But you can also use VBscript and FScommand to have flash talk to Html and back. See a nice and complete tutorial here where multiple methods are explained in detail:
    LVL 6

    Accepted Solution

    You can check whether the variable is defined or not with following code

    //returns true if variable is not defined
    //code goes here

    for javascript things...please refer


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
    This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now