Jump to content
Search Community

swf not loading until second click

ErinD test
Moderator Tag

Recommended Posts

Hi!

 

Testing locally I didn't come across this issue, but once I uploaded to my website, I noticed that when I click a thumbnail in my portfolio section, the swf does not load right away. In fact, It has to be clicked a second time for it play. Is there a way to overcome this so it works on the first click?

 

Thank you

 

site here: http://www.erindawson.net

Link to comment
Share on other sites

Hi, here is the code:

 

function thumbClicked(evt:MouseEvent):void

{

var num:uint = thumbArray.indexOf(evt.currentTarget);

var swfd:SWFLoader;

if (swfd == null)

{

swfd = new SWFLoader("img/" +folioXML.piece[num].filename, {onProgress:swfProgress, bgColor:0xffffff, scaleY:.71, scaleX:.73, container:movieContainer});

swfd.load();

}

else

{

swfd.unload();

removeChildAt(0);

swfd = new SWFLoader("img/" +folioXML.piece[num].filename, {onProgress:swfProgress, bgColor:0xffffff, scaleY:.71, scaleX:.73, container:movieContainer});

swfd.load();

}

captionHolder.text = folioXML.piece[num].description;

titleName.text = folioXML.piece[num].title;

 

addChild(newMask);

newMask.y = 30;

movieContainer.mask = newMask;

var movBack:createMask = new createMask(582, 350, 0xffffff);

addChildAt(movBack, 15);

swapChildrenAt(0, 15);

movBack.y = 30;

TweenMax.to(movBack, .01, {dropShadowFilter:{color:0x333333, alpha:.8, blurX:6, blurY:6, distance:6}});

}

 

I appreciate you taking the time to take a look!

 

Thanks

Link to comment
Share on other sites

There's your problem:

 

var swfd:SWFLoader;
if (swfd == null)
...

 

You declared a variable (swfd) and then checked if it's null...that will ALWAYS evaluate as true because you didn't set the swfd variable to any value yet.

 

Maybe you meant to declare that variable outside the method so that it persists? Remember, local variables that are declared inside functions only exist within that function - they get gc'd as soon as it finishes running the function.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...