?
Solved

Javascript controlled Flash

Posted on 2003-03-23
13
Medium Priority
?
254 Views
Last Modified: 2010-08-05
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.TGotoFrame("_level0/BackgroundColor",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.
0
Comment
Question by:fredmastro
[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
  • 8
  • 5
13 Comments
 
LVL 6

Expert Comment

by:henryww
ID: 8191164
ok .. .got the file. again is bit late here.
so i will see what's wrong and get back to u later :)
cheers
0
 
LVL 6

Expert Comment

by:henryww
ID: 8191261
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("symValF",symVal );
myFlash.setVariable("shdValF",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(symValF);
    _root.shield.gotoAndStop(shdValF);
    ... etc ... etc ... etc
}

......

put your movieclips on the main timeline, name them properly and it will goto and stop at the selected frames.

cheers
0
 
LVL 2

Author Comment

by:fredmastro
ID: 8191289
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.
0
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!

 
LVL 6

Expert Comment

by:henryww
ID: 8191307
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 ...?
0
 
LVL 2

Author Comment

by:fredmastro
ID: 8191321
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.
0
 
LVL 6

Expert Comment

by:henryww
ID: 8191371
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

0
 
LVL 6

Expert Comment

by:henryww
ID: 8191425
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 ... :)
0
 
LVL 2

Author Comment

by:fredmastro
ID: 8191460
hmm link doesn't work.

Can I download the files from this link?
0
 
LVL 6

Accepted Solution

by:
henryww earned 1600 total points
ID: 8191494
???
oh i am sorry ...
http://www.smartclever.net/example/flash/emblem/
get it the other way round ...
0
 
LVL 2

Author Comment

by:fredmastro
ID: 8191577
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.
0
 
LVL 6

Expert Comment

by:henryww
ID: 8191578
i really have to go now .. :)

see u
0
 
LVL 6

Expert Comment

by:henryww
ID: 8191588
oh ...

yeah ur javascript ...
compare my index with urs ...

it looks a bit messy there :)

cheers & thanks
0
 
LVL 2

Author Comment

by:fredmastro
ID: 8191657
woohoo it's working good now...

now I just have to convert it all to Javascript.

http://www.theblooded.net/guildpreviewer/flashdefault.asp

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

762 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