Author Topic: [Code] Adding clickable sponsor art to preloader using pure Actionscript 3.  (Read 1074 times)

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Hi,

As we should know, preloader section of flixel is before we enter realm of flixel and is in pure Actionscrip3's stage stuff. So as sponsors want their clickable logo on the preloader one cannot use FlxButton or FlxButtonPlus and has to use Flash's stuff. I managed to do this and decided put the code here for people that will get sponsorship:

embed your logo:

Code: [Select]
[Embed(source="../data/sponsor_logo.png")]
protected var SponsorLogoClickable:Class;

Then put this in middle of your create() method:

Code: [Select]
/**
* This section loads sponsor's logo and renders it clickable in preloader.
*/
var mySprite:Sprite = new Sprite()
var marg:Bitmap = new SponsorLogoClickable();
mySprite.addChild(marg);
mySprite.addEventListener(MouseEvent.CLICK, goToMyURL);

mySprite.x = 13;
mySprite.y = 213;

// If you make a MovieClip (or Sprite) clickable, one would expect the mouse cursor to automatically
// change to a pointer or hand icon. However in as3, you need to specifically make that object selectable.
// http://flashscript.ca/hand-cursor.php
mySprite.buttonMode = true;
mySprite.useHandCursor = true;

_buffer.addChild(mySprite);

I don't know Flash's traditional stuff and it's the best thing I managed to do with googling and reading stuff at 6am but let me know if you need me to explain any of it, even though it's simple, but it wasn't at first ;)

Regards.
blog, twitter, Check out my award winning game, Rot Gut:

wg/funstorm

  • Global Moderator
  • Key Contributor
  • *****
  • Posts: 596
  • Karma: +0/-0
    • View Profile
    • Funstorm
Interesting, I used simplebutton. Don't really know what all the differences are to using sprite since I don't know vanilla as3 very well either. How did you do mouseover?

Code: [Select]
_btnSponsor = new SimpleButton();
_btnSponsor.upState = _btnSponsor.hitTestState = new graphicSponsorExtraBigOut();
_btnSponsor.overState = _btnSponsor.downState = new graphicSponsorExtraBigOver();
_btnSponsor.x = 700 / 2 - 468 / 2;
_btnSponsor.y = 230;
_btnSponsor.addEventListener(MouseEvent.CLICK, btnSponsorClick);
_btnSponsor.useHandCursor = true;
_buffer.addChild(_btnSponsor);

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Hey Wolfy,

If you mean how I managed the cursor become hand icon when it's over the sponsor's logo, it was these two:
Code: [Select]
mySprite.buttonMode = true;
mySprite.useHandCursor = true;

But if you mean how I did the button changes when mouse goes over the logo, IIRC we couldn't figure out how and didn't.

What was "simplebutton" ?
blog, twitter, Check out my award winning game, Rot Gut: