Solved

Flash Vertical Scroller

Posted on 2008-06-25
5
209 Views
Last Modified: 2012-08-14
Hi,

I am trying to create a vertical scroller that moves up and down and contains external swf's from an cml file.

I have created an empty movie clip to hold the external swf's but cant get it to link out to a website. here is the code:

onClipEvent (load) {

for(i=1;i<=8;i++) {
  this.createEmptyMovieClip("container_mc"+i, this.getNextHighestDepth());
  //add spacing between each swf
  if(i>1) {
       this["container_mc"+i]._y +=(88*i-88);
  }
  this["container_mc"+i].loadMovie("swf"+i+".swf");
  trace(this["container_mc"+i]);
  this["container_mc"+i].onRelease = function() { trace("clicked");
        getURL('http://www.bbc.co.uk');
        }
 
}

Any ideas how to get something like this working?

Thanks
0
Comment
Question by:coolispaul
  • 3
5 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 21865727
When a movieClilp is loading an external SWF,
code must wait to load the external SWF completely, before apply onRelease action on same movieClip.

what happening in your case:

loadMovie start loading SWF,
code attachs an onRelease event to the same movieClip,
and now SWF load completes and all events gets cleared to the movieClip.

below is the updated code, which actual loads swf into a child movieCLip and  onRelease event has been attached to the parent movieClip.
now this should work fine:

onClipEvent (load) {
	for(i=1;i<=8;i++) {
		var mc = this.createEmptyMovieClip("container_mc"+i, this.getNextHighestDepth());
		var child = mc.createEmptyMovieClip("child",4);
		if(i>1) {
		   mc._y +=(88*i-88); 
		}
		child.loadMovie("swf"+i+".swf");
		mc.onRelease = function() { trace("clicked");
		getURL('http://www.bbc.co.uk');
	}  
}

Open in new window

0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 500 total points
ID: 21865756
sorry,
previous code has syntax error, below is the fixed code:
onClipEvent (load) 
{
	for(i=1;i<=8;i++) 
	{
		var mc = this.createEmptyMovieClip("container_mc"+i, this.getNextHighestDepth());
		var child = mc.createEmptyMovieClip("child",4);
		if(i>1) 
		{
		   mc._y +=(88*i-88); 
		}
		child.loadMovie("swf"+i+".swf");
		mc.onRelease = function() 
		{ 
			trace("clicked");
			getURL('http://www.bbc.co.uk');
		}
	}  
}

Open in new window

0
 
LVL 13

Expert Comment

by:crooksy88
ID: 21865834
You code is correct, just needs a closing } right at the end.

Also this code needs to be added to a movieclip symbol on the timeline as it is a clipEvent.

So, create a new movieclip symbol if you haven't already got one, then drag it to the stage, make sure it is selected on the stage and paste your code into the actions panel.

Then test your movie, obviously having your series of swf1.swf, swf2.swf etc in the same directory.

MC



onClipEvent (load) {
 
for(i=1;i<=8;i++) {
  this.createEmptyMovieClip("container_mc"+i, this.getNextHighestDepth());
  //add spacing between each swf
  if(i>1) {
       this["container_mc"+i]._y +=(88*i-88); 
  }
  this["container_mc"+i].loadMovie("swf"+i+".swf");
  trace(this["container_mc"+i]);
  this["container_mc"+i].onRelease = function() { trace("clicked");
        getURL('http://www.bbc.co.uk');
        }
  
}
}

Open in new window

0
 

Author Comment

by:coolispaul
ID: 21865907
Great thanks - that works .

Also one other question related to this.

How can i get the scroller to loop? i.e i have teh stage that holds 4 external swfs at once. I have the parent movieclip moving vertically upwards so that all 8 swfs are shown but then it blanks out. How can i get external SWF1 to show straight after SWF8 and therby giving the impression they are looping?

Thanks
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 21867893
with due respect,
this seems like another question which is not covered in current question details..

I request to open a new question with appropriate question heading, I will definitely provide the solution there.
Reason is,
Solution to nested questions are not searchable to other EE users.
IF we use proper question heading for each question,
Other users similar problem can easily search the question heading to get the solution.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do I convert a CS4 FLA file to CS6? 1 882
IE 11 Flash Player issue 7 249
Action Script commands 4 324
Devices and printers wont load and flash files in print spooler 3 217
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question