fredmastro
asked on
Javascript controlled Flash
Ok let me show you want I'm trying to do...
I'm trying to make this... http://www.theblooded.net/guildpreviewer/default.asp
Using Flash... Like this page.. http://www.theblooded.net/guildpreviewer/flashversion.htm
I decided to use JavaScript talking to Flash like this page says you can do.. http://www.flashcentral.com/Tech/HawaiiMap/
There is a demo, notice on the bottom left you can move the bird to a specific frame or a frame at a time up or down.
Also, this page here http://www.moock.org/webdesign/flash/fscommand/ Shows me I can move frames too.
And here are the Flash Methods. http://www.macromedia.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
Hopefully, you are familiar with this in someway.
Anyway, they all say that I can do something like this...
document.flashfile.TGotoFr ame("_leve l0/Backgro undColor", 3)
This should go to my backgroundcolor movie clip and go to frame 2, so I read anyway. But in my movie on the second link up there... I have 3 flash movie clips in my movie, Background, Foreground and Symbols. I just want them to move up by one for right now, but I can't seem to get it working.
Later I'll want to replace one movie clip with another, but I'm not sure how to do that yet, that's another day.
I'll attach my movie so you can see. It's Flash MX or Flash 6.
The only other option would be too...
Some how make an FS command somewhere in the movie and then I can call it from JavaScript, and I can send it arguments, what movieclip to move, and what frame to go to.
Here's my movie I'm using: http://www.theblooded.net/guildpreviewer/sb%20guild%20emblem.zip
Here's the page I'm messing around with: http://www.theblooded.net/guildpreviewer/flashversion.htm
Tell me what I'm doing wrong, make this work for me! Provide me sample even! I'll up the points if I have too.
I'm trying to make this... http://www.theblooded.net/guildpreviewer/default.asp
Using Flash... Like this page.. http://www.theblooded.net/guildpreviewer/flashversion.htm
I decided to use JavaScript talking to Flash like this page says you can do.. http://www.flashcentral.com/Tech/HawaiiMap/
There is a demo, notice on the bottom left you can move the bird to a specific frame or a frame at a time up or down.
Also, this page here http://www.moock.org/webdesign/flash/fscommand/ Shows me I can move frames too.
And here are the Flash Methods. http://www.macromedia.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
Hopefully, you are familiar with this in someway.
Anyway, they all say that I can do something like this...
document.flashfile.TGotoFr
This should go to my backgroundcolor movie clip and go to frame 2, so I read anyway. But in my movie on the second link up there... I have 3 flash movie clips in my movie, Background, Foreground and Symbols. I just want them to move up by one for right now, but I can't seem to get it working.
Later I'll want to replace one movie clip with another, but I'm not sure how to do that yet, that's another day.
I'll attach my movie so you can see. It's Flash MX or Flash 6.
The only other option would be too...
Some how make an FS command somewhere in the movie and then I can call it from JavaScript, and I can send it arguments, what movieclip to move, and what frame to go to.
Here's my movie I'm using: http://www.theblooded.net/guildpreviewer/sb%20guild%20emblem.zip
Here's the page I'm messing around with: http://www.theblooded.net/guildpreviewer/flashversion.htm
Tell me what I'm doing wrong, make this work for me! Provide me sample even! I'll up the points if I have too.
hmmm ... just wonder why u will need buttons on javascript and only do the shield (emblem) in flash???
i mean if user can see flash, the have the player u might as well do the whole thing in flash ... it is much easier than passing variables from js to flash, back & forth...
if u are familiar with js, it is very much the same in action script, and in fact i found it easier.
what do u think?
have a glance at ur files, ... hmmm ... i don't think u can call one a particular movieclip to gotoFrame other than the maintimeline,...ur movieclip has no instance name anyway.
but if u really like the flash /js combination ...
u can try something like that
// javascript
function setVar2Flash(sym,shd,...) {
symVal = symVal + sym;
shdVal = shdVal + shd;
myFlash = InternetExplorer ? window.movie_name: window.document.movie_name ;
// this will pass the variable symValF to ur flash movie, make sure u have the movie_name = to the movie_name for the <object id="movie_name" ...> and the <embed name="movie_name" ... >
myFlash.setVariable("symVa lF",symVal );
myFlash.setVariable("shdVa lF",shdVal );
... etc
}
// for the button onClick
< .... name="btn_nxt" onClick="setVar2Flash(1,0. ..);" >
< .... name="btn_prev" onClick="setVar2Flash(-1,0 ...);>
.. etc etc ...
in ur flash, u have a onEnterFrame to monitor the variable changes
_root.onEnterFrame() = function () {
// symbol is the movieclip's instance name
// u can just refer to the variables here
_root.symbol.gotoAndStop(s ymValF);
_root.shield.gotoAndStop(s hdValF);
... etc ... etc ... etc
}
......
put your movieclips on the main timeline, name them properly and it will goto and stop at the selected frames.
cheers
i mean if user can see flash, the have the player u might as well do the whole thing in flash ... it is much easier than passing variables from js to flash, back & forth...
if u are familiar with js, it is very much the same in action script, and in fact i found it easier.
what do u think?
have a glance at ur files, ... hmmm ... i don't think u can call one a particular movieclip to gotoFrame other than the maintimeline,...ur movieclip has no instance name anyway.
but if u really like the flash /js combination ...
u can try something like that
// javascript
function setVar2Flash(sym,shd,...) {
symVal = symVal + sym;
shdVal = shdVal + shd;
myFlash = InternetExplorer ? window.movie_name: window.document.movie_name
// this will pass the variable symValF to ur flash movie, make sure u have the movie_name = to the movie_name for the <object id="movie_name" ...> and the <embed name="movie_name" ... >
myFlash.setVariable("symVa
myFlash.setVariable("shdVa
... etc
}
// for the button onClick
< .... name="btn_nxt" onClick="setVar2Flash(1,0.
< .... name="btn_prev" onClick="setVar2Flash(-1,0
.. etc etc ...
in ur flash, u have a onEnterFrame to monitor the variable changes
_root.onEnterFrame() = function () {
// symbol is the movieclip's instance name
// u can just refer to the variables here
_root.symbol.gotoAndStop(s
_root.shield.gotoAndStop(s
... etc ... etc ... etc
}
......
put your movieclips on the main timeline, name them properly and it will goto and stop at the selected frames.
cheers
ASKER
Hmm, kind of confused on that there.
I thought I made my movie an instance already. when I did New Symbol. Or do I have to still covert it to symbol?
that Hawaii link I showed you, they are controlling the bird and it's a movie clip.
I didn't do it all in flash because I don't know flash that well.
I thought I made my movie an instance already. when I did New Symbol. Or do I have to still covert it to symbol?
that Hawaii link I showed you, they are controlling the bird and it's a movie clip.
I didn't do it all in flash because I don't know flash that well.
yes that's right too ... sorry ... the TGotoFrame ... not GotoFrame ... sorry ...
but u don't have an instance name that's why ...
u want me to fix the html for u & fla for u ...?
but u don't have an instance name that's why ...
u want me to fix the html for u & fla for u ...?
ASKER
Yes if you could. I know VBScript very well, and so I usually do something in VBScript then figure out how to do it in Javascript since I'm weak in Javascript.
If you could fix those two files then I could take a look.
If you could fix those two files then I could take a look.
i missed one line there in js function ...
var InternetExplorer = navigator.appName.indexOf( "Microsoft ") != -1;
myFlash = InternetExplorer ? window.movie_name: window.document.movie_name ;
almost there ... 5 mins ... :P
var InternetExplorer = navigator.appName.indexOf(
myFlash = InternetExplorer ? window.movie_name: window.document.movie_name
almost there ... 5 mins ... :P
ok here u go...
http://www.smartclever.net/flash/example/emblem/
index.html (view source u can see)
SB Guild Emblem.swf
SB Guild Emblem.fla
there is little problem though if u click prev and eventually < 1, u will have to hit next a few times to make it go to the next frame, same for next, if u pass the end then u will have to press previous a few times ...
we can fix the "sym" in javascript so it will always be >= 1, but u can't do it for the max ... unless u hardcode the max, but everytime u add a new symbol u will have to change the javascript as well too ...
have a look ... :)
http://www.smartclever.net/flash/example/emblem/
index.html (view source u can see)
SB Guild Emblem.swf
SB Guild Emblem.fla
there is little problem though if u click prev and eventually < 1, u will have to hit next a few times to make it go to the next frame, same for next, if u pass the end then u will have to press previous a few times ...
we can fix the "sym" in javascript so it will always be >= 1, but u can't do it for the max ... unless u hardcode the max, but everytime u add a new symbol u will have to change the javascript as well too ...
have a look ... :)
ASKER
hmm link doesn't work.
Can I download the files from this link?
Can I download the files from this link?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok well your's works great. For some reason I can change yours to point to my file and it works fine...
http://www.theblooded.net/guildpreviewer/henryflashjava.htm
but if I use my page it doesn't work at all still.
http://www.theblooded.net/guildpreviewer/flashversion.htm
would be nice if I understood why, so I can add to it.
Thank you for your help, this give me something to work off of.
http://www.theblooded.net/guildpreviewer/henryflashjava.htm
but if I use my page it doesn't work at all still.
http://www.theblooded.net/guildpreviewer/flashversion.htm
would be nice if I understood why, so I can add to it.
Thank you for your help, this give me something to work off of.
i really have to go now .. :)
see u
see u
oh ...
yeah ur javascript ...
compare my index with urs ...
it looks a bit messy there :)
cheers & thanks
yeah ur javascript ...
compare my index with urs ...
it looks a bit messy there :)
cheers & thanks
ASKER
woohoo it's working good now...
now I just have to convert it all to Javascript.
http://www.theblooded.net/guildpreviewer/flashdefault.asp
now I just have to convert it all to Javascript.
http://www.theblooded.net/guildpreviewer/flashdefault.asp
so i will see what's wrong and get back to u later :)
cheers