Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Tips abd Tricks Actionscript 3.0 - Loader.content

This is a discussion on Tips abd Tricks Actionscript 3.0 - Loader.content within the Tutorials forums, part of the Flash English category; Greetings to all! Developing with Flash CS3 and Actionscript 3.0, we often need to use small tricks which are ...


Go Back   Forum Flash CS3 Flash CS4 > Flash CS3 Flash CS4 > Flash English > Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 27-09-07, 09:44
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
Tips abd Tricks Actionscript 3.0 - Loader.content

Greetings to all!
Developing with Flash CS3 and Actionscript 3.0, we often need to use small tricks which are often not easy to find. Every time that I will find myself in this situation, I will write an article.

The first article, as you will have understood from the title, regards the Loader class and its content property.

Let's see what is on about...

I take an example:

let's say that we have an SWF to load containing a TimeLine animation.
Once the SWF is completely loaded, we would like to interact with its TimeLine.

Imediatly, we would think to do the following way:
instanceNameLoader.content.play();

or

var clip:MovieClip=instanceNameLoader.content;
clip.gotoAndPlay(5);

In both case, Flash would return an error because the type of Loader's content (Loader.content) is not recognised by Flash at compile time.

At this point, we will need to use a trick:

I create a variable of 'universal' type, adding an asterisk.
The asterisk lets that variable hold any type of data.
var movie:*=instanceNameLoader.content.
Now, I create another variable, with a MovieClip data type, to which I will assign the value of the 'universal' variable (movie)
var clip:MovieClip=movie;
from now on, Flash recognised the Loader's content as a MovieClip with which I can interact as I wish.
clip.gotoAndPlay(5);

See you soon!
__________________

 


I recommend: Essential Actionscript 3.0

- I do not reply technicians pvt messages. Open a thread !
- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Tips and Tricks - MovieClip.dropTarget Flep Tutorials 1 13-11-08 11:28
Trucco del giorno - Loader.content Flep Articoli e tutorials 7 29-06-08 16:24
ActionScript 3 Tips hard_overclocker Flash English 8 18-05-08 12:34
Tips and tricks - ghost instance Flep Tutorials 0 25-09-07 17:14
Tips and tricks - MovieClip.mouseChildren Flep Tutorials 0 23-09-07 11:50


All times are GMT. The time now is 18:29.

Powered by vBulletin version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap