Web Hosting Forum | Lunarpages
News: October 6, 2008 - Submit Your Site for the October 2008 Site of the Month!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 15, 2008, 07:46:34 PM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: can make the button to be hyperlink?  (Read 1990 times)
begeiste
Galactic Royalty
*****
Offline Offline

Posts: 360


WWW
« on: April 26, 2007, 03:14:20 PM »

Hi,
Can action script make a href tag for linking to specific pages  inside of this action script?
on (rollOver) {
   _root.xnew = -314;
}


Thanks
Logged
brymstone
Pong! (the videogame) Master
*****
Offline Offline

Posts: 20


« Reply #1 on: August 15, 2007, 11:25:16 AM »

Hi begeiste,

You won't be able to make Flash display web pages inside your flash movie, but you can make it fetch web pages for you. And they can be displayed in either the same browser window the visitor has open, or in a new one completely.

Firstly, select your button symbol and press F9 to bring up the Actions panel. From there, remove any actionscript. Close the Actions panel, or re-press F9. With your button still selected, goto the Properties panel and give the button an instance name. Something like "outsideLink_btn".

Now create a new layer and name it "actions". On the first frame of that layer, hit F9. In the Actions panel, type the following to make the web page apepar in the visitor's current browser window:

outsideLink_btn.onRelease = function() {
    getURL("http://www.wherever.com", "_self");
}

Alternatively, type the following to make the web page appear to the visitor in a completely new browser window:

outsideLink_btn.onRelease = function() {
    getURL("http://www.wherever.com", "_blank");
}

Hit F9 again to hide the Actions panel. Test your movie. Make any changes you want to, then publish.

Hope this helps Smile
Logged
pb1856
Trekkie
**
Offline Offline

Posts: 19


WWW
« Reply #2 on: September 06, 2007, 06:40:57 AM »

Hi begeiste,

You won't be able to make Flash display web pages inside your flash movie, but you can make it fetch web pages for you. And they can be displayed in either the same browser window the visitor has open, or in a new one completely.

Firstly, select your button symbol and press F9 to bring up the Actions panel. From there, remove any actionscript. Close the Actions panel, or re-press F9. With your button still selected, goto the Properties panel and give the button an instance name. Something like "outsideLink_btn".

Now create a new layer and name it "actions". On the first frame of that layer, hit F9. In the Actions panel, type the following to make the web page apepar in the visitor's current browser window:

outsideLink_btn.onRelease = function() {
    getURL("http://www.wherever.com", "_self");
}

Alternatively, type the following to make the web page appear to the visitor in a completely new browser window:

outsideLink_btn.onRelease = function() {
    getURL("http://www.wherever.com", "_blank");
}

Hit F9 again to hide the Actions panel. Test your movie. Make any changes you want to, then publish.

Hope this helps Smile

How do you accomplish the same thing, but if you want to link a "page" within your flash movie - not an outside URL? 
Logged
brymstone
Pong! (the videogame) Master
*****
Offline Offline

Posts: 20


« Reply #3 on: September 11, 2007, 12:50:11 AM »

Hi pb1856,

There's several ways to accomplish this. Firstly, you should make sure your desired content (page) is contained within a movieclip.

Approach 1: On stage, but hidden until needed.

Place your movieclip on the stage on a separate layer with an easy to remember instance name. On a separate "actions" layer, in the first frame, set it's "visibilty" to false - like so:

Code:
// Example movieclip instance name: content_mc
content_mc._visible = false;

Next, write some code to tell a button to change that visibility to true when it's clicked:

Code:
// Example button instance name: my_btn
my_btn.onRelease = function() {
    content_mc._visible = true;
}

Approach 2: Attaching the movieclip to the stage when needed.

Having created your content movieclip, you'll need to know exactly where you'd like to place it on the stage. So place it where you want it to be, then select it and goto the Properties panel. Take note of it's X and Y coordinates. Also note that your movieclip will not initially need an instance name, so delete that if there is one. And you can now delete the movieclip from the stage. It's still in the library. Hit the shortcut key F11 to view the library. Right click on your movieclip and select Linkage. Take note of the Linkage Identifier for later - it's usually the same as the name you've given your symbol. Make sure the "Export for ActionScript" and "Export in first frame" check boxes are checked, then Ok it.

That's your movieclip prepared to be added to the stage. Now for the ActionScript to perform it:

Code:
// Attaching a movieclip to the stage from the library
attachMovie("content_mc", "content", 0, {_x:0, _y:0});

Let's understand what the above means:

attachMovie = the command to attach movieclips to the stage
"content_mc" = the linkage identifier from earlier goes here
"content" = this is where you supply an instance name
0 = the level your movieclip will be attached to
{_x:0, _y:0} = the X and Y coordinates you noted from earlier go here

Following on from Approach 2, if you have buttons or anything that needs to be accessed within your content movieclip, you can address those symbols by using the new instance name. As per the example code above, addressing a button would look like this:

Code:
// Example button instance name: another_btn
content.another_btn.onRelease = function() {
    // do something
}

And finally, removing the attached movieclip with a button:

Code:
// Example button instance name: remove_btn
// Attached movieclip instance name: content
remove_btn.onRelease = function() {
    removeMovieClip("content");
}

That's pretty much it. Hope it's helpful Thumbs Up
« Last Edit: September 11, 2007, 01:03:12 AM by brymstone » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM