Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / General Flash Topics / July 2008



Tip: Looking for answers? Try searching our database.

Creating a Password Protected page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jackcee - 14 Jul 2008 16:41 GMT
My site is built in Flash MX 2004. I want to ad a page in the site that allows the user to type a password in a box and it will then open a PDF document.
jedaniel - 14 Jul 2008 16:53 GMT
I have the perfect thing for you, but it will password protect the page before
proceding to the next page.  This may work for you if you have the submit
button to open up the link of the pdf.  Let me know if your interested in the
code.  I will send it to you via email.

Jason
jackcee - 14 Jul 2008 17:09 GMT
That would be great Jason. My email is: jclancey@ctmgroupinc.com
Thanks
Shan-Dysigns - 14 Jul 2008 17:39 GMT
All you have to do is create a dynamic text field for the password, and when
the user clicks on a submit button, flash checks if the dynamic text field's
".text" property is equal to your predefined password. If so, then getURL, if
not, whatever message you want to give them about incorrect password.
jackcee - 14 Jul 2008 17:54 GMT
Thank you for your reply Shan-Dysigns. How do I go about creating a "Dynamic Text Field"? Do you know anywhere I could look to see an example of how that might look in the coding?
Shan-Dysigns - 14 Jul 2008 18:05 GMT
Use the Text tool in Flash, in the properties panel, change from static text to
dynamic, draw a rectangle on the stage to represent your text area, assign it
an instance name (txtPassword), set the font properties, color, etc. If you
have a submit button with an instance name of btnSubmit, then in frame actions
you can use:

btnSubmit.onPress=function() {
if (txtPassword.text=="somePassword") {
getURL("path to pdf.pdf", "_blank);
} else {
// whatever you want to do here to let them know they are incorrect //
}
}
jackcee - 14 Jul 2008 18:31 GMT
Thank you. I really apprciate this.
jackcee - 14 Jul 2008 20:36 GMT
Hello Shan-Dysigns, I seem to be close but it's not quite working.
I created a rectangle, converted it to a symbol (named it txtPassword)
open the txtPassword symbol so I could edit it, choose the text tool, changed
it to Dynamic Text, clicked in the txtPassword rectangle, and set the text
properties. I then created a submit button (on a different layer), named it
btnSubmit, and gave it the following actions:
btnSubmit.onPress=function() {
if (txtPassword.text=="kiddie rides") {
getURL("testdocument.pdf", "_blank);
}
After publishing the Flash file and opening the page in my browser, when I
roll over the rectangle it turnes to a curser but when I try to type the
password, the letters don't type out. Did I miss something?
Shan-Dysigns - 14 Jul 2008 21:49 GMT
Part of your syntax is wrong. Look at my example
http://www.shan-dysigns.com/flash/password.fla to see how I did it. I also used
a text input component to make it easier than having to draw one yourself.
jackcee - 15 Jul 2008 13:14 GMT
Unfortunately I'm unable to open your Flash file. I'm using version MX 04. Could that be the issue?
Shan-Dysigns - 15 Jul 2008 14:30 GMT
I thought I converted it to MX, I usually do... try http://www.shan-dysigns.com/flash/passwordMX.fla
jackcee - 15 Jul 2008 14:34 GMT
Still no go. Not sure why. Any suggestions? I'm feeling really bad that I'm making you work like this. Do you have an hourly rate ...haha
Shan-Dysigns - 15 Jul 2008 15:08 GMT
Maybe it's time to upgrade your Flash program. I reread your post about the
steps you took. When you created a rectangle shape, then converted it to a
symbol, you have changed the path structure of my original suggestion. Let me
start over with the way you began.

-- create a rectangle path to act as the visible background of the text area
(make it white) - you can always change this later
-- convert that rectangle into a movie clip with instance name of mcPassword
-- open the new mc and add a layer on top of the shape, use the text tool
using dynamic text and draw an area for text, give it an instance name of
txtPassword, set font properties (use a system font for now so we don't have to
worry about embedding fonts)
-- back to the main time line, create a button, instance name of btnSubmit
-- frame action code: see attached

Your previous method had incorrect systax (left out a set of quotes in
"_blank" and was missing ending "}").

mcPassword.txtPassword.password = true;// this will change the characters to
"*" when someone is typing in a password //
btnSubmit.onPress = function() {
    if (mcPassword.txtPassword.text == "yourPassword") {
        getURL("http://www.domainName.com/testdocument.pdf", "_blank");// better to
use absolute paths in this case //
    }
};
jackcee - 15 Jul 2008 15:39 GMT
I've actually figured out how to do the text field as you initially showed
where you can see the password as you type. The problem now is how the submit
button finds the "testdocument.pdf" file. For my site, I store all the swf and
html files in one folder. When I want to, lets say find the custome style page,
I use this method
on (release){
_root.loadMovie("cus_styl.swf", root);
}
and it brings that page up. It doesn't seem to work when I store the
"testdocument.pdf" file. Because it's a pdf, do I need to store it some other
way?
Shan-Dysigns - 15 Jul 2008 16:23 GMT
If you load a movie at the root level, it's going to replace everything already
on the root. Is that what you want? If so, you don't need to re-reference the
root in the code.

_root.loadMovie("cus_styl.swf", root); needs to be
_root.loadMovie("cus_styl.swf");

You can't load a pdf file the same way you loaded this swf. You have to use
getURL
jackcee - 15 Jul 2008 17:39 GMT
Okay, I've named my text input area txtPassword. I've named my submit button
btnSubmit. My password is "kiddie". The "testdocument.pdf" is in the folder
where it should be. The script reads:

btnSubmit.onPress=function() {
if (txtPassword.text=="kiddie") {
getURL("testdocument.pdf", "_blank");
}

But it's still not working. I can type in the password field but hitting the
submit button doesn't do anything. I'm at a loss.
Shan-Dysigns - 15 Jul 2008 18:54 GMT
I noticed in my earlier instructions, I kept saying "dynamic text". I meant to
say "input text", so in your last post, I see you've caught that. At this
point, I am going to have to look at the flash file. There is something else
going on.
CHAOS'|nc. - 15 Jul 2008 20:43 GMT
There is a diff betn the two anyway?
jackcee - 15 Jul 2008 20:59 GMT
Success!! here's what I ended up with.

btnSubmit.onPress=function(){
if (txtPassword.text=="kiddie"){
getURL("testdocument.pdf", "_blank");
}
else{
    gotoAndPlay(60);
}
}

I put the action on a seperate layer instead of within the button. Not sure if
that was the main problem. I can't thank you enough for all your help and
patience. You may be seeing my screams of help again for other matters. If I
were you I'ld run the other way but hopefully you don't.
Thanks again
Shan-Dysigns - 16 Jul 2008 00:47 GMT
Well that would do it. The action script I gave is a frame action not a mc action. I try to place action script in a single frame as much as possible so all your code is in one area.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.