Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

What is the code?

New Here ,
Apr 07, 2013 Apr 07, 2013

how do I link text to a website in flash cs5? I've tried everything...

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2013 Apr 07, 2013

For AS3, use the navigateToURL()

     navigateToURL(new URLRequest(http://www.wherever.com));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2013 Apr 07, 2013

My website is viewable online at www.thewreath.org.  I still can't get the text to hyperlink to another site.  What should I do? The link I think gets broken and I can't see the dynamic content.  All I can see is red.

package

{

          import flash.display.MovieClip;

          import flash.events.Event;

          import flash.net.URLRequest;

          import flash.net.navigateToURL;

          import gs.TweenLite;

          import gs.easing.*;

          import org.papervision3d.events.InteractiveScene3DEvent;

          import org.papervision3d.materials.MovieAssetMaterial;

          import org.papervision3d.objects.DisplayObject3D;

          import org.papervision3d.objects.primitives.Plane;

          import org.papervision3d.view.BasicView;

          public class DocClass extends BasicView

          {

                    public var plane:Plane;

                    public var plane1:Plane;

                    public var plane2:Plane;

                    public var current:Plane;

                    public var home:MovieAssetMaterial;

                    public var about:MovieAssetMaterial;

                    public var contact:MovieAssetMaterial;

                    public var centerY:Number;

                    public var centerX:Number;

                    public function DocClass()

                    {

                              super(0, 0, true, true);

                              centerY = stage.stageHeight / 2;

                              centerX = stage.stageWidth / 2;

                              home = new MovieAssetMaterial("homeMat", true, true);

                              about = new MovieAssetMaterial("aboutMat", true, true);

                              contact = new MovieAssetMaterial("contactMat", true, true);

                              home.interactive = true;

                              home.smooth = true;

                              about.interactive = true;

                              about.smooth = true;

                              contact.interactive = true;

                              contact.smooth = true;

                              plane = new Plane(home, 350, 90, 1, 1);

                              plane.name = "homeButton";

                              plane.useOwnContainer = true;

                              plane.alpha = 0;

                              plane1 = new Plane(about, 350, 90, 1, 1);

                              plane1.name = "aboutButton";

                              plane1.useOwnContainer = true;

                              plane1.alpha = 0;

                              plane2 = new Plane(contact, 350, 90, 1, 1);

                              plane2.name = "contactButton";

                              plane2.useOwnContainer = true;

                              plane2.alpha = 0;

                              plane.z = plane1.z = plane2.z =-600;

                              plane.x = -400;

                              plane1.x = 0;

                              plane2.x = 400;

                              plane.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, clicked);

                              plane1.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, clicked);

                              plane2.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, clicked);

                              plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, over);

                              plane1.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, over);

                              plane2.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, over);

                              plane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, out);

                              plane1.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, out);

                              plane2.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, out);

                              scene.addChild(plane);

                              scene.addChild(plane1);

                              scene.addChild(plane2);

                              startRendering();

                              TweenLite.to(plane, .5, {alpha:1});

                              TweenLite.to(plane1, .5, {alpha:1, delay:.5});

                              TweenLite.to(plane2, .5, {alpha:1, delay:1});

                    }

                    protected override function onRenderTick (e:Event = null):void

                    {

                              var rotY: Number = (mouseY - centerY) / centerY * 200;

                              var rotX: Number = (mouseX - centerX) / centerX * 200;

                              camera.x += (rotX - camera.x) / 10;

                              camera.y -= (rotY + camera.y) / 10;

                              super.onRenderTick();

                    }

                    public function clicked(e:InteractiveScene3DEvent):void

                    {

                              trace(e.target.name);

                              switch(e.target.name)

                              {

                                        case "homeButton":

                                                  navigateToURL(new URLRequest("http://index.html"), "_blank");

                                                  break;

                                        case "aboutButton":

                                                  navigateToURL(new URLRequest("http://google.com"), "_blank");

                                                  break;

                                        case "contactButton":

                                                  navigateToURL(new URLRequest("http://www.google.co.uk"), "_blank");

                                                  break;

                              }

                    }

                    public function over(e:InteractiveScene3DEvent):void

                    {

                              current = e.target as Plane;

                              viewport.buttonMode = true;

                              var obj:MovieClip = MovieClip(MovieAssetMaterial(current.material).movie);

                              TweenLite.to(obj, .4, {frame:20, ease:Back.easeIn});

                    }

                    public function out(e:InteractiveScene3DEvent):void

                    {

                              current = e.target as Plane;

                              viewport.buttonMode = false;

                              var obj:MovieClip = MovieClip(MovieAssetMaterial(current.material).movie);

                              TweenLite.to(obj, .4, {frame:1, ease:Back.easeOut});

                    }

          }

}

Message was edited by: chineseadam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2013 Apr 07, 2013

I missed the "text" detail part of your first posting.  What in the code that you just showed is the problemed part?

If you want to link text that is in a textfield then you can use an html link if you assign the text to the htmlText property of the textfield.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2013 Apr 07, 2013

I tried that.  The screen is just red.  If I tamper with the illustration, by making a hyperlink, the website just goes red.  I need this fixed.  Do you want the file?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2013 Apr 07, 2013

If you show/explain what you are having a problem with someone might be able to help.  I do not see anyting in the code you showed that involves linked text, nor do I see anything in the site except for a number of images that fly too fast to try to click.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2013 Apr 07, 2013

the flying text is interactive.  If you hover over with your mouse, it slows down and the flying goes in the opposite direction.  Should I make the flying slower? I am having a problem with the text linking to websites when the mouse clicks onto a word/image or text.  I use actionscript with making a button or movie clip but i just end up seeing the red background of the flash file.  Can you help, please?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2013 Apr 07, 2013

Just assign the clicking event listeners to the movieclips instead of the text.  If the text happens to be in a dynamic textfield, be sure to set its selectable property to false (In the Properties panel click the selectable icon which appears as a small "Ab") to deselect it).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2013 Apr 07, 2013

I put the wrong code in by mistake.  This is the code:

package {

          import flash.display.*;

          import flash.events.*;

          public class ThreeD extends Sprite {

                    private var cont:MovieClip;

                    public var material:MovieClip;

                    public var speed:Number=0;

                    private var menu:Array = new Array();

 

                    public function ThreeD():void {

                              cont = new MovieClip();

                              cont.x=stage.stageWidth*0.5;

                              cont.y=stage.stageHeight*0.5;

                              addChild(cont);

                              addEventListener(Event.ENTER_FRAME, render);

                              material = new Content();

                              material.stop();

                              material.x = 620;

                              material.y = 100;

                              material.alpha=0.7;

                              addChild(material);

                              makeChildren();

                    }

                    private function makeChildren():void {

                              for (var i:uint=0; i<10; i++) {

                                        var bl:MovieClip = new Blob();

                                        bl.alpha=0.8;

                                        bl.addEventListener(MouseEvent.CLICK, onClick);

                                        bl.z=3000-(i*400);

                                        var frame=i+1;

                                        bl.gotoAndStop(frame);

                                        cont.addChild(bl);

                                        menu.push(bl);

                              }

                    }

                    private function onClick(e:Event):void {

                              var sp:MovieClip=MovieClip(e.target);

                              material.gotoAndStop(sp.currentFrame);

                    }

                    private function movement():Number{

                              var a:Number = stage.mouseX;

                              var b:Number = stage.stageWidth / 2;

                              var c:Number = 60;

                              return 0-((a-b)/c);

                    }

                    function render(e:Event):void {

                              speed  += movement();

                              if (speed>=50) {

                                        speed=50;

                              }

                              if (speed<=-50) {

                                        speed=-50;

                              }

                              for(var j:int=menu.length-1;j>=0;j--) {

                                        // loop through menu

                                        menu.z+=speed;

                                        if (menu.z>3400){

                                                  menu.z=-600;

                                        }

                                        if (menu.z<-600){

                                                  menu.z=3400;

                                        }

                              }

                    }

          }

}

And here is the code I am putting on the text or movie clip:

stop();

import flash.events.MouseEvent;

import flash.net.URLRequest;

var get ;bourbon_mc.URLRequest=new URLRequest("http://wwww.google.co.uk");

bourbon_mc.addEventListener(MouseEvent.CLICK, bClick),

function bClick(event:MouseEvent):void{

          navigateToURL(getbourbon);

}

}

Why is it not working?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2013 Apr 07, 2013

This line makes no sense:

var get ;bourbon_mc.URLRequest=new URLRequest("http://wwww.google.co.uk");

and you appear to have an extra curly brace at the very end.

Get rid of it and try:

bourbon_mc.addEventListener(MouseEvent.CLICK, bClick),

function bClick(event:MouseEvent):void{

     navigateToURL(new URLRequest("http://wwww.google.co.uk"));

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 07, 2013 Apr 07, 2013

If you happen to get error message you need to include them in your posting.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2013 Apr 07, 2013
Symbol 'bourbon_mc', Layer 'Layer 2', Frame 1, Line 51061: Call to a possibly undefined method addEventListener through a reference with static type Class.
Symbol 'bourbon_mc', Layer 'Layer 2', Frame 1, Line 51120: Access of undefined property bClick.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2013 Apr 08, 2013

I got two error messages... (see last posting)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 11, 2013 Apr 11, 2013
LATEST

There us something wrong with the object your code is targeting as bourbon_mc.

bourbon_mc.addEventListener(MouseEvent.CLICK, bClick),

What is that object and how was it created?

Also, at the end of that same line you have a comma.  That could be a source of an error.  Lines of code end with semi-colons.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines