[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

passing variables in to flash using case statements

Posted on 2003-12-04
7
Medium Priority
?
522 Views
Last Modified: 2008-03-10
Does any one know how to pass a variable into flash from a html file using javascript cases.  e.g:

I am trying to use:

<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
 switch (sParam)
    {
    case "Slide1":
       //variable i am trying to pass 'name = XXX' where slides is the id/name of the flash file.
       break;

    case "Slide2":
       //variable i am trying to pass 'name = YYY' where slides is the id/name of the flash file.
       break;       
                   
    }
</SCRIPT>


so as each different case statement is matched a different value for the variable is passed.

Does any one know the script i can use to do this?  I need an example.

Thanx
0
Comment
Question by:Jyontex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 27

Accepted Solution

by:
negatyve earned 400 total points
ID: 9877570
<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
switch (sParam)
{
      case "Slide1":
            var myvariable = "hello"
            break;
      case "Slide2":
            var myvariable = "byebye"
            break;      
}
var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.slides : window.document.slides;
targetMovie.SetVariable("variable_name", myvariable);
</SCRIPT>
0
 

Author Comment

by:Jyontex
ID: 9881303
Hi this looks like the kind of thing i want but still cannt get it to work.

i am using:

<HEAD>
<TITLE>Test</TITLE>

</HEAD>
<BODY bgColor=#FFFFFF text=#ffffff>
<SCRIPT FOR="MediaPlayer" EVENT="MarkerHit(lMarkerNum)" LANGUAGE="JScript">
{
      MediaPlayer.Play();
}
</SCRIPT>
<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
 switch (sParam)
    {
    case "Slide1":
       var frameName = "a1"
       break;

    case "Slide2":
       var frameName = "b1"
       break;

    case "Slide3":
       var frameName = "c1"
       break;

var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.Slides : window.document.Slides;
targetMovie.SetVariable("frameName", frameName);       
                   
    }
</SCRIPT>
<table width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><OBJECT ID="MediaPlayer" WIDTH=320 HEIGHT=240
    CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
    STANDBY="Loading Windows Media Player components..."
    TYPE="application/x-oleobject" align="middle" vspace="0">
        <PARAM NAME="FileName" VALUE="test.wmv">
        <PARAM NAME="ShowControls" VALUE=true>
        <PARAM NAME="DisplaySize" VALUE=0>
        <PARAM NAME="AutoStart" VALUE=true>
        <EMBED TYPE="application/x-mplayer2"
    SRC="test.wmv"
    WIDTH=320
    HEIGHT=240 align="middle" vspace="0"> </EMBED> </OBJECT></td>
  </tr>
  <tr>
    <td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" width="80" height="20" align="top" id="Slides">
        <param name=movie value="test.swf">
        <param name=quality value=high>
        <embed src="test.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" align="top">
        </embed> </object></td>
  </tr>
</table>
</BODY>
</HTML>

and a simple dynamic text box in the flash to display the value passed in the parameter.

Can you see where i'm going wrong?
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9881473
What does this script do?

<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Jyontex
ID: 9881599
its picking up variables passed from the wmv and passing it to the switch statement.  (that works), so you can ignore that bit.  Only having problems passing new variables to the flash fom there.
0
 
LVL 27

Expert Comment

by:negatyve
ID: 9881812
Before I make any test, if you try:

switch (sParam)
{
      case "Slide1":
            var frameName = "a1"
            break;

      case "Slide2":
            var frameName = "b1"
            break;

      case "Slide3":
            var frameName = "c1"
            break;
}
alert(frameName)

what happens?
0
 

Author Comment

by:Jyontex
ID: 9881890
it doesnt work.  the alert needs to be within the case.

and your script works if i use:

<SCRIPT FOR="MediaPlayer"
        EVENT="ScriptCommand(sType, sParam)"
        LANGUAGE="JScript">
 switch (sParam)
    {
    case "Slide1":
       var frameName = "a1"
var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.Slides : window.document.Slides;
targetMovie.SetVariable("frameName", frameName);
       break;

    case "Slide2":
       var frameName = "b1"
var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.Slides : window.document.Slides;
targetMovie.SetVariable("frameName", frameName);
       break;

    case "Slide3":
       var frameName = "c1"
var IE = navigator.appName.indexOf("Microsoft") != -1;
var targetMovie = IE ? window.Slides : window.document.Slides;
targetMovie.SetVariable("frameName", frameName);
       break;
             
    }
</SCRIPT>

can this be simplified?
0
 

Author Comment

by:Jyontex
ID: 9881900
Its ok....i put the script into a simple function.

Thanx for your help
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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…
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses

650 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