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

AS3 not working. Need to implement code to lauch viewer's default mail app. Please Help!

New Here ,
Feb 27, 2011 Feb 27, 2011

Hello,

I'm struggling to work out why; when you click on the "Contact" link/movie clip on my home page, it No Longer launches my Entourage default mail application. The action script is below. I've tried implementing loads of different mailto: as3 codes into my existing code, however none of them seem to be working with my existing code. I'm not an expert coder and could really use some idiot proof instructions/code here, what the code is, where to place it in the existing code and what other buttons/movie clip/instance name I'll need to create? Can anyone help me, Please?

Thank You,

Kavi

import flash.events.Event;
import flash.display.MovieClip;Picture 1.png

MASTER CODE:

var k:Loader = new Loader();
k.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop1);
k.contentLoaderInfo.addEventListener(Event.COMPLETE, done1);
k.load(new URLRequest("homeLoad.swf"));
function loop1(e:ProgressEvent):void {
    var perc1:Number=e.bytesLoaded/e.bytesTotal;
    percent.text=(Math.ceil(perc1*100).toString()) + "%";
}
function done1(e:Event):void {
    //removeChildAt(0);
    //percent.x=-1000;
    mainHolder.addChild(k);
    //k.x = (mainHolder.width - k.width)/2;
    //k.y = (mainHolder.height - k.height)/2;
}

var navigationsArray:Array = [homeLogo_mc.backToHome_mc, home_mc, branding_mc,typography_mc, advertising_mc, logos_mc, videos_mc, profile_mc, contact_mc ];

function addListeners():void
{
    for (var i:uint = 0; i < navigationsArray.length; i++)
    {
        navigationsArray.buttonMode = true;
        navigationsArray.mouseChildren = false;
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
       
    } // end of the for loop
} // end of function addListeners

function menuOnHover(e:Event):void
{
var targetMC:MovieClip = MovieClip(e.target); //specifies the movieClip clicked
targetMC.gotoAndStop(2); //move to frame 2 which has a light blue text
}
function menuOnMouseOut(e:Event):void
{
var targetMC:MovieClip = MovieClip(e.target); //specifies the movieClip clicked
targetMC.gotoAndStop(1); //move to frame 1 which has a white text
}

// to have the CLICK function, specify each function to each menu
home_mc.addEventListener(MouseEvent.CLICK, homePage);
homeLogo_mc.backToHome_mc.addEventListener(MouseEvent.CLICK, homePage);
function homePage(e:Event):void
{
    trace("home Page");
    for (var i:uint = 0; i < navigationsArray.length; i++) //loop to all menus on the array to reset(back to its white text)
    {
        navigationsArray.gotoAndStop(1); //move all menu to frame 1 which has a white text
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
    }

    home_mc.gotoAndStop(3); //move to frame 3 which has a dark blue text
    home_mc.removeEventListener(MouseEvent.ROLL_OVER, menuOnHover);
    home_mc.removeEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
   
    mainHolder.removeChildAt(0);
    percent.x=300;
    k.load(new URLRequest("homeLoad.swf"));
    SoundMixer.stopAll()

}

branding_mc.addEventListener(MouseEvent.CLICK, brandingPage);
function brandingPage(e:Event):void
{
    trace("branding Page");
    for (var i:uint = 0; i < navigationsArray.length; i++)
    {
        navigationsArray.gotoAndStop(1);
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
    }

    branding_mc.gotoAndStop(3);
    branding_mc.removeEventListener(MouseEvent.ROLL_OVER, menuOnHover);
    branding_mc.removeEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);

    mainHolder.removeChildAt(0);
    percent.x=300;
    k.load(new URLRequest("images.swf"));
    SoundMixer.stopAll()
}

typography_mc.addEventListener(MouseEvent.CLICK, typographyPage);
function typographyPage(e:Event):void
{
    trace("typography Page");
    for (var i:uint = 0; i < navigationsArray.length; i++)
    {
        navigationsArray.gotoAndStop(1);
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
    }

    typography_mc.gotoAndStop(3);
    typography_mc.removeEventListener(MouseEvent.ROLL_OVER, menuOnHover);
    typography_mc.removeEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);

    mainHolder.removeChildAt(0);
    percent.x=300;
    k.load(new URLRequest("images1.swf"));
    SoundMixer.stopAll()
}

advertising_mc.addEventListener(MouseEvent.CLICK, advertisingPage);
function advertisingPage(e:Event):void
{
    trace("advertising Page");
    for (var i:uint = 0; i < navigationsArray.length; i++)
    {
        navigationsArray.gotoAndStop(1);
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
    }

    advertising_mc.gotoAndStop(3);
    advertising_mc.removeEventListener(MouseEvent.ROLL_OVER, menuOnHover);
    advertising_mc.removeEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);

    mainHolder.removeChildAt(0);
    percent.x=300;
    k.load(new URLRequest("images2.swf"));
    SoundMixer.stopAll()
}

