Solved

passing variables in to flash using case statements

Posted on 2003-12-04
7
515 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 100 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

705 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