Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > HTML and JavaScript

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-29-2012, 02:29 PM   #1
developerSpy
Registered User
 
Join Date: Jun 2012
Posts: 4
Unhappy Passing Variables From Javascript to AS3

Hey, new here and in a major bind. I need to pass a variable back to flash from my Javascript. The variable will change which video is being playing in the .swf by click on the link.

HTML:
<a href="javascript:void(0);" onClick="swapVideo();" ><i>Video</i></a>

JAVASCRIPT CODE:
var flashVidSource;
flashVidSource = 'video1';

//swapVideo when bio is clicked
function swapVideo(str)
{
//point to flashVideo player
getFlashMovie("introPlayer.swf").sendToActionscrip t(str);
//check conditional value
if(flashVidSource == 'video1')
{
//toggle from video1 to video2
flashVidSource = 'video2';
}else{
//toggle from video2 to video1
flashVidSource = 'video1';
}
//pass the string to introPlayer.swf
callToActionscript(flashVidSource);
}

ACTIONSCRIPT 3:
import flash.external.ExternalInterface;
//listen for javaScript
ExternalInterface.addCallback("swapVideo", swapVideo);


//set the intial source of videoMc by calling the function and pushing the string
swapVideo("video1");

function swapVideo(str):void
{
trace("swapVideo");
//depending on the string passed from JavaScript, display correct video
//video1
if (str == "video1")
{
//aiello's path
videoMc.source = "video1.flv";
}
//video2 if (str == "video2")
{
//video2's path
videoMc.source = "video2.flv";
}
}


It is not working, PLEASE HELP!

Last edited by developerSpy; 06-29-2012 at 03:29 PM.
developerSpy is offline   Reply With Quote
Old 06-30-2012, 04:15 AM   #2
USAFDrew2011
Flash_Developer
 
Join Date: Jul 2011
Location: Layton City, Utah
Posts: 185
Default

This kind of seems similar to what you are trying to accomplish:

http://www.flashwonderland.com/html-...ml-button.html
USAFDrew2011 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:58 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.