logos_mc.addEventListener(MouseEvent.CLICK, logosPage);
function logosPage(e:Event):void
{
    trace("logos Page");
    for (var i:uint = 0; i < navigationsArray.length; i++)
    {
        navigationsArray.gotoAndStop(1);
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
    }

    logos_mc.gotoAndStop(3);
    logos_mc.removeEventListener(MouseEvent.ROLL_OVER, menuOnHover);
    logos_mc.removeEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
   
    mainHolder.removeChildAt(0);
    percent.x=300;
    k.load(new URLRequest("images4.swf"));
    SoundMixer.stopAll()
}

videos_mc.addEventListener(MouseEvent.CLICK, videosPage);
function videosPage(e:Event):void
{
    trace("videos Page");
    for (var i:uint = 0; i < navigationsArray.length; i++)
    {
        navigationsArray.gotoAndStop(1);
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
    }

    videos_mc.gotoAndStop(3);
    videos_mc.removeEventListener(MouseEvent.ROLL_OVER, menuOnHover);
    videos_mc.removeEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
   
    mainHolder.removeChildAt(0);
    percent.x=300;
    k.load(new URLRequest("video.swf"));
    SoundMixer.stopAll()
}

profile_mc.addEventListener(MouseEvent.CLICK, profilePage);
function profilePage(e:Event):void
{
    trace("profile Page");
    for (var i:uint = 0; i < navigationsArray.length; i++)
    {
        navigationsArray.gotoAndStop(1);
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
    }

    profile_mc.gotoAndStop(3);
    profile_mc.removeEventListener(MouseEvent.ROLL_OVER, menuOnHover);
    profile_mc.removeEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
   
    mainHolder.removeChildAt(0);
    percent.x=300;
    k.load(new URLRequest("images3.swf"));
    SoundMixer.stopAll()

}

contact_mc.addEventListener(MouseEvent.CLICK, contactPage);
function contactPage(e:Event):void
{
    trace("contact Page");
    for (var i:uint = 0; i < navigationsArray.length; i++)
    {
        navigationsArray.gotoAndStop(1);
        navigationsArray.addEventListener(MouseEvent.ROLL_OVER, menuOnHover);
        navigationsArray.addEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
    }

    contact_mc.gotoAndStop(3);
    contact_mc.removeEventListener(MouseEvent.ROLL_OVER, menuOnHover);
    contact_mc.removeEventListener(MouseEvent.ROLL_OUT, menuOnMouseOut);
   
    mainHolder.removeChildAt(0);
    percent.x=300;
    k.load(new URLRequest("contact.swf"));
    SoundMixer.stopAll()
}
addListeners(); // call the function addListeners();

TOPICS
ActionScript
691
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 ,
Feb 27, 2011 Feb 27, 2011

It's best to keep the code you show focused on the problem at hand.  There is nothing readily evident in what you show that shows any attempt to implement a mailto link.  As for the contact_mc code, if it has any relationship to the problem, the contact_mc is loading a file named contact.swf, so maybe that other Flash file is where you need to turn your attention.

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 ,
Feb 27, 2011 Feb 27, 2011

Hi Ned,

Thanks for the prompt response and help. This is the mailto code I'm trying to implement into my existing code with no luck:

}


var linkToEmailAddress:URLRequest = new URLRequest("mailto:info@ackshundesign.com");

email_btn.addEventListener(MouseEvent.CLICK, emailAddress);

function emailAddress(event:MouseEvent):void
{
    navigateToURL(linkToEmailAddress);
   
}

I've changed the "email_btn" to "contact_mc" and tried a bunch of other things too.

Your advice made sense to me so I'll go over it again with a fine comb and see if I can work it out.

Any other tips on how and where to paste the mailto code above would be much appreciated.

If the ball is in my court now, I will keep at it, and hope to get it right.

Thank You,

Kavi

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
Guru ,
Feb 28, 2011 Feb 28, 2011

The code itself works.

The problem could be

in your Loader, you are using one Loader for all your different contents,

but the event.complete Handler seems to be tailored to a specific content.

Another possibility is that your loaded button is overlayed by sth. not visible.

use

email_btn.buttonMode = true

and see if the mouse cursor changes to a hand

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 ,
Mar 03, 2011 Mar 03, 2011

Hi Ned,

You steered me in the right direction after all! The problem lied in the contact page's absence of basic hyperlink coding! All sorted/Good now, THANK U very much for your help!

Cheers,

Kavi

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 ,
Mar 03, 2011 Mar 03, 2011
LATEST

You're welcome Kavi

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