javascriptin'
- Started
- Last post
- 11 Responses
- Cenitgrade
Sorry for the another techie question but I'm at a loss... javascript is mental. Kinda fools you into thinking it's like AS but nope, it bitch slaps you in the face.
I'm trying to program a html button to to pass a variable into flash to set a nested movie to hide (_alpha = 0). I really am not getting Javascript. Any thoughts. It's late and my brain is numb. Or even a link to a good tut, because all the ones if seen are too techie!
Cheers m'lads and ladies.
- amullins0
javascript:
function getFlashObject( oid) {
return $.browser.msie ? window[oid] : document[oid];
}
getFlashObject( "flash-object-id" ).doSomething();
getFlashObject( "flash-object-id" ).doSomethingElse("from javascript");actionscript:
ExternalInterface.addCallback("d...
ExternalInterface.addCallback("d...
function doSomething(){
trace("did something");
}
function doSomethingElse(param1){
trace("did something " + param1);
}for your specific case
actionscript:
ExternalInterface.addCallback("s...
function setMCProperty(p,v){
//m = movieclip
m[p] = v;
}javascript:
function getFlashObject( oid) {
return $.browser.msie ? window[oid] : document[oid];
}
getFlashObject( "flash-object-id" ).setMCProperty("_alpha",0);- fyi: there's a little jquery in this $.browser.msie.amullins
- Cenitgrade0
thanks for the reply. However this section gives me an error...
ExternalInterface.addCallback("s...
function setMCProperty(p,v){
//m = movieclip
m[p] = v;
}it's because of the ("s...
what should this be?Cheers.
- Cenitgrade0
Bang bang bang bang... thats my head off the wall...
I can't get this to work. Here's what I have:in the html doc in the head section, movie ID is java:
<script type="text/javascript">
function hideRedBox() {
thisMovie("java").hideRedBox(nul...
}
function thisMovie(movieName) {
if (navigator.appName.indexOf("Micr... != -1) {
return window[movieName]
} else {
return document[movieName]
}
}
</script>
-------
Here the button that executes the javascript:<a href="#" title="Hide The Box" onclick="hideRedBox();">
Push here to hide Red Box
</a>
-------And in the flash file this AS2.0:
import flash.external.*;
ExternalInterface.addCallback("h...
function hideRedBox() {
my_redBox._alpha = 0;
}agghhhh why won't it work?
if I simply call the function in flash using
hideRedBox()
the box disappearsbut when I click the button in the html it doesn't.
- Cenitgrade0
hmmm the code above goes wonky in qbn.
the HTML bit after the ... =
...null)and after the ... Flash bit it should read:
"hideRedBox",null,hideRedBox)
- acescence0
you're calling hideRedBox() from js and passing arguments, but your hideRedBox function as defined in flash accepts no arguments. or at least that's what it looks like but it's hard to tell...
- Cenitgrade0
thanks acescence, but i'm still kinda confused.
Are you saying the javascript is correct but the flash code doesn't know how to accept the javascript commands?
I though I could just define a Flash function that would execute when flash "heard" the javascript. Or am I crazy?
- Cenitgrade0
cheers Acesence, that what I'm looking for.
I've copied yours pretty much exactly... but i won't work for me.
the my sample online:
http://centigrade.ca/agency3/tes…and this is the flash code (AS2) i've used.
http://pastebin.com/m6b1cbc3c
- acescence0
oh yeah, sorry, externalinterface.addcallback takes just 2 arguments in as3, but needs an instance argument in as2...
- Cenitgrade0
You sir are a genius. I am indebted to you! Next time i'm in SF I'll get you a beer in the Toranado.
- or buy you a fancy beer from BevMo as I used to work there.
Cenitgrade
- or buy you a fancy beer from BevMo as I used to work there.