PDA

View Full Version : Stopping a loop


Wookie
04-17-2004, 11:41 AM
I have a fade effect, ie an image fades into view and then out of view using this code in the "on Timer"

if Opacity<=10 then
step=2;
elseif Opacity >=250 then
step=-2;

end

Opacity=Opacity+step;
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

The trouble is I want it to fade into view and then out of view once only, and then to fade into my main application...how do I stop this looping I am getting and then launch my main application?

TIA

Wookie

Wookie
04-17-2004, 06:04 PM
Anyone?

Wookie...

Wookie
04-17-2004, 06:52 PM
I have spent all day going through the scripting guide to find something that will solve my problem above. I cannot see anything there, can someone please offer some help or advice?

Wookie

SUF6NEWBIE
04-17-2004, 08:08 PM
Hey, try using the 'break' control word which is in the scripting guide.

pretty sure it's used for exactly that... breaking out of loops etc.

thats my 2 cents..hope gets you somewhere

MTN

Wookie
04-17-2004, 08:18 PM
Yeah I have tried that in various forms, but then the build fails as it says there is no loop to break...

But thanks for trying, I appreciate that!

Wookie

TJ_Tigger
04-17-2004, 08:19 PM
Very busy weekend. Try something like this.

[On Show]
direction = up
Opacity = 0
Page.StartTimer(50);

[On Timer]
if direction == up then
if (Opacity < 255) then
Opacity = Opacity + 2
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif Opacity >=255 then
direction = down
end
elseif direction == down then
if (Opacity > 0) then
Opacity = Opacity + 2
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif (Opacity <= 0) then
Page.StopTimer()
end
end

Corey
04-17-2004, 09:12 PM
Hey wow, neat code pasting thingy. :cool

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Wookie
04-18-2004, 12:00 AM
Thanks TJ..I have tried that one now and I'm afraid it does not work.

I get half of what I want ie, the image will fade from nothing to full view, then it just dissapears completely.

Thanks once again TJ...I appreciate the time and effort you spent trying this one out for me.

Wookie

Stefan_M
04-18-2004, 12:51 AM
change + to - in second part of the code

elseif direction == down then
if (Opacity > 0) then
--Change
Opacity = Opacity + 2 -> Opacity = Opacity - 2
---------
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif (Opacity <= 0) then
Page.StopTimer()
end
end

Stefan

Wookie
04-18-2004, 01:35 AM
Thanks Stefan...I have already tried that one....and I get the same result as above...in other words just half of the effect that I want.

I'll have to try again later, I'm off to bed now...

Thanks ALL of you who have tried this out for me...the saga continues!

Wookie

Stefan_M
04-18-2004, 03:04 AM
Try to enclose the direction parameters in ""

[On Show]
direction = "up"
Opacity = 0
Page.StartTimer(50);

[On Timer]
Code:
if direction == "up" then
if (Opacity < 255) then
Opacity = Opacity + 2
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif Opacity >=255 then
direction = "down"
end
elseif direction == "down" then
if (Opacity > 0) then
Opacity = Opacity + 2
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif (Opacity <= 0) then
Page.StopTimer()
end
end

Stefan

Wookie
04-18-2004, 06:10 AM
Nice one Stefan, its now mostly working.

My image fades from nothing to full opacity, then dissapears for a second then reappears at full opacity and fades away to nothing. I'm not sure why it dissapears...any ideas?

Thanks again Stefan!

Wookie

Stefan_M
04-18-2004, 06:33 AM
copy paste error
change + to - at second part of code
change elseif to else

[On Timer]
Code:
if direction == "up" then
if (Opacity < 255) then
Opacity = Opacity + 2
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif Opacity >=255 then
direction = "down"
end
elseif direction == "down" then
if (Opacity > 0) then
Opacity = Opacity - 2
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
else
Page.StopTimer()
end
end

Wookie
04-18-2004, 07:28 AM
I had already changed the + to a -, and making the elseif to else change did not change the way the app worked.

How do I save or publish this little app so I can attach it here for you all to view and tinker with?

Wookie

Wookie
04-18-2004, 07:34 AM
Here is a copy of the logo...Please bear in mind that I plan to make a better looking logo later on... ;)

Hope this helps you to help me..

Wookie

Stefan_M
04-18-2004, 08:23 AM
simple answer

Opacity greater than 255 is not allowed.

Stefan

Wookie
04-18-2004, 08:35 AM
"Enlightened Member"...I can see why!.. ;) :)

Thank you Stefan, that is brilliant.

Now before you go :D ..Now that the image is fading out and it finishes, I want to either boot to a new page or another application, do I just add file run at the end of the on timer?

Wookie

Corey
04-18-2004, 08:52 AM
In general, the best way to see if a given action will work in a given event is just to give it a shot, it will be instantly apparent whether or not it works. No risk, takes only a few seconds... The main thing is to experiment, in the long run that's the best way to really internalize these things. Two cents.

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Wookie
04-18-2004, 09:05 AM
Corey..I quite agree, I have learnt an awfull lot in the last couple of days and my head is fit to burst! When I have asked for assistance here, it means I have already tried it, and when I click "submit" on here I go back and continue trying.

It may seem to some that I am just making my application off the back of others help...not so...!

Yes I have questioned, quizzed, cajoled and all of the other things to get this first little step done, but I have also put an awfull lot of work into it also..including reading the scripting guide 2 and a half times over.

Anyway...I'm sticking around, hopefully I will be able to return the help I have received from members here, to others who join and then request help. Hopefully I will be able to help before AMS5 becomes AMS7.. :)

The help I have received here has been nothing short of phenomenal, I have been around the net for a good few years now and I have NEVER encountered such enthusiastic help before.

Thanks to all of those who have helped me on this and another thread.!! :)

Wookie

Corey
04-18-2004, 09:12 AM
Hi. Glad you're enjoying it. Just a tip, in order to get the most out of the scripting guide, try the examples out by hand as you go along. Coding them yourself, testing them, and then experimenting with a few of your own variations, will make it all stick in your mind in the best way possible. :)

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

Wookie
04-18-2004, 10:52 AM
BTW..I'm still looking to jump from this app to another page...Tried for over an hour or more now...:(

Any pointers?

Wookie

TJ_Tigger
04-18-2004, 11:40 AM
[On Timer]
Code
if direction == "up" then
if (Opacity < 255) then
Opacity = Opacity + 2
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif Opacity >=255 then
Opacity = 255
direction = "down"
end
elseif direction == "down" then
if (Opacity > 0) then
Opacity = Opacity - 2
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
elseif (Opacity <=0) then
Opacity = 0
Page.StopTimer()
Page.Jump("Page2")
end
end


Are you doing this with two applications or one application. One application to fade in your logo then fade out and another which is your actual application?

Wookie
04-18-2004, 11:53 AM
Hi TJ,

Well it was initially suggested that I use two apps for this effect, but either will be good, I have already tried the jump page action jumping to page two, and a few other page things..

I have also made a copy of this app and placed the whole folder inside the one for this fade app and tried to call the copy using "file.run" but still no joy.

Wookie

Wookie
04-18-2004, 11:58 AM
It will have to be a two apps I think as I want page2 and on to be rectangular, and the first page is "logo" shaped...

Wookie

TJ_Tigger
04-18-2004, 12:06 PM
Wookie,

Here is your logo app with the fade in and fade out. When the opacity reaches 0 on the fade out it will launch another application called mainapp.exe. This will need to be in the same folder as the logo app. I have a post on the board with an example of one app calling another app. It had to do with screen resolution but the concept is the same.

Here is the link
http://www.indigorose.com/forums/showthread.php?t=7141

In short what you need to do is build to a hard drive folder your logo application and to a separate folder your main application. The logo application you will want to select the Enable Autorun check box and for the main application deselect that same option. When you build your applications make sure you rename the exe on the main app to mainapp.exe or what ever you have named it in the logo app. Then copy the logo app executable and any graphics to the main app folder. Make sure that you include the .ccd file in the autoplay folder. hopefully this will help get you started.

Tigg

Wookie
04-19-2004, 02:25 PM
I have not tried this one yet but I will soon...Couple or queries...

I grasp the idea of most of what you have written, but for a few points..

In short what you need to do is build to a hard drive folder your logo application and to a separate folder your main application. The logo application you will want to select the Enable Autorun check box and for the main application deselect that same option.

Okay..no problem.

When you build your applications make sure you rename the exe on the main app to mainapp.exe or what ever you have named it in the logo app.

Also no problem, except..which files is the exe? Is it the Autorun file from the CD_Root folder or is it the AutoPlay Media Studio file that bears the name of my project? Or is it a published version..ie ready to burn? Also I will I guess need to rename the ccp aplication as two in the same folder would I guess be bad..

TIA

Wookie

SUF6NEWBIE
04-19-2004, 02:30 PM
this is a real quickie long shot...

elseif Opacity >=255 then
direction = "down"
end

change to:

elseif Opacity >= "255" then
direction = "down"
end

sorry guys trash this......dah..
pays to read all posts dont it

TJ_Tigger
04-19-2004, 03:32 PM
Also no problem, except..which files is the exe? Is it the Autorun file from the CD_Root folder or is it the AutoPlay Media Studio file that bears the name of my project? Or is it a published version..ie ready to burn? Also I will I guess need to rename the ccp aplication as two in the same folder would I guess be bad..

TIA

Wookie

This should be your autoplay.exe that would be automatically launched when you insert the CD. Look as the thread I posted to see more in detail what I was doing.

Wookie
04-19-2004, 09:47 PM
I finally managed to do it okay, after some fiddling with the code I changed the line
File.Open(_SourceFolder .. "mainapp.exe", _SourceFolder, SW_SHOWNORMAL)

to this..

File.Open("\\mainapp.exe", "{_SourceFolder}", SW_SHOWNORMAL)

And it now works a treat!!

The full code for the on timer now looks like this...

--Debug.Print("Current Opacity= "..Opacity.."/n/r");

if direction == "up" then
if (Opacity < 255) then
Opacity = Opacity + 2
if Opacity > 255 then
Opacity = 255;
direction = "down"
end
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
--elseif Opacity >=255 then
-- direction = "down"
end
elseif direction == "down" then
if (Opacity > 0) then
Opacity = Opacity - 2
if Opacity < 0 then
Opacity = 0;
File.Open("\\mainapp.exe", "{_SourceFolder}", SW_SHOWNORMAL)
Application.Exit()
end
long = DLL.CallFunction("AutoPlay\\Docs\\wTrans.dll", "SetWindowTransparency", handle..","..Opacity, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
--else
-- Page.StopTimer()
end
end

Big thanks to everyone who helped or who tryed to help...It been an educating couple of days.. :D

Wookie