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

What's wrong with my syntax?

Explorer ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

I'm getting an error with this. What's wrong with my syntax?

Error: Scene 1, Layer 'actions', Frame 1, Line 21 1084: Syntax error: expecting rightparen before semicolon.

// Line 21

holder.load(new URLRequest("Interactive_StrategyMap.swf" + "?random=" + Math.random();));

TOPICS
ActionScript

Views

961

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Jun 17, 2013 Jun 17, 2013

You need to get rid of that semi-colon siiting just after Math.random()   Leave the one at the end only.

Votes

Translate

Translate
LEGEND ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

You need to get rid of that semi-colon siiting just after Math.random()   Leave the one at the end only.

Votes

Translate

Translate

Report

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
Explorer ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

Thanks Ned,

That took care of that error but I'm still getting an undefined error. Do you know why this URLRequest is not loading the .swf? Lines 21 and 22

//THIS IS THE PRELOADER CONTAINER THAT LOADS THE INTERACTIVE
//STRATEGY MAP (Interactive_StrategyMap.swf).

// CREATE A NEW LOADER OBJECT TO HOLD THE LOADED CONTENT
var holder:Loader = new Loader();
addChild(holder);

// CREATE EVENT HANDLERS TO TRACK THE LOADING PROGRESS
// AND TO TRACK THE COMPLETION OF THE LOADED CONTENT
holder.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoading);
holder.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event):void {
this.loadingClip.visible = false;
}
function onLoading(e:ProgressEvent):void {
var pcent:Number = e.target.bytesLoaded / e.target.bytesTotal * 100;
loadingClip.loadingText.text = int(pcent) + "%";
}

// LOAD THE EXTERNAL CONTENT
holder.load(new URLRequest("Interactive_StrategyMap.swf" + "?random=" + Math.random()));
trace(holder.load(new URLRequest("Interactive_StrategyMap.swf" + "?random=" + Math.random())));

Votes

Translate

Translate

Report

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 ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

You should include the error message and you should identify which lines are 21 and 22 if you think they are relevant.

Votes

Translate

Translate

Report

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
Explorer ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

Hi Ned,

I'm trying to force my preloader to load the .swf every time. I do not want it stored in cache (because I'm trying to solve the issue where the dynamic text doesn't load on refresh)

So, I've added this math.random to the end of the string... but now the preloader .swf apparently can't see the .swf I want it to load because the path is Interactive_StrategyMap.swf?random=123 instead of Interactive_StrategyMap.swf

The error I get is:

completeHandler: Interactive_StrategyMap.swf?random=123

Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.

My full code is:

//THIS IS THE PRELOADER CONTAINER THAT LOADS THE INTERACTIVE
//STRATEGY MAP (Interactive_StrategyMap.swf).

// CREATE A NEW LOADER OBJECT TO HOLD THE LOADED CONTENT
var holder:Loader = new Loader();
var myString:String = "Interactive_StrategyMap.swf" + "?random=123" + Math.random();
addChild(holder);

// CREATE EVENT HANDLERS TO TRACK THE LOADING PROGRESS
// AND TO TRACK THE COMPLETION OF THE LOADED CONTENT
holder.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoading);
holder.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event):void {
this.loadingClip.visible = false;
}
function onLoading(e:ProgressEvent):void {
var pcent:Number = e.target.bytesLoaded / e.target.bytesTotal * 100;
loadingClip.loadingText.text = int(pcent) + "%";
}

// LOAD THE EXTERNAL CONTENT
holder.load(new URLRequest(myString));
trace("completeHandler: " + myString);

Votes

Translate

Translate

Report

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 ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

You probably want to apply your random appendage to the resource that is providing the text, not the swf. IF that's an xml file then apply it to the loading of the xml file.

In appending it you should use the same types of data.  Anyways, rather than trying to add a Number to String, coerce the Number to be a String...

"?random=123" + String(Math.random());

Votes

Translate

Translate

Report

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
Explorer ,
Jun 17, 2013 Jun 17, 2013

Copy link to clipboard

Copied

LATEST

That worked! ugh, I spent entirely too much time on this today

Thanks Ned! You rule.

Votes

Translate

Translate

Report

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