Topic: Set transparency in Director (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=11417" title="Pages that link to Topic: Set transparency in Director (Page 1 of 1)" rel="nofollow" >Topic: Set transparency in Director <span class="small">(Page 1 of 1)</span>\

 
Fey
Bipolar (III) Inmate

From: The Netherlands
Insane since: May 2003

posted posted 05-20-2003 15:52

I'm working on my final report of my current traineeship, and it has to be a multimedial production (CD Rom) I chose to make it in Director, not as a flash-website as many of my classmates, but as a full screen production.
The main screen consists of a background image, a menu and some minor animations. Or it would have those animations if it weren't for my unexcusable absolute non-talent for Lingo *grrmmmbl*

The animation an sich is very simple. There is a tree on whose branches flowers bloom. It can be translated to the following code:

global counter

on enterFrame me
counter = counter + 1
if counter < 60 * 60 then
go to the Frame
else
if counter >= 60 * 60 then
go to frame2
counter = 0
end if
end if
end

Don;t bother with testing it: this piece of code works just fine.

What happens after this is that the movie starts to play on frame 2 and slowly the flower becomes visible. This takes 500 frames.

After that, when the visibility is 100%, the counter kicks in again in a frame script, and the movie waits another minute (60 * 60 ticks) before the visibility gradually fades to 10%. This also takes 500 frames.

Now, this flower takes about three minutes to complete it's cycle from unvisible to visible to invisible again. But I want flowers that have an even longer cycle and I don't want my score to become 2000 frames or maybe more.

Then I thought: hey, if I take a new movie, make the cycle and then put it all in a movie-loop and then import this loop into my main movie I'm done. But for some reason, the loop doesn't include my scripting, so I lose the 2 delays of 3600 ticks.

Now I see two options: I find a way to link the increase of the opacity of the flower to the ticks and I imagine it would go something like:

if counter > 300 then
if counter = counter + 50 then
sprite (1).opacity = sprite (1).opacity + 10%
end if
end if

(I know this is not the correct syntax but if this is the correct solution, then someone please tell me the right syntax?)

Or another possibility is that I create two loops, one for the increase and one for the decrease of the opacity of the flower and I use the option to change the castmember of the sprite after every x ticks. That would like:

on exitframe me
counter = counter + 1

if counter >= 60 * 60 then
set the member of sprite(1) to loop1
counter = 0
counter = counter + 1
end if

if counter >= 60 * 60 then
set the member of sprite(1) to loop2
counter = 0
counter = counter + 1
end if

end

and then on frame 5 (or whichever following frame) I create a loop of "On exit frame me go to the frame"

Now, is one of these a good solution and if it is, what would be the correct syntax?

Thank you very much for at elast reading my post this far I'd be even more grateful for a sensible reply because I really don't know it anymore.

The summary: what's the best way of taking a long time to change the opacity of a sprite from 0 % to 100 % and back to 0 % again?



Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 05-21-2003 06:27

Alrighty then, I don't understand what your trying to do without actually seeing the project (linking to your DIR file might help) but I just thought I'd run with this:

quote:
The summary: what's the best way of taking a long time to change the opacity of a sprite from 0 % to 100 % and back to 0 % again?



But I'm still a little confused. You've got the right idea, but I think your not quite understanding how lingo can work without needing to progress through the score. Anyways, try knocking up a quick test with the code below and that should help you figure out how to get what you actually want:

Sprite Script (Behaviour):

property myCounter, myStaticLimit, myLimit, mySprite

on beginSprite me

mySprite = sprite(me.spriteNum)
mySprite.blend = 0
myCounter = 0
myStaticLimit = 200 --// The ammount of frames for sprite x, Best to put this in a propertyDescriptionList handeler so you can set it form the behaviour property dialouge box.
myLimit = myStaticLimit

end on

on exitFrame me

put myCounter

if myCounter < myLimit then

myLimit = myStaticLimit
myCounter = myCounter +1 --// Increase Opacity Counter

else if myCounter >= myLimit then

myLimit = 1 --// Set the limit back to 1 (it's 1 because we're testing for '>=') to count down
myCounter = myCounter - 1 --// Decrease Opacity Counter

end if

mySprite.blend = integer((myCounter.float/myStaticLimit.float)*100) --// Translate Frames Passed to Percentage for alpha value


end on


That bit of code will slowly fade in whatever sprite you drop it on from 0% to 100% over 200frames then back again over another 200 frames, then back to 100% again and so on and so on, untill you stop the movie.

This only requires one frame in the score, but you'll have to add a little frame script with:

on exitFrame
go the frame
end on

This will cause it to loop indefinatly on that frame and trigger the exitFrame handeler for the sprite with the blend behaviour on it.

I hope that's kinda what you were asking for. Anyways, just write that up in a little demo for youself so you understand how it all works and hopefully you'll be able to apply the same logic your project. Best of luck =)

Edit: Just to make sure this would work I did up a couple of quick tests:
http://www.whatever.net.au/~cameron/testMovie.dir -- Director MX PC/MAC file
http://www.whatever.net.au/~cameron/fadeTest.exe -- Projector EXE, PC only, requires Shockwave Plugin (The non Shockwave version was 2 meg!)

NB: Scan the EXE file for viruses! I scan my PC regurarly but I can't garuntee anything.

Anyways, I hope this helps.



[This message has been edited by Dracusis (edited 05-21-2003).]

Fey
Bipolar (III) Inmate

From: The Netherlands
Insane since: May 2003

posted posted 05-21-2003 10:28

Thank you very much! This is a great help

I tested it and made some adaptions so that I could control the start of the blending phases and now the script looks like this:
(and for the dir see here)

property myCounter, myStaticLimit, myLimit, mySprite, myPause, myTeller

on beginSprite me

mySprite = sprite(me.spriteNum)
mySprite.blend = 0
myCounter = 0
myPause = 0
myTeller = 0
myStaticLimit = 200 --// The ammount of frames for sprite x, Best to put this in a propertyDescriptionList handeler so you can set it form the behaviour property dialouge box.
myLimit = myStaticLimit


end on

on exitFrame me

-- put myCounter

if myCounter < myLimit then
myTeller = myTeller + 1
put myTeller
if myTeller >= 50 then
myPause = 0
myLimit = myStaticLimit
myCounter = myCounter +1 --// Increase Opacity Counter
end if



else if myCounter >= myLimit then
myPause = myPause + 1
put myPause
if myPause >= 100 then
myLimit = 1 --//Set the limit back to 1 (it's 1 because we're testing for '>=') to count down
myCounter = myCounter - 1 --//Decrease Opacity Counter
end if

end if

mySprite.blend = integer((myCounter.float/myStaticLimit.float)*100) --//Translate Frames Passed to Percentage for alpha value

end on

Now it works fine, good enough for my production I'd say So thanks

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 05-21-2003 15:46

You might want to remove the put variableX lines as all they do is output the value of said variable to the message window. There were a couple of typo's in the first script I typed in so when I made the example I just cut'n'paste the code from director when I was editing my reply. I must have left that bit in but you don't need it and if your teacher is going to look at the code you should probably remove it.

Anyways, I'm glad it helped. I don't get a chance to answer many director questions in here. Actually, this is the first director/lingo related question I've seen in a good six months. =)



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


« BackwardsOnwards »

Show Forum Drop Down Menu