Topic: Actionscript & Javascript - Possible? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=11319" title="Pages that link to Topic: Actionscript &amp;amp; Javascript - Possible? (Page 1 of 1)" rel="nofollow" >Topic: Actionscript &amp; Javascript - Possible? <span class="small">(Page 1 of 1)</span>\

 
Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 05-16-2002 09:40

Hmmm... How to phrase this...

Ok, say I have a very simple looping animation. Just a couple of shapes, simple colors, simple shapes. eg; A simple animation of a clock constantly turning. Could I possibly use some combination of Javascript & Actionscripting to define the colors of the shapes in the animation.

Would I be able to embed a .swf file in a HTML page and set it's colors by passing variabules to it through Javascript? Or, use actionsctipt to pull color codes slapped onto the end of the html page url and color the objects accordingly?

I've only ever brushed my nose with actionscript and flash before but if something like this would be possible then I'd be more than willing to learn it.

Many many thanks in advance.

# Don't burn your bridges, take them with you! #

kretsminky
Maniac (V) Inmate

From: A little lower... lower... ahhhhhh, thats the spot
Insane since: Jun 2000

posted posted 05-16-2002 18:04

I know that JS and AS can interact. I'm not sure about how well they play together though.

For instance, you can call a JS through Flash by using the getUrl command and using the old javascript:/ thingy.

I'm sure Steve or Grumble will know a bit more about it than I do.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-16-2002 20:17

There's an actionscript function that's supposed to interact with javascript... i don't have flash installed on XP yet so I can't look it up... but i think it has the word "command" in it or something... sorry, I forget. Have you searched the docs yet?

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 05-17-2002 16:46

im not very sure about this myself.
but in the object-tag there are parameter-tags.
maybe you can access them via javascript. dont know if it works dynamically though.

from the flash side i dont know about any possibility yet. maybe slime finds somethin.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-17-2002 21:35

Found it. Look up the "fscommand" function in actionscript.

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 05-17-2002 23:44

fscommand it is.

But I'd be wary. Not all browsers support. Mac IE for one.

However, there might be ways.... ActionScript has powerful color object capabilities. And, as Krets mentioned, you can inbed javascript in the body of the containing page's html and call it from Flash - that's the standard way of opening a new window with Flash.

If you wanted to change the color of a symbol's instance with ActionScript (intirely in Flash), that's pretty straightforward. Not real easy, but do-able. To get a javascript generated variable into Flash... I'm sure it's not impossible, but it's not as straightforward and at least in some instances the limitations are due to the browser, not Flash or JavaScript.

By the way - the animation might have to be created with actionscript instead of tweened frames. I don't know. Getting a symbol to rotate in a circle like a clock isn't hard with ActionScript, and the symbols involved aren't "tampered" with the way they are in a tween. In order to change a symbol's properties with script, you have to be able to address the specific symbol. I really don't know if symbols remain "addressable" in that way when they're being morphed in a tween. Interesting question.

[This message has been edited by Steve (edited 05-17-2002).]

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 05-18-2002 16:17

Arrr... good points all round.

Looks like I have a little research on my hands.

As for the animated clock face, sould be fairly easy with a-script. I'd just make a sybmol of a circle and mask out everything but the hand then rotate yes?...

fscommand looks interesting. Although no Mac IE support is just poo if you ask me. Maybe I could get by using predefined text files and the loadVariables() command...

Thanks for all of the comments. I was hoping this would be simpler. Hah! When has that ever been the case with web technologies! Figures...

Steve
Maniac (V) Inmate

From: Boston, MA, USA
Insane since: Apr 2000

posted posted 05-19-2002 20:48
quote:
I'd just make a sybmol of a circle and mask out everything but the hand then rotate yes?...



uhh - no.

I mean, I guess I'm assuming you want the clock to tell the right time.

First - most clocks have multiple hands. Second - how do you figure just rotating some element will keep time? You need to hook into Flash's Date Object.

Colin Moock has a visually spare but extremely useful example at his Code Depot: http://www.moock.org/asdg/codedepot/

Scroll down to chapter 13 - Analog Clock

He does it all with AttachMovie and the Date Object. Each hand is an instance of the same symbol, adjusted for size and color with ActionScript, and taking it's individual rotation instructions from the Date Object. This is a GREAT example of ActionScript working directly on symbol instances. Download the fla and take it apart. You'll learn a lot!

quatroGringo
Nervous Wreck (II) Inmate

From: Minneapolis, MN, USA
Insane since: Apr 2002

posted posted 05-25-2002 21:12

Use the Flash Color object to dynamically change the color, you can do this incrimentally with a looping statement. There are plenty of tutes on how to do this at http://www.flashkit.com.

You can also retrieve the time with Flash's clock functions and animating can be done via ActionScript or with a frame by frame animation - then referencing the desired frame depending on the time.

It can all be done right in Flash, no need for javaScript.

5G

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 05-30-2002 08:31

Arrr, actually the clock wasn't going to tell the correct time, it was just going to be a little loading animation. Thus da loopin.

Although I did download that FLA. Nice link steve.

quatroGringo, It's not a matter of setting the colour of an object in flash. I want flash to get the color values from an external source. Like from a text document or better yet, something added to the end of a url. ANyways, I've had to put this on hold again as I have a throng of assignment to get done over the next week or two.

Sorry I didn't reply sooner. I've been really busy. If I still can't get the problem sorted when I finally get around to making this it i'll be sure to dreadge this topic back up again. I'll have some broken examples of it then as well...



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu