Jump to content
Search Community

Newbie questions...

ness_du_frat test
Moderator Tag

Recommended Posts

Hi ! I discovered TweenMax a few days ago, and I must it's kinda great :)

But it's not until today I noticed I could have several tweens in sequence. I did a sliding page, and like a totally dumb girl, I twisted the code so that I could get a tween after the previous one is finished... lol.

I found TimeLine, and it's exactly what I need. I plan on watching the video and reading the documentation, but first I'd like to know if what I want is doable... I guess it is, but then I also guessed it would be easy to make AS3 and mySQL communicate, and I spent my whole week-end struggling with encoding problems...

Anyway.

 

On one of my pages, I have a sliding movieclip, which displays the content, according to what button the user clicked on. (when I say button, I mean movieclips used as buttons)

When the user first comes to the page, the sliding page is already there, with the default content. When he clicks on one button (let's say chat), the sliding page should slide to the right with the default content, and come back with the chat content.

Right now, I have a really messy code with variables and errors everywhere, so I guess TimeLine will help me with this, since I won't have to put the code in the sliding page movieclip.

 

So, is it doable ? Is there anything I must know before starting, so that I don't get stuck and spend ages on a stupid little mistake ?

 

Thanks a lot !!!

 

So, now to the stupid girl part question... I downloaded the package, but I don't have any com folder... where is it ? I only have the gs folder, and the too swf examples. I already tried doing a little something using TimeLineLite, but no surprise here, TimelineLite() is not recognized, since I don't have the corresponding package... I thought everything was in the same zip file ? I really feel stupid, here ^^

Link to comment
Share on other sites

On one of my pages, I have a sliding movieclip, which displays the content, according to what button the user clicked on. (when I say button, I mean movieclips used as buttons)

When the user first comes to the page, the sliding page is already there, with the default content. When he clicks on one button (let's say chat), the sliding page should slide to the right with the default content, and come back with the chat content.

Right now, I have a really messy code with variables and errors everywhere, so I guess TimeLine will help me with this, since I won't have to put the code in the sliding page movieclip.

 

So, is it doable ? Is there anything I must know before starting, so that I don't get stuck and spend ages on a stupid little mistake ?

 

If you're asking if you could tween a MovieClip to the right and then run some of your code to populate it and then tween it back to the left, sure. TweenLite/Max can tween any numeric property of any object. You probably don't even need TimelineLite or TimelineMax, but definitely watch the video at http://www.greensock.com/timeline-basics/ to understand what they do - they can be extremely useful.

 

So, now to the stupid girl part question... I downloaded the package, but I don't have any com folder... where is it ? I only have the gs folder, and the too swf examples. I already tried doing a little something using TimeLineLite, but no surprise here, TimelineLite() is not recognized, since I don't have the corresponding package... I thought everything was in the same zip file ? I really feel stupid, here ^^

 

Where in the world are you getting your download from? It must not be from the greensock.com site. If you have a "gs" folder, it's very stale. Go to http://www.tweenmax.com (redirects to the appropriate greensock.com page) and click the big "Download AS3" or "Download AS2" button on the upper right corner. And please let me know where you got the stale stuff.

Link to comment
Share on other sites

I dowloaded it from here ^^ At least I think so, because I tried to have a look at the examples (the guy with the green sock that you can target to a point and have tweens applied to it), and that's when I decided to download it.

I would have had a look through my browser history, in order to tell you for sure if I found it here or not, but I have a funny (eurrh, not so funny, actually) bug with Firefox, that no update could solve : I don't have any history display. Only the bookmarks.) But as I can be clever sometimes, I found it : http://www.greensock.com/as/legacy/gree ... 10-as3.zip

I realise now that I downloaded an old version, but you know what ? On my first visit, I looked everywhere to find a download link, and that's the only one I found. Back here today, I started looking everywhere again, to finally realise, after 5 minutes, that it was the huge green download button on the right side of the page... Sometimes, the bigger and the more visible the things are, the less we see them ^^

(and sorry for my English, I'm French)

 

I'll ditch my as3 with the variables and messy code, and I'll try it with TweenMax, probably tonight. Thanks !

Link to comment
Share on other sites

So, I watched the video, and it was very useful, and a lot clearer than just seeing it written in the docs.

But, of course, I already have a problem, and probably an easy one.

 

contact.addEventListener(MouseEvent.MOUSE_DOWN, tween);
chat.addEventListener(MouseEvent.MOUSE_DOWN, tween);

// l'écran : 
var myTimeline:TimelineLite = new TimelineLite();

function tween(evt:MouseEvent) {
var cible=evt.currentTarget.name;
myTimeline.append(TweenMax.to(ecran, 1, {x:1000, y:70, tint:0x3399cc,rotation:360,scaleX:0.2, scaleY:0.2, alpha: 0.1}));
myTimeline.append(TweenMax.to(ecran, 2, {x:400, y:70, tint:null,scaleX:1, scaleY:1, alpha:0.5, ease:Back.easeOut}));
myTimeline.play();
ecran.ecran.titre_txt.text= fichierXML.page.(@nom==evt.currentTarget.name).@titre;
ecran.ecran.contenu_txt.text= fichierXML.page.(@nom==evt.currentTarget.name).@contenu;
}

So, that's my code. (I know, that's a lot of effects, but it's brand new and I'm still playing with it ^^) Now I'm a bit stuck, mainly because I don't know timelinelite very well (or it would be more accurate to say : I barely know it). When the user clicks on the contact button, I'd like "ecran" to go to the right side of the screen, then come back, and that's working perfectly. But I'd like "ecran" to bring back the info for the page "contact". I don't really now how to do that, I'm not used at all to this particular way of thinking. I guess there should be a fonction associated to the myTimeline variable, but this function should be triggered only when ecran comes back (with the ease:Back). And to complicate everything, the function will not be the same for all buttons (for some, I just have to put some text, that's what I'm (trying to do) doing with my xml file, for others, I'll need to do an addChild and place a movieclip inside ecran (and remove all other stuff). I guess the best way to do that would be to do addChild for everything, and have a movieClip with the text code inside, so that it can be removed like any other stuff. I really doubt I should do a new function for every button, but how can I pass the variables to the tween ? With the regular movieclip timeline, I would do a switch, but here, I'm lost...

(I know, I'm not being very clear, but it's not THAT clear in my head either...)

I would be glad for a little headstart on this one ^^

Link to comment
Share on other sites

Sorry, I didn't really follow what you're trying to accomplish. But I'd recommend looking into the onComplete special property. It allows you to call a function when a particular tween finishes (you can also define an onComplete for a whole TimelineLite/Max). I hope that helps.

Link to comment
Share on other sites

Ok.

But from what I saw, the onComplete is applied to the timeline variable, and what I need to do is call a function in the middle of the timeline. So should I define my timeline with only one tween inside, and inside the onComplete function I'll define the other tween ? Would it be the right solution ?

(oh, and if you want to have a look at what I'm trying to do, here is my website (not finished at all) : http://zarkan.org/test/jeu.html (you need to click on the desk, then on the screen on the desk. If you click on the first three buttons in the column, you'll see the sliding page in action, maybe my questions will be clearer then ^^)

(you'll see that, for example, the title of the sliding page changes when you click on a button, but I want it to change only when the sliding page comes back. Don't look at the content, for the moment I've only made the title changeable. I've modified the tween so that you can see the title when the page goes to the right)

Link to comment
Share on other sites

I've managed to make it work exactly like I wanted (at least the easy part), but I get these errors :

 

at Function/http://adobe.com/AS3/2006/builtin::apply()

at com.greensock.core::TweenCore/complete()[/users/Ness/Desktop/flash files/com/greensock/core/TweenCore.as]

at com.greensock::TimelineLite/renderTime()[/users/Ness/Desktop/flash files/com/greensock/TimelineLite.as]

at com.greensock.core::SimpleTimeline/renderTime()[/users/Ness/Desktop/flash files/com/greensock/core/SimpleTimeline.as]

at com.greensock::TweenLite$/updateAll()[/users/Ness/Desktop/flash files/com/greensock/TweenLite.as]

 

It does work, though, but I don't understand the error messages.

Link to comment
Share on other sites

It's very tough to troubleshoot errors when you don't show us the code that's generating the errors.

 

As far as the onComplete, you can use it in any of your tweens as well. So if you tween to the right and then tween back to the left, and you want to call a function right after the tween-to-the-right happens, you'd do something like:

 

var t:TimelineLite = new TimelineLite();
t.append( new TweenLite(mc, 1, {x:800, onComplete:myFunction}) );
t.append( new TweenLite(mc, 1, {x:0}) );

function myFunction():void {
   //do stuff here.
}

Link to comment
Share on other sites

Oh, that's cool !!! Too bad I haven't seen it earlier, that would have saved me a few lines of code. Anyway, I might change my code for the one you gave me, might make the things clearer.

So, about the code generating the error :

import com.greensock.*;
import com.greensock.easing.*;

var contact_form:contactformC=new contactformC();
contact_form.name="contact_form";
ecran.contentfond.visible=false;
var cible;
var oldcible;

var fichierXML:XML;
var chargeurDonnees:URLLoader=new URLLoader();
var adresseFichierXml:URLRequest=new URLRequest("pages.xml");
function donneesOk(event:Event) {
fichierXML=new XML(chargeurDonnees.data);
ecran.addChild(contact_form);
ecran.getChildByName("contact_form").x=20;
ecran.getChildByName("contact_form").y=50;
ecran.title_txt.text= fichierXML.page.(@nom=="contact").@titre;
ecran.contentfond.content_txt.text= fichierXML.page.(@nom=="contact").@contenu;
oldcible="contact";
cible="contact";

}
chargeurDonnees.load(adresseFichierXml);
chargeurDonnees.addEventListener(Event.COMPLETE, donneesOk);
// le contenu : 



contact.addEventListener(MouseEvent.MOUSE_DOWN, tween);
chat.addEventListener(MouseEvent.MOUSE_DOWN, tween);
quiz.addEventListener(MouseEvent.MOUSE_DOWN, tween);
information.addEventListener(MouseEvent.MOUSE_DOWN, tween);
facebook.addEventListener(MouseEvent.MOUSE_DOWN, tween);
rss.addEventListener(MouseEvent.MOUSE_DOWN, tween);
liens.addEventListener(MouseEvent.MOUSE_DOWN, tween);
questions.addEventListener(MouseEvent.MOUSE_DOWN, tween);
galerie.addEventListener(MouseEvent.MOUSE_DOWN, tween);
persos.addEventListener(MouseEvent.MOUSE_DOWN, tween);
guestbook.addEventListener(MouseEvent.MOUSE_DOWN, tween);

// l'écran : 
var myTimeline:TimelineLite = new TimelineLite({onComplete:retour});



function tween(evt:MouseEvent) {
trace("le target"+evt.currentTarget.name);
cible=evt.currentTarget.name;
myTimeline.append(TweenMax.to(ecran, 1, {x:1000, y:70, tint:0x3399cc,rotation:360,scaleX:0.2, scaleY:0.2, alpha: 0.1}));
//myTimeline.append(TweenMax.to(ecran, 2, {x:1000, y:70, tint:null,scaleX:1, scaleY:1, alpha:0.5, ease:Back.easeOut}));
myTimeline.play();
ecran.title_txt.text= fichierXML.page.(@nom==oldcible).@titre;
if (ecran.content_txt) {
ecran.contentfond.content_txt.text= fichierXML.page.(@nom==oldcible).@contenu;
trace(ecran.contentfond.content_txt.text)
}
else ("pas de content")
trace(oldcible);
}

function retour():void {
oldcible=cible;
TweenMax.to(ecran, 2, {x:400, y:70, tint:null,scaleX:1, scaleY:1, alpha:0.5, ease:Back.easeOut});

switch (cible) {
case "contact" :
ecran.getChildByName("contentfond").visible=false;
ecran.getChildByName("contact_form").visible=true;
ecran.title_txt.text= fichierXML.page.(@nom==cible).@titre;	
break;
case "chat":
ecran.getChildByName("contact_form").visible=false;
ecran.getChildByName("contentfond").visible=true;
ecran.title_txt.text= fichierXML.page.(@nom==cible).@titre;	
ecran.contentfond.content_txt.text= fichierXML.page.(@nom==cible).@contenu;
break;

default :
ecran.getChildByName("contact_form").visible=false;
ecran.getChildByName("contentfond").visible=true;
ecran.title_txt.text= fichierXML.page.(@nom==cible).@titre;
ecran.contentfond.content_txt.text= fichierXML.page.(@nom==cible).@contenu;

}

}

Link to comment
Share on other sites

You didn't describe what error you were getting - you only posted what function was called before the error happened. Please post the full error message, or better yet, post the FLA that generates the error (that's MUCH better for troubleshooting purposes). Don't forget to zip the file before you post it.

Link to comment
Share on other sites

Oh, if I could post the fla, I surely would, but I doubt you'd want to download a 25Mb fla file ^^

Anyway, that's the complete error :

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at ecrancloseupC/retour()[ecrancloseupC]

at Function/http://adobe.com/AS3/2006/builtin::apply()

at com.greensock.core::TweenCore/complete()[/users/Ness/Desktop/flash files/com/greensock/core/TweenCore.as]

at com.greensock::TimelineLite/renderTime()[/users/Ness/Desktop/flash files/com/greensock/TimelineLite.as]

at com.greensock.core::SimpleTimeline/renderTime()[/users/Ness/Desktop/flash files/com/greensock/core/SimpleTimeline.as]

at com.greensock::TweenLite$/updateAll()[/users/Ness/Desktop/flash files/com/greensock/TweenLite.as]

 

 

Which is really funny, because I don't know why on earth I would have a null object reference at line 88... I'm putting the code right below :

 

import com.greensock.*;
import com.greensock.easing.*;

var chatwindow:chatwindowC=new chatwindowC;
ecran.addChild(chatwindow);
chatwindow.name="chatwindow";
ecran.getChildByName("chatwindow").x=20;
ecran.getChildByName("chatwindow").y=50;
ecran.getChildByName("chatwindow").visible=false;
ecran.contentfond.visible=false;
var cible;
var oldcible;

var fichierXML:XML;
var chargeurDonnees:URLLoader=new URLLoader();
var adresseFichierXml:URLRequest=new URLRequest("pages.xml");
function donneesOk(event:Event) {
fichierXML=new XML(chargeurDonnees.data);
var contact_form:contactformC=new contactformC();
contact_form.name="contact_form";
ecran.addChild(contact_form);
ecran.getChildByName("contact_form").x=20;
ecran.getChildByName("contact_form").y=50;
ecran.title_txt.text= fichierXML.page.(@nom=="contact").@titre;
ecran.contentfond.content_txt.text= fichierXML.page.(@nom=="contact").@contenu;
oldcible="contact";
cible="contact";

}
chargeurDonnees.load(adresseFichierXml);
chargeurDonnees.addEventListener(Event.COMPLETE, donneesOk);
// le contenu : 



contact.addEventListener(MouseEvent.MOUSE_DOWN, tween);
chat.addEventListener(MouseEvent.MOUSE_DOWN, tween);
quiz.addEventListener(MouseEvent.MOUSE_DOWN, tween);
information.addEventListener(MouseEvent.MOUSE_DOWN, tween);
facebook.addEventListener(MouseEvent.MOUSE_DOWN, tween);
rss.addEventListener(MouseEvent.MOUSE_DOWN, tween);
liens.addEventListener(MouseEvent.MOUSE_DOWN, tween);
questions.addEventListener(MouseEvent.MOUSE_DOWN, tween);
galerie.addEventListener(MouseEvent.MOUSE_DOWN, tween);
persos.addEventListener(MouseEvent.MOUSE_DOWN, tween);
guestbook.addEventListener(MouseEvent.MOUSE_DOWN, tween);

// l'écran : 
var myTimeline:TimelineLite = new TimelineLite({onComplete:retour});



function tween(evt:MouseEvent) {
trace("le target"+evt.currentTarget.name);
cible=evt.currentTarget.name;
myTimeline.append(TweenMax.to(ecran, 1, {x:1000, y:70, tint:0x3399cc,rotation:360,scaleX:0.2, scaleY:0.2, alpha: 0.1}));
//myTimeline.append(TweenMax.to(ecran, 2, {x:1000, y:70, tint:null,scaleX:1, scaleY:1, alpha:0.5, ease:Back.easeOut}));
myTimeline.play();
ecran.title_txt.text= fichierXML.page.(@nom==oldcible).@titre;
if (ecran.content_txt) {
ecran.contentfond.content_txt.text= fichierXML.page.(@nom==oldcible).@contenu;
trace(ecran.contentfond.content_txt.text)
}
else ("pas de content")
trace(oldcible);
}

function retour():void {
oldcible=cible;
TweenMax.to(ecran, 2, {x:400, y:70, tint:null,scaleX:1, scaleY:1, alpha:0.5, ease:Back.easeOut});

switch (cible) {
case "contact" :
ecran.getChildByName("contentfond").visible=false;
ecran.getChildByName("contact_form").visible=true;
ecran.getChildByName("chatwindow").visible=false;
ecran.title_txt.text= fichierXML.page.(@nom==cible).@titre;	
break;
case "chat":
ecran.getChildByName("contact_form").visible=false;
ecran.getChildByName("contentfond").visible=false;
ecran.getChildByName("chatwindow").visible=true;
ecran.title_txt.text= fichierXML.page.(@nom==cible).@titre;	
ecran.contentfond.content_txt.text= fichierXML.page.(@nom==cible).@contenu;
break;

default :
ecran.getChildByName("contact_form").visible=false;  // that's line 88
ecran.getChildByName("contentfond").visible=true;
ecran.getChildByName("chatwindow").visible=false;
ecran.title_txt.text= fichierXML.page.(@nom==cible).@titre;
ecran.contentfond.content_txt.text= fichierXML.page.(@nom==cible).@contenu;

}

}

Link to comment
Share on other sites

This is unrelated to TweenLite/Max - there's a problem in your function related to a null object reference. For example, if you do ecran.getChildByName("contentfond").visible=false; and there's no child named "contentfond" in ecran, it would throw the error. I have no idea which one specifically is the problem, but you've got something in there that's returning null.

Link to comment
Share on other sites

I thought the errors might be unrelated, but you're right. Anyway, I cannot understand this error, since everything is where it's supposed to be, and if you check my code, contact_form is created at the begginning, way before the function is executed. I thought maybe flash would load the classes first and have a look inside or whatever, before creating the contact_form, and would trigger an error because something is missing.

Link to comment
Share on other sites

I was only using contact_form as an example - without seeing your FLA and being able to publish it myself, I'm really not sure what to tell you. There's a null reference in there somewhere. I'd recommend using trace() to output various objects to find out where the null reference is.

Link to comment
Share on other sites

I really can't find the problem. Actually, I must have understood something wrong, because my first attempt was to do "addChild" for the contact_form, or chatwindow, when the corresponding button was clicked, and removeChildAt, to remove it before putting something else in its place. Couldn't get it to work.

Anyway, I posted the fla on megaupload, if you want to have a look, it's in the movieclip called "ecranscloseup".

 

http://www.megaupload.com/?d=YJGKNYYE

 

Thanks :)

Link to comment
Share on other sites

I tried downloading the file and publishing it, but there were tons of compile errors:

 

**Error** Scene 1, Layer 'actions', Frame 1, Line 180: 1172: Definition Captcha could not be found.
    import Captcha;

**Error** Scene 1, Layer 'actions', Frame 1, Line 180: 1172: Definition Captcha could not be found.
    import Captcha;

**Error** Scene 1, Layer 'actions', Frame 1, Line 181: 1046: Type was not found or was not a compile-time constant: Captcha.
    var captcha:Captcha=new Captcha();

**Error** Scene 1, Layer 'actions', Frame 1, Line 181: 1180: Call to a possibly undefined method Captcha.
    var captcha:Captcha=new Captcha();

**Warning** Symbol 'clock', Layer 'Layer 3', Frame 1, Line 2: Warning: 3594: getHours is not a recognized method of the dynamic class Date.
    var mesHeures=monHorloge.getHours();

**Warning** Symbol 'clock', Layer 'Layer 3', Frame 1, Line 3: Warning: 3594: getMinutes is not a recognized method of the dynamic class Date.
    var mesMinutes=monHorloge.getMinutes();

**Warning** Symbol 'clock', Layer 'Layer 3', Frame 1, Line 4: Warning: 3594: getSeconds is not a recognized method of the dynamic class Date.
    var mesSecondes=monHorloge.getSeconds();

**Warning** Symbol 'clock', Layer 'Layer 3', Frame 1, Line 10: Warning: 3594: getHours is not a recognized method of the dynamic class Date.
    var mesHeures=monHorloge.getHours();

**Warning** Symbol 'clock', Layer 'Layer 3', Frame 1, Line 11: Warning: 3594: getMinutes is not a recognized method of the dynamic class Date.
    var mesMinutes=monHorloge.getMinutes();

**Warning** Symbol 'clock', Layer 'Layer 3', Frame 1, Line 12: Warning: 3594: getSeconds is not a recognized method of the dynamic class Date.
    var mesSecondes=monHorloge.getSeconds();

**Warning** Symbol 'closeupdigicode', Layer 'actions', Frame 1, Line 25: Warning: 3590: void used where a Boolean value was expected.  The expression will be type coerced to Boolean.
    var answer:Boolean=MovieClip(root).captcha.checkCaptcha(test_txt.text);

**Warning** Symbol 'contact form', Layer 'actions', Frame 1, Line 50: Warning: 3594: exec is not a recognized method of the dynamic class RegExp.
    var r:Object = p.exec(s);

 

If you'd like help, please post all the necessary files so that we can just open the FLA and hit "test" to see the problem.

Link to comment
Share on other sites

Yep, as suspected, ecran.getChildByName("contact_form") is returning null. You only add contact_form to ecran in the donneesOk(), so if retour() gets called before donneesOk(), it won't be able to find contact_form.

 

Since this really isn't related to GreenSock code at all, I can't spend the time to chase this down further for you (there's a LOT of code in that FLA!)

 

Good luck.

Link to comment
Share on other sites

Thanks !

Actually, I tried a version with contact_form added manually and visible set to false, the problem was the same. But thanks for trying :)

And BTW, there is absolutely no reason why return() should be called before donneesok, since the very first page shown is that of the contact form (which is here at that moment, when the page loads), and return is called only once a button has been clicked.

But anyway, sometimes, strange things happen...

Link to comment
Share on other sites

Hmm, well you could build something in a MovieClip timeline and use a TweenMax frame tween to control the playhead on the MovieClip timeline, and dump that TweenMax into a TimelineLite (or multiple TweenMax tweens), but yeah, TimelineLite is only for containing TweenLite, TweenMax, or other TimelineLite/Max instances. Have you watched the video at http://www.greensock.com/timeline-basics/ ?

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...