[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-11
2
Medium Priority
?
158 Views
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.

0
Comment
Question by:madasczik
2 Comments
 
LVL 9

Expert Comment

by:dutchfoxer
ID: 12560462
getURL("javascript:resizeMovie('300','150')");

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:

http://www.moock.org/webdesign/flash/fscommand/
0
 
LVL 6

Accepted Solution

by:
nishasrilankan earned 2000 total points
ID: 12562175
You can check whether the variable is defined or not with following code

if(variable=='undefined'){
//returns true if variable is not defined
//code goes here
}
//

for javascript things...please refer http://www.actionscript.org/tutorials/intermediate/FS_Command_JavaScript_Library/index.shtml

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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. …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

830 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